Introduction
In the last two articles of the tutorial series, we learned how to create a basic chatbot and how to integrate a lambda function to our bot for fulfillment. In this article, we’ll discuss what slots are and how to play around with slots to make our chatbot more interactive and richer. Let’s jump directly into the tutorial.
Series Info
Following is the four-tutorial series to learn how to develop a chatbot using Amazon Lex Service and deploy the same on Facebook Messenger.
- Creating a Chatbot using Amazon Lex Service: Day 1 (Initial Bot)
- Creating a Chatbot using Amazon Lex Service: Day 2 (AWS Lambda Functions)
- Creating a Chatbot using Amazon Lex Service: Day 3 (Slots in AWS Lex)
- Creating a Chatbot using Amazon Lex Service: Day 4 (Facebook Messenger Integration)
Slots
In this section, we’ll see how to collect customer information using Slots.
- You can add a new intent to prompt a customer to speak to the representative.
![Creating A Chatbot Using Amazon Lex Service - Slots In AWS Lex]()
- Add the new intent and name it CustomerInformation.
![Creating A Chatbot Using Amazon Lex Service - Slots In AWS Lex]()
- You can provide the sample utterances like “Contact Representative”, “Talk to human” etc.
![Creating A Chatbot Using Amazon Lex Service - Slots In AWS Lex]()
Coming down to slots section, provide the name of the slot, the type, and the prompt. Lex service provides various types of slots, we’ll use those.
- Choose Slot Name as name, choose Slot Type as AMAZON.person, and Prompt as “What is your name”. You can explore more on slot types by checking in the dropdown on what information you need to seek from the customer.
![Creating A Chatbot Using Amazon Lex Service - Slots In AWS Lex]()
We’ll add a few more slots like phone number, email id, preferred date of calling to the customer, preferred time of calling to the customer. Check the following picture for the implementation.
![Creating A Chatbot Using Amazon Lex Service - Slots In AWS Lex]()
Chatbot collects all the information from the user when the user intends to speak to the customer. You can check the "Required" checkbox to seek all the mandatory information.
- Now, add the confirmation prompt to make sure that all the information provided by the customer is correct. In the Confirmation prompt, you can reference Slot values by surrounding the Slot name with curly braces. So, we will include name, phone number, date, and time in our Confirmation prompt. If the user decides he/she doesn't want us to call them and says no at the confirmation, we will just say ”OK. Thanks!”.
- Now, we can save, build, and test our bot.
![Creating A Chatbot Using Amazon Lex Service - Slots In AWS Lex]()
Testing Slots
After the bot is built again, you can test the intent and the slots again to check if the bot is working fine.
So, when you type the sample utterances phrase like “Speck to a representative”, the bot starts collecting information as asked in the slot.
It asks, “What is your name?”, “What is your phone number” etc whatever was provided in the slot.
Once all the information is provided, it shows the confirmation prompt with the customer details that we provided in the prompt message for confirmation in curly braces.
Error Handling
We saw that our bot does not respond well to the user saying “Hi” or “Hello” or something that is not mentioned in the intent utterances and it keeps on showing the defaulted message and after few prompts, it says that it does not understand what the user is saying and goodbye. This is all configured for the bot as the default setting. We can change that as per our requirement using the Error Handling feature of Lex.
- Click on the orange color link saying Error Handling on the BotService.
![Creating A Chatbot Using Amazon Lex Service - Slots In AWS Lex]()
- In the clarification prompt, give the prompt on what your bot is capable of so that it shows the meaningful information to the user if the user types in anything that the bot does not understand. You can limit the maximum number of tries as you wish. I am limiting it to 2. After the two tries if the bot still doesn't understand the user, then give a meaningful hang-up phrase, like the user can call the customer care at a particular number or something else meaningful. You can delete the defaulted clarification prompt and hang-up phrase now.
![Creating A Chatbot Using Amazon Lex Service - Slots In AWS Lex]()
- Now test the bot and see that when we type phrases like “hi” or something else the bot prompts two times about what it can help with, and after that it shows the hang-up phrase.
![Creating A Chatbot Using Amazon Lex Service - Slots In AWS Lex]()
Conclusion
In this article, we discussed about the slots and error handling and working and integrating various kind of AWS Lex slots in the chatbot. You can make the bot richer by trying more slot options. In the next and last article of the series, we’ll learn how to deploy our chatbot in Facebook messenger and see that working live.