Book a vacation with Amazon Lex Automated Chatbot Designer (Preview) - Conversational AI - Part 1
Tags: tutorial, aws, beginners, ai
Published: 2022-03-05 14:32:54


## The rise of Conversational AI

Industries ranging from travel, startups, telecommmunications want 
to provide a unique customer experience, reach customers globally  and provide customer support to engage with customers with a digital experience via voice calls or text.

In this 24/7 economy, some customer profiles e.g. professionals, 
and millenials might prefer to contact a company after hours and choose not to speak directly to a contact centre agent or type with a live agent.

For example a professional might prefer to research and switch health insurance online, book a holiday or shop online at 11pm at night - in those given scenarios you just might meet a chatbot when you click on the landing page of a company website and click-through tabs.

Below is an example of a chatbot session with telecommunications provider Optus a subsidiary of Singapore Telecommunications Limited for researching cell phones.


![optus chatbot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j2w8y9bj4kffcsq6g34v.png)

In this global economy, contact centres may operate locally or within a shared services model with agents that you can speak with during business hours from 9am to 5pm and then outsource until 8pm to neighbouring Asian countries such as Singapore, Mumbai, Malaysia  and thereafter switch on a chat bot to act as a concierge service to answer FAQs.

### What is Conversational AI?

According to Deloitte, conversational AI is:

*A programmatic and intelligent way of offering a conversational experience to mimic conversations with real people, through digital and telecommunication technologies*

Conversational AI brings together 8 technology components including the following:

* **Natural Language Processing (NLP):** The ability to read or parse human language text
* **Intent Recognition:** The ability to understand what the user is requesting
* **Entity Recognition:** Some text 
* Fulfilment: Pull data from web services using APIs or databases
* **Voice Optimised Responses:** Engage in conversations in a human-like manner and show emotions to optimise the experience
* **Dynamic Text to Speech:** Converts written text to natural language
* **Machine Learning:** Understand the customer by analyzing agent responses
* **Contextual Awareness:** Ability to follow conversation history, translate, recall, memorise information over conversations

### What is Amazon Lex V2?

Amazon Lex is an AWS Service that builds conversational interfaces with voice and text. This enables developers to build chatbots within minutes instead of weeks using the Amazon Lex console.

### Benefits of building a bot with Amazon Lex V2

* You can analyze thousands of lines of audio transcripts and reduce effort to find the intent (i.e. the action the user wants to perform) using machine learning.

* You may build, test and deploy chatbots for websites, contact centres and messaging channels in a matter of hours instead of weeks.

* You can build a minimum viable product and then iterate to improve conversation design

* You can use chatbots to improve customer experience by designing intents that have well defined intent names, sample utterances and create a Lambda function to fulfill the intent.

### [NEW] from Amazon re:invent 2021 - Amazon Lex Chatbot Designer (Preview)

At AWS re:Invent 2021 there was an announcement of Amazon Lex Chatbot Designer in preview which means that you can test drive and build a chatbot using this service free of charge for a limited period.

You may re-play and watch the announcement from AWS re:Invent 2021 at this link below with Jenna Pederson, Sr. Developer Advocate, Gunnar Grosch, Sr. Developer Advocate and Harshal Pimpalkhute, Product Manager 

**AWS re:Invent 2021 - AWS On Air ft. Automated chatbot designer in Amazon Lex**

{% youtube n38xtnAIxYI %}

### High level architecture

This reference architecture from AWS provides an overview of how the Amazon Chatbot Designer works.The automated chatbot designer (preview) allows you to use your existing conversation transcripts. It analyzes the transcripts and suggests an initial design with intents and slot types.

Step 1: Input your audio transcripts into Amazon S3

Step 2: Transcripts are loaded into Amazon Chatbot Designer

Step 3: Deep Learning techniques will group and extract the intents (i.e. the reason for the phone call)

Step 4: The bot design will produce a list of intents that can be reviewed for intents and slot types

![Chatbot Architect](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rlgj1ujndu6aa3767q8h.png)

### How to create a bot with Amazon Lex V2

There are four steps to create a bot with [Amazon Lex V2](https://docs.aws.amazon.com/lexv2/latest/dg/how-it-works.html)

Step 1: Create a bot and add one or more languages

Configure the bot to do the following:

a) Understand the user goal
b) Engages conversation with the user to obtain information and
c) Fulfills the user's intent

Step 2: Test the bot

Use the test window client provided by Amazon Lex V2 console to test the bot.

Step 3: Publish the a version of the bot and create an alias.

Step 4: Deploy the bot. You can deploy the bot on your messaging channels such as Facebook Messenger and Slack.


### Tutorial 1: Build a Chatbot with Amazon Lex Automatic Chatbot Designer (Preview) with [existing data](https://docs.aws.amazon.com/lexv2/latest/dg/how-it-works.html)

Below is a chatbot session with online flight booking provider Last Minute for researching flight information outside business hours.

![bookfligthn](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d4ih229v0ngt7443aqto.png)

Step 1: Click on URL for [Chatbot Designer]
(https://aws.amazon.com/lex/chatbot-designer/)


![pic 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iwevy2j0hdnbflw0wavz.png)

Step 2: Create an example bot to Book a [flight](https://docs.aws.amazon.com/lexv2/latest/dg/exercise-1.html)


Step 3: Sign into the Amazon Lex V2 console with your login details for IAM user for your Amazon account

If you do not have administrator user access you may follow the steps in the [blog](https://dev.to/aws-builders/creating-your-first-iam-admin-user-and-user-group-in-your-aws-account-machine-learning-part-1-3cne) or read the instructions from the user guide [here](https://docs.aws.amazon.com/IAM/latest/UserGuide/getting-started_create-admin-group.html)

![iam console](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dygs18u91oq9jvlpozi3.png)

Step 4: In the Amazon Lex V2 bot console click **Create bot**.


![V2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xf4ql5sc01u2lx4v659q.png)

Step 5: For the **Creation method**, choose **Start with an example**


![start with an example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4utmydnsb70om8zncv88.png)


Step 6: In the **Example bots** section, select from the drop-down menu **BookTrip**


![booktrip](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fd9xxg0ns2ecm12edfdg.png)

Step 7: In the **Bot configuration** give the bot a name and a description for the purpose of creating a bot


![bot configuration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2rlsfl9sp40bmxredsdn.png)


Step 8: In the **Permissions** section, choose **Create a role with basic Lex permissions**


![IAM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0rbjfzknjpm6t6ll4ihu.png)

IAM permissions are required to run the bot.


Step 9: In the **Children's Online Privacy Protection Act(COPPA)** section read the terms and conditions and make the right choice.

![coppa](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ej4a10uh1lxd8f2l3ntd.png)

Step 10: In the **Session timeout** and **Advanced settings** retain the default settings and click **Next**. Amazon Lex 2 will create the bot.


![session](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0xws5i198ry2hrhr1mcc.png)

**Add language to a Bot**

Step 1: In the **Language** section, choose a language and provide a description. Select from the drop-down menu **English(GB)** and in the description type **British accent**


Step 2: Leave **Voice interaction** and **Intent classification confidence score threshold** with default settings.

Step 3: Select **Add language** to add a language to the bot.

Select **Emma** from the drop-down menu and use Standard speech-to-text.

Step 4: After the language is added, choose **Done** to continue.


![Emma](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dzmna83udcrputte2iyy.png)

Use the intent editor to inspect the intents used by the bot and once you are satisfied you can test the bot.

**To test the BookFlight bot**

Step 1: From the bottom of the menu, click **Build**. Wait a few seconds for the bot to be created.


![bot build](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tuaj05f7ft0mfos7poxv.png)

Step 2: After the bot has been created, click **Test** to open the test window.

Step 3:Test the bot.Start the conversation with a sample utterance or type your own e.g. "I would like to book a flight to London"

![Test bot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wpg3hs8115aiov09e28k.png)

### AWS re:Invent 2021 - Amazon Lex

**Demo of Amazon Lex Automated Chatbot Designer. re:Invent 2021 recaps**

{% embed https://www.youtube.com/watch?v=6Zo_vrbEz78 %}

### Getting Started with Amazon Lex

**Best practices for Conversation Design with Amaxzon Lex**

{% embed https://www.youtube.com/watch?v=3PsFIAdXTPo %}


### References

[What is Conversational AI?] (https://www2.deloitte.com/content/dam/Deloitte/au/Documents/strategy/au-deloitte-conversational-ai.pdf)

[Building bots] (https://docs.aws.amazon.com/lexv2/latest/dg/build-create.html)

[Amazon Lex Chatbot Designer (Preview)] (https://aws.amazon.com/lex/chatbot-designer/)

[Create an IAM User role](
https://docs.aws.amazon.com/IAM/latest/UserGuide/getting-started_create-admin-group.html)

### Glossary

Amazon Lex core concepts explained [here](
https://docs.aws.amazon.com/lexv2/latest/dg/how-it-works.html)

**Bot** – A bot performs automated tasks such as ordering a pizza, booking a hotel, ordering flowers, and so on. An Amazon Lex V2 bot is powered by automatic speech recognition (ASR) and natural language understanding (NLU) capabilities.

Amazon Lex V2 bots can understand user input provided with text or speech and converse natural language.

**Language** – An Amazon Lex V2 bot can converse in one or more languages. Each language is independent of the others, you can configure Amazon Lex V2 to converse with a user using native words and phrases. For more information, see Languages and locales supported by Amazon Lex V2.

**Intent** – An intent represents an action that the user wants to perform. You create a bot to support one or more related intents. For example, you might create an intent that orders pizzas and drinks. For each intent, you provide the following required information:

**Intent name** – A descriptive name for the intent. For example, OrderPizza.

**Sample utterances** – How a user might convey the intent. For example, a user might say "Can I order a pizza" or "I want to order a pizza."

**How to fulfill the intent** – How you want to fulfill the intent after the user provides the necessary information. We recommend that you create a Lambda function to fulfill the intent.

**Slot** – An intent can require zero or more slots, or parameters. You add slots as part of the intent configuration. At runtime, Amazon Lex V2 prompts the user for specific slot values. The user must provide values for all required slots before Amazon Lex V2 can fulfill the intent.

For example the OrderPizza intent requires slots such as size, crust type, and number of pizzas. For each slot, you provide the slot type and one or more prompts that Amazon Lex V2 sends to the client to elicit values from the user. A user can reply with a slot value that contains additional words, such as "large pizza please" or "let's stick with small." Amazon Lex V2 still understands the slot value.

**Slot type** – Each slot has a type. You can create your own slot type, or you can use built-in slot types. 

**Version** – A version is a numbered snapshot of your work that you can publish for use in different parts of your workflow, such as development, beta deployment, and production. 

**Alias** – An alias is a pointer to a specific version of a bot. 

Happy Learning! 😁

### Next Tutorial: Building a custom bot with automated chatbot designer in Amazon Lex (Preview) - Conversational AI- Part 2