2021 Offer : Pay for 1 & Get 3 Months of Unlimited Class Access

- AWS Blogs -

How to Create Amazon Chatbot & Integrate with Facebook?

Over time we have been trying to develop and innovate technologies that made our life easier. With numerous applications around us to solve this purpose, Chatbots are emerging to be an important part of our lives. One of the solutions around is Amazon Lex which is a powerful platform for building Chatbots.

And as rightly said: “Chatbots Will Be Your New Best Friend” ... Forbes

What is Amazon Lex?

Amazon Lex is an AWS service that helps in building an interface where applications use text and voice. Alexa from Amazon also uses Amazon Lex as a backend engine. It is used to create, natural language chatbots for the applications. Amazon Lex uses the power of natural language understanding (NLU) and automatic speech recognition (ASR) to create an interactive user experience that looks lifelike.

What is a Chatbot?

“A chatbot is a computer program that connects with the user in a natural language using audio or text mode. It understands what the user says and respond based on a series of rules”.

Features of a Bot:

A). Intent

Intent means a task end-user wants to achieve. Bot can support multiple intents, like flight booking, taxi booking, check price or gold or even start-stop an ec2 instance.

For each intent, you provide the following required information:

  • Intent name– Name for the intent. For example, startec2instance
  • Sample utterances – how the user can ask the bot to achieve the task, like stop an ec2 instance.
  • How to fulfill the intent – It means how can the task asked by the user be achieved, for example to start-stop an ec2 instance, we can create a lambda function which can be called to perform these actions on an ec2 machine.

B). Slot

Intent can have zero or more slots. You can add slots while configuring an intent configuration. When a bot is called Amazon Lex asks the user for the defined slot values. Amazon Lex asks the user all the slot values before fulfilling the tasks asked by the end-user. 

For example, the startec2instance or stopec2instance intent will need slots such as instance name, instance-id, zone-name, etc. In the intent configuration, we can add slots. For each slot, we ask for a slot type and a message for Amazon Lex to ask to the user. Users can answer with a slot value that may have some extra words like “start the ec2 instance with instance id XXX please” or “can we stop and instance by name XXX”. Amazon Lex can still perform the tasks.

C). Slot type

Slots have a type. We can create our custom slot types or use built-in slot types. For example, we can have the following slot types for startec2instance intent:

  • Instancename – What is the instance name?
  • Instanceid – What is the instance id?
  • Region – In which region is the instance?

Features of a Chatbot

  • Conversational Skills - Chatbot has natural language processing (NLP) capabilities to understand and respond in many languages.
  • Integrates with many digital channels – Facebook, Kik, Twilio, Slack and other messaging platforms.

AWS Curriculum

ChatBot Use case scenarios 

ChatBot are used to give the users a friendly, interactive graphical user interface to chat and express their interest and needs, and expect the bot to behave as real human and response in the same manner. Chatbot interacts with the user as a real human, understanding the user’s needs and responding similarly.

Some fields where Chatbots are already a success:

  1. Customer Service – answer a large volume of calls asking for the product details or delivery status.
  2. Marketing – ask for user’s expectations and prompt them with the right product that satisfies their needs.
  3. HR – keeping track of employee’s satisfaction by asking them for surveys from time to time.
  4. IT – solution to common issues can be provided using Chatbots to the issue raised in It ticketing tool
  5. Travel – use to book tickets for customers based on their inputs like travel dates, destination and flight options.
  6. Finance – money transfer based on the security inputs that can be asked by the Bank as per the predefined slots in the Chatbots.

1). Demo: Using Amazon Lex for creating a Chatbot 

Now let’s come to the most exciting part of the tutorial … J creating a real Amazon Lex Chatbot.

Read: Top 70 AWS Interview Questions and Answers

Exciting. isn’t it.

Steps to be followed:

  • Create a free tier AWS account if you don’t have one yet.
  • Login to AWS account and go to Amazon Lex

Amazon Lex service dashboard

  • Press the Create button.

Amazon Chatbot and  Integrate with Facebook

  • Select “Custom Bot” Option.
    • Provide a Bot Name.
    • Session Timeout.
    • IAM role is automatically selected.
    • For COPPA, select the “NO” button. Read the link for more information.
  • Click on the ‘+’ button to Create an Intent.

Amazon Chatbot and  Integrate with Facebook oneGive a meaningful content name. In my case, I gave “WhatisurName”

steps to create Amazon Chatbot and  Integrate with Facebook

  • Enter Sample Utterances, that you expect your user to ask to your bot.

  • In Slots, choose the responses based on the inputs expected from the user.

Like in the case here, we expect the user to Hi, Hey or Hello as above. The Bot will reply to the user with his Name and this seems to be a more human-like response. We will test this in a minute … 

Other things the bot will ask for is the place the user lives and his / her date of birth.

Steps to create Amazon Chatbot and  Integrate with Facebook

  • Press the “Save intent “ button to confirm your changes.

save intent

  • Press the “Built” button to build the bot.

Steps Amazon Chatbot and  Integrate with Facebook

Read: EC2 in AWS - The Backbone of AWS

 Once the Built is complete you can test your Bot by using “Test Bot” option on right.

Amazon Chatbot and  Integrate with Facebook steps

  • Once testing is complete press the Publish button to publish your changes.

Amazon Chatbot and  Integrate with Facebook StepsOnce Published you will get the following pop-up

Amazon Chatbot and  Integrate with Facebook Steps

Hooray, your first Amazon Lex ChatBot created successfully.

Now it’s time to test it in the outer world.

2). Demo: Integrating Amazon Lex Chatbot with Facebook.

So, guys as your first Amazon Lex Chatbot is ready, it’s time to expose it to the outer world. Let’s learn how to interact with websites like Facebook as it is the largest used website for personal social circle as well as running Business campaigns and promotions.

For this you need a Facebook account. J .. I am sure you have one. 

Steps to be followed.

Amazon Chatbot and  Integrate with Facebook steps 11

create new app id facebook

  • Now go to Settings > Basic option on left. Here you will find the App Secret, Take a note of it.

Amazon Chatbot and  Integrate with Facebook steps 15

Read: How to Become an AWS Certified Solution Architect?
  • Go to Products and choose Messenger, click settings.
  • In section “Access Tokens”, Add the page you just created, in my case it is “TestBot”.
  • Click “Generate Token” a pop-up will appear with your page token. Copy the token

token generated Amazon Chatbot and  Integrate with Facebook

  • Got back to Amazon Lex, Channels. Enter the following values:
    • Channel Name
    • Channel Description
    • IAM Role – predefined
    • KMS Key – aws/lex
    • Alias – Name that we enter when we published the bot.
    • Verify Token – APP name
    • Page Access Token – Page Access Token, obtained in step 9.
    • App Secret Key – Obtained in step 6.
    • Click Activate, and you will get the Call Back URL, copy it.

Amazon Chatbot and  Integrate with Facebook

  • Go to the Facebook Developer APP ID page.
    • Select Webhook.
    • Click on “Add Callback URL
    • Enter the Callback URL, obtained in Step 10 and App Id Name in Verify Token and click “Verify and Save”

edit call back url Amazon Chatbot and  Integrate with Facebook

Done. Facebook is Integrated with your Amazon Lex Chatbot.

3). Demo: Facebook-Chatbot testing.

  • Go to the Facebook page you created.
  • Click on “Add Button”
  • Choose the following options.
  • Click on “Send Message” >> “Test Button”

Chat window just like Facebook messenger will appear.

Amazon Chatbot and  Integrate with Facebook

Now ask the same utterances as the user may ask.



Well, so today we learned, what is the power of Amazon Lex, what are Chatbots and how they are very useful for the present day Business and how it is needed to reach your customers in a friendly and interactive way.

How they can bring more customer traffic to your business, by replying maximum user queries. How it can save a lot of Operation cost as human tele callers can be replaced by automated Chatbots. Amazon Lex developers are also in Demand as per LinkedIn.

Hope you find this tutorial helpful and knowledgeable, happy learning.

Read: AWS vs. OpenStack vs. SoftLayer - Which One is the Best?

    Ish Kumar

    A DevOps Engineer by profession and a Technical Blogger by passion. I love to learn anything about DevOps and Cloud computing and at the same time share the knowledge among those who are willing to learn and share the same passion with me.


Trending Courses


  • AWS & Fundamentals of Linux
  • Amazon Simple Storage Service
  • Elastic Compute Cloud
  • Databases Overview & Amazon Route 53

Upcoming Class

14 days 19 Mar 2021


  • Intro to DevOps
  • GIT and Maven
  • Jenkins & Ansible
  • Docker and Cloud Computing

Upcoming Class

1 day 06 Mar 2021

Data Science

  • Data Science Introduction
  • Hadoop and Spark Overview
  • Python & Intro to R Programming
  • Machine Learning

Upcoming Class

0 day 05 Mar 2021


  • Architecture, HDFS & MapReduce
  • Unix Shell & Apache Pig Installation
  • HIVE Installation & User-Defined Functions
  • SQOOP & Hbase Installation

Upcoming Class

0 day 05 Mar 2021


  • Salesforce Configuration Introduction
  • Security & Automation Process
  • Sales & Service Cloud
  • Apex Programming, SOQL & SOSL

Upcoming Class

1 day 06 Mar 2021


  • Introduction and Software Testing
  • Software Test Life Cycle
  • Automation Testing and API Testing
  • Selenium framework development using Testing

Upcoming Class

0 day 05 Mar 2021

Business Analyst

  • BA & Stakeholders Overview
  • BPMN, Requirement Elicitation
  • BA Tools & Design Documents
  • Enterprise Analysis, Agile & Scrum

Upcoming Class

0 day 05 Mar 2021

MS SQL Server

  • Introduction & Database Query
  • Programming, Indexes & System Functions
  • SSIS Package Development Procedures
  • SSRS Report Design

Upcoming Class

0 day 05 Mar 2021


  • Features of Python
  • Python Editors and IDEs
  • Data types and Variables
  • Python File Operation

Upcoming Class

0 day 05 Mar 2021

Artificial Intelligence

  • Components of AI
  • Categories of Machine Learning
  • Recurrent Neural Networks
  • Recurrent Neural Networks

Upcoming Class

14 days 19 Mar 2021

Machine Learning

  • Introduction to Machine Learning & Python
  • Machine Learning: Supervised Learning
  • Machine Learning: Unsupervised Learning

Upcoming Class

7 days 12 Mar 2021


  • Introduction to Tableau Desktop
  • Data Transformation Methods
  • Configuring tableau server
  • Integration with R & Hadoop

Upcoming Class

8 days 13 Mar 2021

Search Posts


Receive Latest Materials and Offers on AWS Course