Creating a Voice bot using Amazon Connect
In this blog, I am going to walk you through creating a sample Lex bot and integrating it with Amazon Connect. Amazon Connect will allow us to create a contact flow mapped to a phone number which will allow us to interact with the Lex bot created via a phone call. Lets get started by creating the Lex bot first.
- From the AWS Management Console, search for Amazon Lex and then navigate to the Amazon Lex Console. Click on Create Bot. Select Start with an example from the Creation method menu and choose the BookTrip bot.
2. Give the bot a name. In my case, I am going with BookTripVoiceBot.
3. Leave all the other settings to its default values and scroll down to the bottom of the page.
4. Add tags to the bot if you want and then click on Next.
5. Here, you can add or change the language the sample bot will be trained in. I am going with the default configuration which is English (US) and the default voice Joanna. Keep the intent classification confidence score threshold to its default value and Click on Done.
6. Your bot will be created with the bot name you gave. Initially the bot is “Not Built”. So, click on the Build button to start the bot build process.
7. After a successful build, you can test the bot. For testing the bot, click on the Test button and then in the text box enter “book a hotel”.
8. The bot will ask you questions like the city you will be staying in, your check-in date, how many nights are you staying for and the type of room. Answer all of these questions via the textbox.
9. As a last step, the bot will confirm your booking details, if you say “Yes” then it will respond with the message “Intent BookHotel is fulfilled”.
10. For the BookHotel intent, you can take a look at the utterances and the slots that the bot has been created with. In this case, instead if “book a hotel”, you can also say “I want to make hotel reservations” to invoke the BookHotel intent.
11. You can also take a look at the slots created by the sample bot for storing location, check-in date etc.
12. Now, the bot that we have created and built successfully needs to be added in our connect instance so that it can be used in our contact flows. So, for doing that, navigate to the Amazon Connect console and click on the instance that you have created. Under the Contact Flows section, look for the Amazon Lex sub-section, and add the bot that you have created.
13. You should be able to see the bot that you added in the Amazon Lex bot list below. Now, we can use the Lex bot in our contact flow.
14. Navigate into the Connect Dashboard, under Routing, click on Contact Flows. Click on Create Contact Flow. From the Interact menu, drag and drop the Get Customer Input node. Give the contact flow a name, in my case I am using “BookTripVoiceBotContactFlow” name.
15. Double-click on the Get Customer Input node, select the Text-to-speech or chat text, in the text box, enter a Welcome message like the one in the image below. “Welcome to the Book Trip Bot. Please say book a hotel to make a hotel reservation or book a car to make a car reservation.”
16. Scroll down in the node properties and select Amazon Lex as the option, under Amazon Lex, select the Lex bot that you created from the Name drop-down menu and then select the Alias available (for a newly created bot it will be TestBotAlias).
17. Scroll down further more, then under Intents sub-section, add the 2 Intent names that the sample Lex bot created for us. Add “BookCar” and “BookHotel”. It is case-sensitive.
18. Now, add more play prompt nodes in the contact flow, just like the one in the image shown below and make the following links from the Get Customer Input node to the Play Prompt nodes.
19. Double-click on each of the Play Prompt nodes, and add prompts to each of them like “Thank you for booking a hotel with us” etc.
20. Add a disconnect node from the Terminate/Transfer menu and make the following links as shown in the image below for the contact flow. Click on Save and then Publish the contact flow.
21. Navigate into the phone numbers section, and click on the number you have claimed previously. It will open a page like the one below, where you will be able to select the Contact flow/IVR. From the drop-down menu, select the Contact Flow name that you created and then click on Save.
22. In the Manage Phone numbers page, you should see the phone number that you have claimed being mapped to the contact flow that you created.
Now, you will be able to test the contact flow that you created by placing a call to the number you have claimed. You can make use of the softphone that Amazon Connect provides to call and test your flow. The bot will give you a welcome message and ask you whether you would like to Book a Hotel or a Car. Based on the voice input that you give, you will have follow-up questions asked by the bot. After you finish your booking, you will get the appropriate message that you have added in the Play Prompt nodes of the contact flow based on whether you opted for booking a car/hotel.
Hope you had fun building this with me. Thank you for reading all the way :)