AWS LEX Walk Through

AWS Lex Walk Through

Amazon Lex is a service for building conversational interfaces using voice and text. With Lex, the same deep learning engine that powers Alexa is now available to any developer, enabling you to bring sophisticated, natural language chatbots to your new and existing applications.

I am using “coffee buying” scenario for this walk through. The main purpose of this blog is to walk through how to setup Lex, what’s the basic elements and how to interact with Lex.

There are three must have elements in Lex in order to work which is Intent, Utterances and Slots.

As the name itself, is what the user wants. In my scenario, buying coffee is the intention.

Kinda like triggers that activate the coffee buying process. For example, when certain keywords are mentioned, then start the coffee buying process.

Conditions for intent. In my scenario, slots would be like type of coffee, size and hot or iced etc.

AWS Lex Walk Through

A response is not a compulsory element but will make the whole process more complete.

In addition, Lambda can be integrated with Lex but I will not use it in this demo. Now, let’s get started

Once at Lex home page, click “Get Started”

AWS Lex Walk Through

As featured image, you will be prompted Custom or some simple bot. Let’s build our own bot as the image below and have some fun.

AWS Lex Walk Through

First create Intent. Actually it could be anything, it is just a name.

AWS Lex Walk Through
AWS Lex Walk Through

Next, we create utterances to trigger the buying process, you can give any sentences to trigger it. When interacting with Lex, as long as any utterances are mentioned, it will trigger the process.

AWS Lex Walk Through

Next, click on the + sign of “Slot types” to setup conditions that need to fulfill the process.

AWS Lex Walk Through

Named your condition(Slot type name) and expected value/answer return by user, click “Add slot to intent” once done. Repeat this step two more times to add size and hot/iced. Be creative, there is no right or wrong answer, you can put anything you like here. ^^

AWS Lex Walk Through

Modify the “Name” and “Prompt”, you can modify it anyway you like.

AWS Lex Walk Through

A finish view.

AWS Lex Walk Through

Lastly, let’s design the response from Lex once the whole process is completed. Scroll down a bit to click on “Response” follow by “Add Message”. Click the + sign once done. {XXX} means to take whatever the user input during the process and response back to user when finish.

AWS Lex Walk Through

It is worth mentioning that for error handling, such as user input something not as expected, you can modify/design the error response from “Error Handling” section.

AWS Lex Walk Through

Finally, scroll to the bottom and click “Save Intent”, follow by clicking “Build” on top right comer.

AWS Lex Walk Through

You will see that bot is building and once done, you can start “chatting” with Lex.

AWS Lex Walk Through

Couple things to pay attention here. First, to trigger the process, only few keywords are needed. In my case, even just “coffee” would work too. Once triggered, slots appear at the bottom right, which awaits for user to input the expected answer/value. First slot is CoffeeTypes so Latte, Mocha or Expresso is expected. Case insensitive.

AWS Lex Walk Through

Completed view of both correct and error process.

AWS Lex Walk Through

AWS Certified SA, SysOps & Developer Associate, Alibaba Cloud certified SA. Focusing on Azure, Prometheus w/ Grafana, ELK and K8S now.