What is Amazon Lex?
Amazon Lex is a service by AWS for building conversational interfaces and chatbots that use natural language understanding (NLU) and automatic speech recognition (ASR). This lets you build voice- or text-based chatbots that can understand and respond
How I used Amazon Lex in this project
I used Amazon Lex to create a BankerBot that can answer the questions of the users accurately and efficiently
One thing I didn’t expect in this project was…
One thing I didn’t expect in this project is how easy it is to use Amazon Web Services to create a fully functioning Bot.
This project took me…
I spent a little over an hour on this project.
Setting up a Lex chatbot
I created my chatbot from scratch with Amazon Lex. Setting it up took me about 10 mins.
While creating my chatbot, I also created a role with basic permissions because I will need it later to call other AWS services on my behalf, later in this project series I will need to integrate Lex with another service called Lambda!
In terms of the intent classification confidence score, I kept the default value of 0.40.
Intents
An intent is what the user is trying to achieve in their conversation with the chatbot. For example, checking a bank account balance; booking a flight; ordering food.
I created my first intent, WelcomeIntent, to welcome a user when they say hello.
FallbackIntent
My chatbot returned the error message Intent FallbackIntent is fulfilled
when I entered any other sentences. This error message occurred because the bot was not trained to understand it.
Configuring FallbackIntent
FallbackIntent is a default intent in every chatbot that gets triggered when it does not understand what the user sent (users’ request)
I wanted to configure FallbackIntent so the user will know the bot does not understand their request instead of the default response which is hard to understand.
Variations
To configure FallbackIntent, I navigated to FallbackIntent section, and edited the Closing Response, and inputted the response I would prefer and added some variations to it as well
I also added variations! What this means for an end user is that they can get more than one type of responses when the bit does not understand their request.
Slots
Slots are pieces of information that a chatbot needs to complete a user’s request. They are like blanks that need to be filled in a form.
Here, I created a custom slot type to get the user’s bank account type
This slot type has restricted slot values, which means that only the values specified will count as a valid accountType.
What does this selection mean?
Selecting Restrict to slot values makes sure that only the values that you specify will count as a valid accountType!.
Otherwise, Amazon Lex will use machine learning to accept other values that it sees users constantly entering..
Different use cases will require different settings, but our BankerBot will only offer customers 3 types of accounts, we don’t want Amazon Lex to recognise any alternatives.
Creating the slot
Now let’s add the three account types!.
In the Values field, enter Checking.
Select Add value, or just press Enter on your keyboard..
Do the same for Savings.
Enter Credit, and add a few synonyms in the second field.
Press ; on your keyboard after every time you add in a new one:. credit card. visa. mastercard. amex. american express.
Choose Add value to finish up your work for Credit.
Choose Save slot type.
Connecting slots with intents
I associated my custom slot with CheckBalance, which is to check the balance in the specified account type.
In your left hand navigation panel, head back to Intents..
Choose Add intent, then Add empty intent..
Enter CheckBalance as your intent name.
Choose Add..
Enter the following description in the Intent details panel: Intent to check the balance in the specified account type..
Scroll down to Sample utterances..
Switch to Plain Text and paste in the following utterances:
What's the balance in my account?
Check my account balance
What's the balance in my {accountType} account?
How much do I have in {accountType} ?
I want to check the balance
Can you help me with account balance?
Balance in {accountType
Slot values in utterances
I included slot values in some of the utterances (i.e. user inputs) by putting it in curly braces For example; Balance in {accountType}
By adding custom slots in utterances, it allowed Amazon lex identify the required answers we are looking for. This means that Amazon Lex is now prepared to look for slot values from the user’s input. If a word fits what’s expected for the accountType slot, Lex will automatically fill in that information and won’t need to prompt the user for their accountType anymore (saving time for the user)!
You might remember that we mentioned the CheckBalance intent should also check for the user’s birthday… let’s create a Slot for the birth date!. Choose Add slot.. Use these values for your next slot:. Name: dateOfBirth. Slot type: AMAZON.Date. Prompts: For verification purposes, what is your date of birth?
Choose Save intent.. Choose Build — shall we answer some questions while you wait? 👀
now we are testing:
Top comments (0)