Amazon Lex can add powerful automation to contact center solutions, so you can enable self-service via interactive voice response (IVR) interactions or route calls to the appropriate agent based on caller input. These capabilities can increase customer satisfaction by streamlining the user experience, and improve containment rates in the contact center.
In both the self-service and call routing scenarios, you may need to configure the bot so that it can obtain information commonly required in customer service calls. For example, to enable a self-service experience when the caller requests a transfer from their checking account to their savings account, you may have to first get their account ID.
Bots are more effective at processing a response if they know the related request or prompt (for example, “What is your account ID?”). Amazon Lex provides comprehensive dialog management capabilities, so that context can be maintained across a conversation. However, sometimes the initial prompt may occur before the Amazon Lex bot is engaged.
In the case of an IVR solution, for example, the welcome prompt (“Welcome to ACME bank. To get started, can you tell me your account ID?”) may be defined in the client (Amazon Connect) contact flow. In this case, the Amazon Lex bot isn’t aware that you already prompted the user for their account ID. This could be a source of ambiguity for the bot (imagine if someone called you and started a conversation by saying, “123456”).
To create the best customer experience in cases like this, we recommend that you provide your Amazon Lex bot with details about the prompt. In this post, we show a simple way to inform Amazon Lex about details such as a prior prompt already provided to the user.
For this example, we use an Amazon Lex bot that provides self-service capabilities as part of an Amazon Connect contact flow. When the user calls in on their phone, they’re prompted for their account ID (for example, a six-digit number). We demonstrate how the Amazon Connect contact flow passes context about the information requested (in this case, the
AccountId slot) to the Amazon Lex bot. As a best practice, we recommend setting the Amazon Lex dialog state to “slot elicitation” any time a user is prompted for a slot value.
We use the following sample banking interaction to model our Amazon Lex bot:
IVR: Hi, welcome to ACME bank customer service. To get started, please tell me your account ID.
IVR: Thanks. How can I help? You can check account balances, transfer funds, and order checks.
User: What’s my balance in checking?
IVR: The balance for your checking account is $875. Is there anything else I can help you with?
User: No thanks, that’s it.
IVR: Okay, thanks for contacting us today. We appreciate your business!
Let’s deploy an Amazon Lex bot to see how this works.
In this sample solution, we use AWS CloudFormation to deploy an Amazon Lex bot with an AWS Lambda fulfillment function, along with an example Amazon Connect contact flow that is integrated with the bot. The welcome prompt (“Welcome to ACME bank. To get started, please tell me your account ID.”) is configured in a “Play prompt” block in the contact flow.
The contact flow uses a Lambda helper function to inform Amazon Lex that the user has been prompted for a slot value. This is done via an “Invoke AWS Lambda function” block in the contact flow. The helper function makes a call to the Amazon Lex
put-session API, to tell Amazon Lex to elicit for the account ID slot value. See the following code:
Next, control passes to the “Get customer input” block in the contact flow to trigger the Amazon Lex bot. Because the bot is ready for the account ID slot, the conversation is more efficient. You can also handle scenarios where the caller doesn’t have the requested information, by creating an intent to respond to inputs such as “I don’t know.” Although the bot is expecting a number (account ID), if the user provides a different response, the appropriate intent is triggered.
Before deploying this solution, you should have the following prerequisites:
Deploy the sample solution
To deploy the solution, complete the following steps:
- Sign in to the AWS Management Console in your AWS account, and choose the following link:
This launches a new CloudFormation stack to create the example banking bot.
- For Stack name, enter a name (for example,
- For ConnectInstanceARN, enter the ARN (Amazon Resource Name) for the Amazon Connect instance you’ll use for testing the solution.
- Leave the other parameters at their default or change them as needed.
- Choose Next.
- Add any tags you may want for your stack (this step is optional).
- Choose Next.
- Review the stack details and select the check box to acknowledge that IAM resources will be created.
- Choose Create stack.
After a few minutes, your stack is complete, and includes the following resources:
- A Lex bot, including a published version with an alias (
- A Lambda fulfillment function for the bot (
- A Lambda helper function, which calls the Amazon Lex
put-sessionAPI to enable slot elicitation mode (
- A CloudWatch Logs log group for Amazon Lex conversation logs (optional)
- Required IAM roles
- A custom resource that adds a sample contact flow to your Amazon Connect instance
Test the bot on the Amazon Lex console
At this point, you can try the example interaction on the Amazon Lex console. You should see the sample bot with the name that you specified in the CloudFormation template (
- On the Amazon Lex console, choose this bot and choose Bot versions in the navigation pane.
- Choose Version 1, then choose Intents in the navigation pane.
- Choose Test.
- Select Development-Alias and choose Confirm.
The test window opens.
- Try “What’s my balance?” to get started. You can also say “order some checks,” “transfer 100 dollars,” and “goodbye.”
You will be prompted for an account ID.
Test the bot with Amazon Connect
Now let’s try this with voice using an Amazon Connect instance. We have already configured a sample contact flow in your Amazon Connect instance.
All you need to do is set up a phone number and associate it with this contact flow. To do this, follow these steps:
- On the Amazon Connect console, open your instance by choosing Access URL and logging in to the instance.
- On the Dashboard, choose View phone numbers.
- Choose Claim a number.
- Choose a country on the Country drop-down menu, and choose a number.
- For Description, enter a description, such as
Example contact flow that elicits a slot with Amazon Lex.
- For Contact flow, choose the contact flow you just created.
- Choose Save.
You’re now ready to call in to your Amazon Connect instance to test your bot using voice. Just dial the number on your phone and give it a try!
You may want to clean up the resources created as part of the CloudFormation template when you’re done using the bot, to avoid incurring ongoing charges. To do this, delete the CoudFormation Stack.
Amazon Lex offers powerful automated speech recognition (ASR) and natural language understanding (NLU) capabilities that you can use to capture information from your users to provide automated, self-service functionality, or to route callers to the right agents. Amazon Lex uses slot elicitation to collect information commonly needed in a customer service call. It’s important to provide the bot details on the type of information it should be expecting at the right times—in some cases, even on the first turn of a conversation. You can incorporate this technique in your own Amazon Lex conversation flows.
About the Authors
Brian Yost is a Senior Technical Program manager on the AWS Lex team. In his spare time, he enjoys mountain biking, home brewing, and tinkering with technology.