Woman using computer to communicate with chatbot and artificial intelligence

Developing powerful chatbots using Amazon Lex

With Amazon Lex, the same deep learning technologies that power Amazon Alexa are now available to any developer. With Amazon Lex you can build bots to increase contact center productivity, automate simple tasks and drive operational efficiencies across the enterprise. For an introduction to Amazon Lex, read Introduction to chatbots using Amazon Lex.

Components of Lex

The components of Lex are:

  • Intent: The action that we would like to perform. For example, booking a hotel or car rental.
  • Utterances: Phrases that invoke your intent. For example, “I’d like to book a hotel,” or “I’d like to reserve a car” invokes your intent.
  • Slots: The user input data required to fulfill intent.
  • Fulfillment: The end goal of your intent.

Chatbot figure 1

Figure 1 displays the different components of Amazon Lex using a sample conversation for the intent to book a hotel. [1]

Chatbot figure 2

Figure 2 displays how you can set up utterances and slots.


Below is an example of how a Lex chatbot works. The intent below is to book a car. The slots are the input that the user enters. In this example there are five inputs/slots. The five slots here are PickupCity, PickupDate, ReturnDate, DriverAge and CarType. The slots can be defined in the Lex console and the intent can also be defined.

The fulfillment here is the confirmation message that the bot gives you after the intent is fulfilled. We can even integrate our bot with Lambda function to perform further actions. For example, sending an email after the fulfillment of the intent.

Chatbot figure 3

Figure 3 displays the Amazon Lex conversation of booking a car rental.

Chatbot figure 4

Figure 4 displays the Amazon Lex bot response after booking the car rental.

Amazon Lex features

Natural conversations
Amazon Lex provides high quality natural language understanding with automatic speech recognition. It uses the same technology that Amazon Alexa uses. During any conversation with the bot, people will type numerous phrases that need to be classified accurately. Lex supports context management so you can manage context directly, without the need of custom code.

Builder productivity
Amazon Lex has a powerful life cycle management. Lex lets you manage different versions of the bots that you create. You can also roll back to previous versions if you are not comfortable with one of the new versions. You can classify the versions as dev, test and production versions. Amazon Lex also supports one-click deployment and lets you deploy your bots to various social media services.

AWS integrations
Lex integrates with Amazon Kendra, Polly, Lambda, CloudWatch, Cognito, DynamoDB and many more.

Contact center integrations
Amazon Lex integrates with Amazon Connect, Amazon’s cloud-based contact center enabling developers to build voice based conversational bots that can handle customers over the phone. Amazon Lex also integrates with AWS Contact Center Intelligence (CCI) which is a similar service to Amazon Connect. With this integration, you can seamlessly create self-service customer service virtual agents, informational bots or application bots.

Lex pricing

With Amazon Lex, you pay for what you use. There is no upfront commitment or minimum fee. Amazon Lex bots are designed under two models:

  1. Request and response interaction: Each user input (voice or text) is processed as a separate API call. Request response model has a different user experience, where user input is required as a trigger. With a continuous streaming conversation, all user inputs across multiple turns are processed in one streaming API call.
  2. Continuous streaming conversation: An example of continuous streaming conversation is when a user needs more time to respond, the bot will send periodic messages such as “take your time” or “let me know once you are ready.”

Amazon Lex also offers a free tier that can process up to 10,000 text requests and 5,000 speech/voice requests for the first year.

Lex QnA bot

Lex QnA bot is another type of chatbot where you can ask a question to the bot and the bot will reply with an answer. Lex QnA bot has the following features:

Uses cloud formation template
It is created from a cloud formation template and provides a UI which can be integrated with any application. You can configure your logic of the bot using lambda functions.

No need for existing infrastructure
With this bot, you don’t need to worry about infrastructure. You have all aspects of the bot built in. For example, you can focus on how the bot answers questions and deals with exceptions. It can also be integrated with social media and other AWS services.

Integrated with Amazon Cognito
This bot also integrates with Amazon Cognito to provide user access. If a user accesses it from a web application it will use an assumed role to assume the users identity and let him access the bot.

Design answers to your questions
With the QnA bot you can design answers to your questions. This bot provides a content designer view which lets you create questions and answers and store them. Here you can design how the bot should respond to your questions, or if the bot does not know the answer, how they should respond.

Customize your answers
You can also customize your answers, call a lambda function, display an image and even build a quiz. The confidence level to identify questions can also be set up. For example, if I have five keywords, then with 60% confidence will give three keywords that it will look for.

Chatbot figure 5

Figure 5 displays the content designer view. With this view you can configure your questions and their corresponding answers. The questions and answers can be customized based on the customer’s requirement.

Chatbot figure 6

Figure 6 displays QnA bot integrated to one of our applications.

Chatbot figure 7

Figure 7 displays a QnA bot working.

Chatbot figure 8

Figure 8 displays a QnA bot's response when it does not know the answer to a question. This is handled using a lambda function which triggers AWS Simple Email Service (SES) which sends an email to the customer.

Chatbot figure 9

Figure 9 displays the QnA bot email. This is configured using Amazon Lambda and AWS Simple Email Service (SES) APIs.

Amazon Lex use cases

Call center bots and voice assistants
You can use Amazon Lex bots in your call center which can perform tasks such as changing a password, requesting balance on an account or scheduling an appointment without speaking to an agent. From the users chat, Amazon Lex will identify the intent and reply accordingly to the user.

QnA bots and informational bots
With Amazon Lex you can build bots for everyday consumer requests such as accessing the latest news, game scores or weather. The bot can either ask questions or you can ask a question to the bot. You can also deploy them to mobile devices, websites, etc.

Application bots
You can build application bots to help customers access their bank account, book tickets, order food, call a cab and much more.

Enterprise productivity bots
Amazon Lex can be used to build enterprise bots that streamline common work activities and improve organizational efficiencies. For example, employees can check sales data from Salesforce, marketing performance from HubSpot and customer service status from Zendesk, directly from their bots within minutes.

How we can help

Amazon Lex makes developing powerful chatbots fairly easy. As an AWS partner, Baker Tilly Digital can help your organization build a chatbot to help your customers receive and fast and accurate information and improve your customers' experience. Contact us to learn more.

[1] Amazon Lex features
Other images created using Amazon Lex console and Baker Tilly products

Two men plan supply chain operations at a warehouse
Next up

The section 45X tax credit