AWS Contact Center

Amazon Connect with Amazon Lex Press or Say Input

You’re sitting in a public place and need to contact customer support over the phone. Perhaps you’re traveling and need to confirm or change a reservation or get an account balance. Maybe you need to reset an account password because you always access the account from your tablet instead of your phone. We’ve all been there.

So, you call customer support. But when you’re in a public place and want to enter sensitive personal information, speaking out the details may not be safe. Everyone around you could hear you, especially if you are trying to speak above the ambient noise.

Now imagine that, much to your delight, customer support let’s you enter all of your input and personal information using your touch-tone keypad. You don’t have to say anything at all.

Amazon Connect with Amazon Lex bots can now capture customer input as digits that customers enter on their numeric keypad when used in an Amazon Connect contact flow. Amazon Lex interprets dual-tone multi-frequency signaling (DTMF) digits entered on a keypad. It matches the intent based on that input in the same way it matches the intent when you speak an utterance. This provides for greater flexibility for customers to interact with your contact center. It also makes it easier for anyone that has difficulty speaking, whether that’s due to a cold or an earlier dentist appointment.

Customers can now choose how they want to enter sensitive information, such personal details or account numbers, on their keypads, while still using the natural language understanding engine behind Amazon Lex to converse with an Amazon Lex bot through Amazon Connect.

In this post, I explain how to create an Amazon Lex bot for use in an Amazon Connect contact flow. You can even try out my version in real time.


This solution includes the following tasks:

  1. Create an Amazon Lex bot – Provide a name and select other settings for your bot.
  2. Configure the bot – Update the settings for the bot to define how it behaves. This includes the following steps:
    • Create intents – An intent is an action that a customer wants to perform, such as getting their account balance. A bot could have one or more intents.
    • Add slots – The slots define the data that a customer must provide to fulfill the intent.
    • Configure the intent – Choose the collection of utterances and slots that match the customer’s intent based on their input, and then determines what happens next.
    • Configure the bot error handling – Configure how the bot handles errors, such as when the caller’s utterance is not understood.
  3. Build and test the bot – Make sure that the bot works as intended.
  4. Publish the bot and create an alias – Publish the bot to make it available to interact with.
  5. Add the bot to your Amazon Connect instance – Add the bot to your instance so you can use it in a contact flow.
  6. Create a contact flow and add the bot – Create a contact flow and define how the bot interacts with callers.
  7. Assign the contact flow to a phone number – Choose the number that customers can call to start the contact flow that includes the bot.
  8. Try it – Call the number you assigned the contact flow to so you try it out.

For this walkthrough, imagine that you are working in a development environment. Skip using an AWS Lambda function to integrate this into a backend database that validates information, and just read back sample data.


To follow along, you need the following:

  • An active AWS account.
  • An Amazon Connect instance created in the US East (N. Virginia) Region. After you create your instance, claim a phone number for it. For more information, see Getting Started with Amazon Connect.

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.

  1. Open the Amazon Lex console.
  2. If you are creating your first bot, choose Get Started. Otherwise, choose Bots, Create.
  3. 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.
  4. 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.

  1. Choose the + icon next to Intents, and choose Create new intent.
  2. Name the intent AccountLookup.
  3. Create another intent, and name it SpeakToAgent.

Add sample utterances

After defining the intents, add some sample utterances.

  1. Select the AccountLookup intent.
  2. Add a sample utterance, such as “Check my account balance” (don’t include the quotes), and choose the + icon.
  3. 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.
  4. Select SpeakToAgent.
  5. Add a sample utterance, such as “Speak to an agent,” and choose +.
  6. 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.

  1. Under Slots, add a slot named AccountNumber.
  2. For Slot type, select AMAZON.NUMBER.
  3. 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.”
  4. 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.

  1. Select the AccountLookup intent.
  2. 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.”
  3. Choose Save Intent.
  4. 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.”
  5. 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.

  1. To enable the Test Bot window, choose Build. It may take a minute or two.
  2. When it is finished building, choose Test Chatbot.
  3. In the Test Chatbot pane, type messages in the chat window.
  4. To test the AccountLookup intent, type “1” (without the quotes), and then type an account number.
  5. 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.

  1. Choose Publish.
  2. Provide an alias for your bot. Use the alias to specify this version of the bot in the contact flow, for example, Blog.
  3. 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.

  1. Open the Amazon Connect console.
  2. Select the Instance Alias of the instance to which to add the bot.
  3. Choose Contact flows.
  4. Under Amazon Lex, choose + Add Lex Bot.
  5. 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.

  1. Log in to your Amazon Connect instance with an account that has permissions for contact flows and Amazon Lex bots.
  2. Choose Routing, Contact flows, Create contact flow, and type a name.
  3. Under Interact, drag a Get customer input block onto the designer, and connect it to the Entry point block.
  4. Open the Get customer input block, and choose Text to speech (Ad hoc), Enter text.
  5. 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.

  1. In the Get customer input block, select Amazon Lex.
  2. For Name, use AccountBalance. For Alias, use Blog.
  3. To specify the intents, choose Add a parameter under Intents.
  4. Type AccountLookup, and choose Add another parameter.
  5. 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.

  1. If the caller presses 1 to get their account balance, use a Prompt block to play a message and disconnect the call.
  2. 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:

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

  1. Add a Set queue block and connect it to the SpeakToAgent node of the Get customer input block.
  2. 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.
  3. 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.

  1. Open the Amazon Connect Dashboard.
  2. Choose View phone numbers.
  3. Select the phone number to which to assign the contact flow.
  4. Add a description.
  5. In the Contact flow/IVR menu, choose the contact flow that you just created.
  6. Choose Save.

Try it

You can try the bot and contact flow that I created for this post in the Amazon Connect demo environment. Dial 206-607-8617, and follow the prompts.


In this post, I showed you how to create an Amazon Connect contact flow to take advantage of Press or Say functionality in an Amazon Lex bot and provide automated assistance to your customers.

Through the power of Amazon Lex conversational interfaces, your customers can now choose how best to provide input, and you can better route their calls to the appropriate bot or agent. I look forward to seeing all the wonderful things you will create with these great new features.