Make Chatbot easily in Facebook Messenger by FPT.AI


Chatbot – The new trend for enterprise

A Chatbot is a service, powered by rules and sometimes artificial intelligence, that you interact with via a chat interface. Today, Chatbots are part of virtual assistants such as Google Assistant, and are accessed via many organizations’ apps, websites, and on instant messaging platforms such as Facebook Messenger. Non-assistant applications include Chatbots used for entertainment purposes, for research, and social bots which promote a particular product, candidate, or issue.

As Josh Elman, Partner of Greylock said: “Many businesses already have phone trees and they do work though most users get grumpy using them. Text based response trees are much easier and faster and that is what I expect a lot of early bot interactions to be. Sometimes with ability to chat with a live person.”

FPT.AI – The platform to make Chatbot easy  

Follow to this trend, FPT has built up FPT.AI – conversational platform for developers in particular and enterprises in general can create applications easily such as Chatbot. Developers can easily develop a simple Chatbot when they do not know anything or can build dialog, conversations, scenario, etc. for advanced Chatbot by this platform. This article will let you know how to create a Chatbot in Facebook Messenger using FPT.AI. Here is detailed instructions:

Step 1: Create Facebook Page

Firstly, you need create Facebook page, after that you can log in and create Bot..

Step 2: Create Facebook application

After logging in, access website:, choose Add a New App to create new application.

  • Click Add product and choose Messenger
  • Access menu Messenger > Settings, in Token Generation choose page that you want to use. Facebook can make token chain. You need to save this to use for Bot.

Step 3: Training Bot on FPT.AI

After having Bot, the next step is register account in website, log in and create new application with the following instruction:

  • Create new intents, each intent fits with each question that give by user for Bot.

For example: developer create intent: why_today_is_hot = “Why today is hot?”.

  • Add more samples for each intent – the other way of the same question. For instant, with intent why_today_is_hot, there are some other ways such as: Why today is so hot? How come today is hot? Why is hot today?…
  • After create intent, click Train to train Bot based on input data.
  • Copy Application token of application in order to use in Code of Bot.

Step 4: Develop Bot

 You can refer to a complete Bot at, using Go language, Code of Bot is explained below:

File answers.json contains the answer data response with each intent as a JSON. You can use MySQL to store if you want.

Open file main.go to replace FPTAI_TOKEN and FB_PAGE_ACCESS_TOKEN by token that you saved before. Change FB_VERIFY_TOKEN by any concepts you want. You just need to inform about this string to Facebook in the next step:

  • Program uses Facebook Bot Framework and FPT SDK for Go.
  • The concept of code includes:
    • Download the answers of question from file json (function Load)
    • Receive question from Facebook (function HandleMessage), 
    • Change question to FPT.AI to detect intent (function RecognizeIntents)
    • Find answer for intent (function Answer)
    • Send answer to user (function SendText)

Compile run program, it will listen at port 1203 to keep the program running. Finally, you need to download the Ngrok software tunnel at to be able to connect and access to Bot from the Internet. At screen Ngrok, copy the “https” address that came out, in the form This is the address you need to inform Facebook.

Step 5: Configure Facebook application

 To do this step, you need to go back to the application in Facebook page, click on Messenger > Settings.

  • In Webhook, click Setup webhook 
  • In the new window open select all cells
  • Enter the address given in the previous step to the Callback URL, add more extention: For instant:
  • Enter the token verification you filled in the code in the previous step in the Token Verification box
  • Click Confirm and Save
  • If true, Bot window will display a Verified message

It’s easy to create Chatbot for yourself by FPT.AI. For now, you can go to Facebook Page and chat to Bot with trained questions, Bot can respond automatically and immediately. Do not forget to set additional different kind of messages for Bot to be able to automatically reply in all cases.

About FPT.AI 

FPT.AI ( ) is a platform for building conversational interfaces. This platform provides the advanced machine learning functionalities such as automatic speech recognition (ASR), text to speech (TTS), and natural language processing/understanding (NLP/ NLU) that enable your systems to interact with users using natural languages via voice or text.

FPT has developed some Chatbots based on FPT.AI such as: Virtual assistant supports applications of Healthcare, a big customer in America; Virtual assistant automatically supports customers through 2 channels: email and chat for a telecommunication agency in Singapore; Virtual customer care staff of FPT Telecom answers and supports customers; Virtual sale staff of FPT Shop helps customers find product information, sends notification of discount programs and supports to buy products promptly; FQC – a virtual assistant of FPT Software’s Quality Assurance, which answers more than 700 frequently asked questions of PM, QA, staff…; MyFSoft – another Vietnamese virtual assistant, is running on iOS and Android mobile devices for FPT Software’s employees, supports to answer 104 situations, frequent considerations of FPT Software’s employees.

Nguyen Dang Minh – FPT HO 


Please enter your comment!
Please enter your name here