Manage dialog to elicit Amazon Lex slots in Amazon Connect contact flows

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.

Solution overview

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.

User: 123456.

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.

Solution architecture

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:

bot_response = lexClient.put_session(
        botId=bot_id,
        botAliasId=bot_alias_id,
        localeId='en_US',
        sessionId=session_id,
        sessionState={
            'dialogAction': {
                'type': 'ElicitSlot',
                'slotElicitationStyle': elicitation_style,
                'slotToElicit': slot_to_elicit
            },            
            'intent': {
                'name': intent,
                'slots': {},
                'state': 'InProgress',
                'confirmationState': 'None'
            },
            'activeContexts': [
                {
                    'name': context_name,
                    'contextAttributes': {},
                    'timeToLive': {
                        'timeToLiveInSeconds': int(context_ttl),
                        'turnsToLive': int(context_turns)
                    }
                }
            ],            
            'sessionAttributes': {}
        },
        requestAttributes={},
        responseContentType='text/plain; charset=utf-8'
    )

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.

Prerequisites

Before deploying this solution, you should have the following prerequisites:

Deploy the sample solution

To deploy the solution, complete the following steps:

  1. 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.

  1. For Stack name, enter a name (for example, lex-elicit-slot-example).
  2. For ConnectInstanceARN, enter the ARN (Amazon Resource Name) for the Amazon Connect instance you’ll use for testing the solution.
  3. Leave the other parameters at their default or change them as needed.
  4. Choose Next.
  5. Add any tags you may want for your stack (this step is optional).
  6. Choose Next.
  7. Review the stack details and select the check box to acknowledge that IAM resources will be created.
  8. 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 (Development-Alias)
  • A Lambda fulfillment function for the bot (BotHandler)
  • A Lambda helper function, which calls the Amazon Lex put-session API to enable slot elicitation mode (SlotElicitor)
  • 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 (banking-bot-sample).

  1. On the Amazon Lex console, choose this bot and choose Bot versions in the navigation pane.
  2. Choose Version 1, then choose Intents in the navigation pane.

You can see a list of intents.

  1. Choose Test.
  2. Select Development-Alias and choose Confirm.

The test window opens.

  1. 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:

  1. On the Amazon Connect console, open your instance by choosing Access URL and logging in to the instance.
  2. On the Dashboard, choose View phone numbers.
  3. Choose Claim a number.
  4. Choose a country on the Country drop-down menu, and choose a number.
  5. For Description, enter a description, such as Example contact flow that elicits a slot with Amazon Lex.
  6. For Contact flow, choose the contact flow you just created.
  7. 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!

Clean up

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.

Conclusion

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.

View Original Source (aws.amazon.com) Here.

Leave a Reply

Your email address will not be published. Required fields are marked *

Shared by: AWS Machine Learning

Tags: