Create an Amazon Lex bot
Create a custom bot to demonstrate the Press or Say integration with Amazon Connect. The bot prompts callers to press or say a number that matches the menu option for the task to complete. In this case, the input is checking their account balance.
Open the Amazon Lex console.
If you are creating your first bot, choose Get Started. Otherwise, choose Bots, Create.
On the Create your Lex bot page, choose Custom bot and provide the following information:
Bot name – For this demo, name the bot AccountBalance.
Output voice – Select the voice for your bot to use when speaking to callers. The default voice for Amazon Connect is Joana.
Session timeout – Choose how long the bot should wait to get input from a caller before ending the session.
COPPA – Choose whether the bot is subject to the Child Online Privacy Protection Act.
User utterance storage – Choose Store
Choose Create.
Configure the Amazon Lex bot
Determine how the bot responds to customers by providing intents, sample utterances, slots for input, and error handling.
Create intents
For this example, configure the bot with two intents: one to look up account information, and another to speak with an agent.
Choose the + icon next to Intents, and choose Create new intent.
Name the intent AccountLookup.
Create another intent, and name it SpeakToAgent.
Add sample utterances
After defining the intents, add some sample utterances.
Select the AccountLookup intent.
Add a sample utterance, such as "Check my account balance" (don't include the quotes), and choose the + icon.
Add a second utterance, "One" (without the quotes), and choose the + icon.This assigns the utterance of "one" or key press of "1" to the AccountLookup intent.
Select SpeakToAgent.
Add a sample utterance, such as "Speak to an agent," and choose +.
Add a second utterance, "Two" (without the quotes), and choose + icon.
Add slots
Before the bot can respond with the caller's account balance, it needs the account number.
Under Slots, add a slot named AccountNumber.
For Slot type, select AMAZON.NUMBER.
For Prompt, add the text to be spoken when the call is answered. To highlight the new DTMF support, ask callers to enter their account number using their keypad. For example, "Using your touch-tone keypad, please enter your account number."
Make sure that the Required check box is selected, and choose the + icon.
Add responses
Now that you have intents, utterances, and a slot, add the responses that the bot provides to callers. Because you are creating a simple bot for this example, you are not hooking up the bot to look up real customer data. The example bot responds with text strings that you add, regardless of the account number that a caller provides.
Select the AccountLookup intent.
In the Response section, add a message for the bot to say to customers. For example, "The balance for your account is $2,586.34."
Choose Save Intent.
For the SpeakToAgent intent, add a message that lets callers know that their call is being connected to an agent. For example, "Okay, an agent will be with you shortly."
Choose Save Intent.
Build and Test the Amazon Lex bot
After you create your bot, make sure it works as intended before you publish it.
To enable the Test Bot window, choose Build. It may take a minute or two.
When it is finished building, choose Test Chatbot.
In the Test Chatbot pane, type messages in the chat window.
To test the AccountLookup intent, type "1" (without the quotes), and then type an account number.
To confirm that the SpeakToAgent intent is working, type "2" (without the quotes).
Publish the Amazon Lex bot and create an alias
Next, publish the bot so that you can add it to a contact flow in Amazon Connect.
Choose Publish.
Provide an alias for your bot. Use the alias to specify this version of the bot in the contact flow, for example, Blog.
Choose Publish.
Add the Amazon Lex bot to an Amazon Connect instance
To use a bot in your contact flow, add the bot to your Amazon Connect instance. You can only add bots created under the same AWS account and in the same Region as your instance.
Open the Amazon Connect console.
Select the Instance Alias of the instance to which to add the bot.
Choose Contact flows.
Under Amazon Lex, choose + Add Lex Bot.
Select the AccountBalance bot and choose Save Lex Bots. If you published the bot after you opened the settings for your instance, reload the page to get it to show up.
Create a contact flow and add your Amazon Lex bot
Next, create a new contact flow that uses your Amazon Lex bot. Create the contact flow When you create the contact flow, you can configure the message played to callers.
Log in to your Amazon Connect instance with an account that has permissions for contact flows and Amazon Lex bots.
Choose Routing, Contact flows, Create contact flow, and type a name.
Under Interact, drag a Get customer input block onto the designer, and connect it to the Entry point block.
Open the Get customer input block, and choose Text to speech (Ad hoc), Enter text.
Type a message that provides callers with information about what they can do. For example, use a message that matches the intents used in the bot, such as "To check your account balance, press or say 1. To speak to an agent, press or say 2."
Add the Amazon Lex bot to your contact flow
The bot is defined as the method of getting customer input.
In the Get customer input block, select Amazon Lex.
For Name, use AccountBalance. For Alias, use Blog.
To specify the intents, choose Add a parameter under Intents.
Type AccountLookup, and choose Add another parameter.
Type SpeakToAgent, and choose Save.
Finish the contact flow
After the caller interacts with the bot, finish the contact flow to complete the call for the customer.
If the caller presses 1 to get their account balance, use a Prompt block to play a message and disconnect the call.
If the caller presses 2 to speak to an agent, use a Set queue block to set the queue and transfer the caller to the queue, which ends the contact flow.
To complete the AccountLookup intent:
Under Interact, drag a Play prompt block to the designer, and connect the AccountLookup node of the Get customer input block to it. After the customer gets their account balance from the Amazon Lex bot, the message in the Play prompt block plays.
Under Terminate/Transfer, drag a Disconnect / hang up block to the designer, and connect the Play prompt block to it. After the prompt message plays, the call is disconnected.
To complete the SpeakToAgent intent:
Add a Set queue block and connect it to the SpeakToAgent node of the Get customer input block.
Add a Transfer to queue block and connect the Set queue block Success and Error nodes to it. You could also add a message that plays when the call cannot be transferred because the queue is full or an error occurs.
Choose Save & Publish.
Your finished contact flow looks something like the following:
Assign the contact flow to a phone number
When callers call in to your contact center, the contact flow to which they are sent is the one assigned to the telephone number that they dialed. To make the new contact flow active, assign it to a phone number for your instance.
Open the Amazon Connect Dashboard.
Choose View phone numbers.
Select the phone number to which to assign the contact flow.
Add a description.
In the Contact flow/IVR menu, choose the contact flow that you just created.
Choose Save.