AWS Lex: Building a BOT

What are Chat Bots?

  • Chat Bot is a service that runs on rules or Artificial intelligence
  • The users interact using natural and conversational Language.
  • Chat Bots are like your personal assistants that actually assist you.
  • They can live in any chat applications like Slack, Facebook messenger, Skype etc.
  • Common example: Weather Bots – fetches forecast, current weather etc.

Top 5 tools to develop Chat Bot:

  1. Lex (Amazon Web Services)
  2. (Google)
  3. Azure Bot Service (Microsoft)
  4. (Facebook)
  5. Watson (IBM)

Building a Chat Bot using Amazon Web Services:

What is AWS Lex?

Lex is AWS service for building conversational interfaces for any applications using voice and text.

Lex enables you to build sophisticated, natural language Chat Bots into your new and existing applications. Lex can serve a variety of use cases, customer support, transaction fulfillment, data retrieval, or even DevOps functions (ChatOps).

AWS Lambda : Lex is integrated with AWS Lambda, a service that lets you run code without provisioning or managing servers. Lambda can be used as a Code Hook and also can be used to connect with other AWS services like SES, SNS, S3.

Simple Architecture:

Prerequisites of Building a chat bot on AWS platform:

  • AWS account
  • Knowledge of any one of the languages (Node JS, Python, Java)
  • Basic knowledge of Artificial Intelligence

Simple Chat Bot – Chat Bot to get details of any State in India

Step 1: Go to Lex in AWS management console and click on Create 

Step 2: Choose the “Custom Bot” and fill details like Bot name, Language, Output Voice.

Step 3: Customize your Bot using Lex Console

Lex Console has following things by which a Chat Bot can be built:

  1. Adding Utterances: Requests from users is called utterances. Example: I want to Order some flowers or Get my state details.
  2. Create an Intent: An action that the user wants to perform, with the minimum information needed. Intent Name should be Unique. Example: OrderFlowers or GetMyStateDetails
  3. Create Slot Types: Slot Types are basically parameter values which are used in the Intent. Lex provides both Custom and Built In slot types. Example: AMAZON.DATE for Date format, or custom slot for CAR TYPES with Enumerations
  4. Confirmation Prompt: It confirms with a final prompt whether the user want to proceed with the action or not. It accepts ‘Yes‘ or ‘NO‘ as input from User. Terminates the fulfillment if user replies ‘No’.
  5. Fulfillment: Fulfillment can be done in two ways: Either invoke a Lambda function or return the parameters back.

Invoking the lambda function: Firstly we have to Create a Lambda function in Node JS. In this case we will invoke a Lambda function which takes user input and sends it to a REST API in Lambda function and returns the data back to Lex.

Lambda function for our Example here:

Build and test your Bot:

Here it is, your Bot is Ready!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s