Last Updated on February 17, 2023

Amazon Web Services (AWS) is a globally trusted comprehensive cloud platform adopted by major corporations, government agencies, and growing startups. These organizations are adopting this to innovate and become more agile. Amazon Lex is a part of AWS and is gaining popularity among leading companies throughout the world.

What is Amazon Lex?

Amazon Lex is a service by AWS for building conversational interfaces into any application using voice and text. Lex has quickly become popular among chatbot enthusiasts. Notably, popular Amazon products such as Alexa are powered by the same technology as that of Amazon Lex.

In this blog, I will help you to understand the basic concepts of Lex and explain how to create a bot and integrate it into your website.


Bonus: Don’t know to code? Try our codeless bot builder.

Understanding AWS Lex

To understand the Lex platform, let’s consider the conversation below between a flight booking chatbot and a user:

User: Book me a flight to New York from Boston.

Bot: Sure! Which date do you want to fly?

User: I am planning to fly on the 10th of October.

Bot: Ok. Do you want me to book a return ticket as well?

User: Yes.

Bot: Please help me with the date of your return.

User: It is 15th October.

Bot – Alright.  Searching for a flight for the 10th of October and returning on the 15th october. Here are the results.

Here, the bot collects the basic information from the user,  processes it, and displays the search results to the user. To create this conversation flow using Lex, let’s first discuss the terminology and concepts used in the Lex console. You can create a free account in Amazon Lex to build your chatbot.

Jump To-


An intent represents an action that the user wants to perform. When an end-user interacts with the bot, the user’s query is matched to the best intent available in the bot.  Every intent has a set of Sample utterances. You can use the Sample utterance to match the user’s query with an intent. You can configure a bot to support multiple intents. These combined intents can handle a complete conversation. 

CTA banner

Sample utterance

This is the collection of possible expressions that an end-user might say. These are basically phrases that mean the same as our defined intent. Let’s go back to our flight booking bot. There are multiple ways to ask a bot to book your flight:

Book me a flight to New York.

Find me a plane to New York.

I want to go on a trip to New York.

Hey, let’s go to New York this winter. 

You can provide these expressions while configuring the intent. You can use these expressions to build a model to categorize the user’s queries.

When a user uses any of these sentences, then, this model identifies the intent. If multiple intents are matched, the best match is triggered. Suppose that none of the intents are matched, you can set a message in the Error Handling section to handle such scenarios. If the intent is matched, Lex will check how to fulfill the intent. 

Fulfilling the intent

Fulfillments are the responses that the bot sends when an intent is triggered. There are two ways to define fulfillment:

  1. Create a Lambda function to fulfill the intent: Amazon recommends creating a Lambda function which will be called when the intent is triggered. Lex will send all details (intent detail and slots), and the Lambda function will perform the action and decide which response to be sent to the user.
  2. Lex returns the information(intent detail and slots) to the client application to do the necessary fulfillment.


Slots are the parameters that are defined as part of the intent configuration. The value of a slot is extracted dynamically at runtime from the user’s query.  Slots contain structured data that can easily be used to perform some logic or generate responses.

Each slot has a type that dictates the type of value the slot would contain. Lex provides some inbuilt intents and slot types to extract the basic information i.e, city names, dates, some measurement units, etc.   

For example, when the user says:

Book me a flight to New York.

You can configure a slot so that your bot can detect the parameter “DestinationCity” and populate it with the value “New York” or whichever city is present in the user’s query.

Now, let’s identify the other possible slots in the above conversation. 

slots in Amazon Lex Kommunicate
Understanding Slots in Amazon Lex

Here is how your Amazon Lex console looks with this configuration.

 Amazon Lex console

You can configure fulfillment after finishing the slot configuration.

Configuring Lambda functions as fulfillment

When a user provides all of the slot data required to fulfill the intent, your Lambda function will be invoked if enabled. Lex sends data to the lambda function in a specific format mentioned here. The Lambda function thus performs the business logic.

In our flight booking scenario, our Lambda function calls the flight search APIs to get the result for the user’s query. Then it returns the result to Lex in the aforementioned format. Further, Lex forwards this response to the end user.

This was all about learning the basic functioning of the Amazon Lex platform. Let’s now jump into testing your bot and integrating it into a website.

Build test and publish the bot

After finishing all the configurations, you need to build your bot before you start testing. Lex provides a test window where you can test your bot and see how the bot replies to the user’s queries.

Please note that if you are changing any intent configuration, you must build it again to make the latest changes visible in the test window. 

Publishing the bot creates a new version of it. It allows you to create a different version of your bots, and you can control the version which your application use.

Integrating Amazon Lex bot into a website

Lex has inbuilt support to integrate bots with some platforms such as Facebook, Kik, Slack, etc.  If you want to integrate your bot with your website or mobile apps, you have two ways:

  1. Using AWS SDK: AWS SDK provides APIs to send queries to the bot. This requires a lot of programming knowledge, development, and maintenance efforts.
  2. Using Kommunicate, which provides a codeless integration with Amazon Lex.

Integrate Amazon Lex using Kommunicate

Kommunicate is a bot+human hybrid customer support software that provides code-less integration with chatbot builder platforms such as Amazon Lex, Google Dialogflow, etc. Once integrated, your users can chat with your bot using a beautiful and customizable chat widget.

Your Lex bot can be integrated into your website in a few simple steps:

Here is the quick video.

Step 1: Create a free Kommunicate account

You can create a free account in Kommunicate. Head to the signup section to start.

Step 2: Connect your Amazon Lex bot

Post signup, navigate to the bot integration section and select the Amazon Lex platform. Kommunicate requires the below detail to query your bot on your behalf. 

Kommunicate Bot integration

You just need to fill in a few details to connect your Lex bot. You can get these details in your AWS Management Console -> Security credentials section.

  1. Access key ID & Secret access key: Access key ID and secret access key are required to sign requests sent to your Lex bot. To get your access key, sign into your AWS console as an IAM user having permission to access Lex API. Locate your user name in the upper-right section of the navigation bar. From the drop-down menu, select My Security Credentials. Then create an access key in the Access keys for CLI, SDK, & API access sections. You can find more detail in this blog.
  2. Bot name in Lex platform: This is the same name you entered while creating the bot in the Lex platform. If you are not aware of it, you can also get it from the bot list on the Lex home page.
  3. Bot alias: A bot alias is a pointer to a specific bot version. The alias is exposed to client applications instead of the version.  If you publish a new version of the bot and want kommunicate to connect to the new version, you can simply point the alias to the new version from Lex console without changing anything on Kommunicate Dashboard. 
  4. Region: AWS region where your Lex service is running. You can find your region in the top-right corner, following the user name in the AWS console.

Once you have the above information follow the below steps, click Save and Proceed.

Step 3: Give your bot an identity

You can give your bot a name and a profile picture. The name and the profile picture will be visible to your users while interacting with your bot. Give your bot a name. This name will be visible to your users who interact with your bot. Click Save and Proceed.

Step 4: Enable/Disable human handoff

Your bot is as smart as you can make it. But at times, it may fail to understand a user’s questions. In that case, you can trigger a chatbot to human handoff. This helps you make the overall user experience better and handle edge cases.

Choose whether to enable or disable this feature and click on Finish bot integration setup.

Step 5: Assign all the incoming conversations to your Lex bot

To let your user chat with the new bot, you need to assign all the conversations to the bot. After finishing the bot setup, click on Let this bot handle all the incoming conversations. Now, all new conversations initiated after the integration will be assigned to this bot, and your bot will start answering them.

You can also enable conversation assignments from the Conversation Rules section.

Step 6: Install the Kommunicate chat widget on your website

The final step is installing the Kommunicate chat widget on your website so your website user can chat with your bot. Copy the installation script from the Install section and paste it into your website. Here are the detailed instructions to install the same.  This is how the chat widget looks on a website

Kommunicate chat widget

Publish your website, and your bot will be ready to chat with your users. Hurray! That was easy, isn’t it?

Suggested Reads: Add Rich Message Button Response in Amazon Lex

CTA banner

Organizations using Amazon Lex successfully

Here are a couple of organizations that have successfully implemented Lex into their business processes to yield significant results.


TransUnion is a worldwide information and insights enterprise that helps businesses transact with their customers using data such as credit scores, credit checks, and credit reports. 

Prior to Amazon Lex, this was handled by TransUnion’s contact center, which was high in cost, and also inefficient. TransUnion customers’ time went into navigating the IVR system before they could talk to an agent. By implementing Amazon Lex which is a part of Amazon Connect, to automate the IVR. This change has significantly reduced customer wait times in the contact queue. The customer spends 18 seconds in the IVR as opposed to the previous 2 minutes, with a transfer rate cut by half. This has led to a 40% reduction in the annual costs of the contact center. 


ROYBI Inc. is an enterprise that has its objectives in changing early-childhood education for the better. They mix robotics with AI to make a fun, interactive learning experience that offers more benefits than traditional teaching methods. 

This formative period in a child’s life is where they absorb the most information and build a foundation that will carry them through life.” AWS and ROYBI have built a customized platform using the computer vision product Amazon Rekognition to enable learning between children and ROYBI robots. This is where Amazon Lex is the conversational interface that comprehends and engages the child to deliver a better multi-modal learning experience.

Wrapping up the Amazon Lex tutorial

Amazon Lex is a great tool that can be used in conjunction with other suites in AWS to create unique products and services that meet customer needs. You can use Kommunicate to integrate your Amazon Lex chatbot (through this Amazon Lex tutorial) to serve your unique business objectives and serve your customers well. 

Suggested Reads: Integrate Dialogflow Chatbot in Your Website

At Kommunicate, we envision a world-beating customer support solution to empower the new era of customer support. We would love to have you on board to have a first-hand experience of Kommunicate. You can signup here and start delighting your customers right away.

Write A Comment

Upcoming Webinar: Conversational AI in Fintech with Srinivas Reddy, Co-founder & CTO of TaxBuddy.