Facebook Messenger Bot
AI Chat Box was introduced by Facebook Messenger bot in the mid of 2016, it was integrated one of the apps in messenger. This service let the user create their own custom AI Chatbox which work’s in Fb messenger application. Facebook is adding more and more services to his messenger platform service. Facebook allows Chatbot to accept payments which make them also able to use for e-commerce feature.
Building a Messenger bot is not that tough enough you just need some Coding skill what if I say you don’t need any Coding skill, now you can create your own Chatbox using ChatBox development tool. In these post, I am going to share how to build your own Facebook Messenger Bot using Api.ai, this the same company which Google acquired last year in the month of September.
Steps to build a Facebook Messenger bot
Step #1. We have to create an account on Api.ai.
Step #2. Click on Create Agent, write some description and select a language for your blog.
Step #3. Now Click on the plus side which is with the word Intent, now start adding intents to your bot, Intents are the reaction of the bot when the user says something. You have to put different reaction for different intentions. Below is the image of what intention and reactions I kept.
Step #4. After adding all the intention and reaction of your bot you can test it right now through the right-hand side of your screen.
I am only adding some intentions for showing you in this guide you can add more intent and reaction to make your bot smarter and impressive, now your Bot has been created and we have to connect it through a Facebook page.
Integrating your bot with Facebook
To connect our bot to the Facebook page we have to first create an FB app visit this link – Developers.facebook.com, click on “Add a new App” enter the App name and select the Category “ Apps for Messenger “. And then click on Create app.
Get Access token from Facebook Page
Go to Facebook Graph API Explorer in Facebook Developer account, On the top right select, the App which you create for your Bot from the drop down list of your app then click on “Get Access Token” to get your token. After getting the token open the Api.ai, select the integrations and enable the Facebook Messenger integration by click on it. Put the token which u get from the app in this field box, this will connect your Bot with the FB Page and it will allow sending the replies.
Connect the Callback URL from Api.ai on Facebook
You will be able to see the Callback URL where you pasted the token, Copy the Callback URL. Head out to Facebook and fill it under webhook settings. This will send the message i.e input of Facebook Messenger to Api.ai.
Verifying token on Facebook
This value can be set by yourself, you have to keep both the value same on Api.ai and Facebook. Fill it out in the 2nd input field in the integration tab under the Facebook Messenger integrations. Head to Facebook and fill all the values under the webhook configuration.
You can also train your bot on Api.ai after it goes public, you can review all the conversation of your bot which it replied to other people and if it was correct you can mark it as correct conversation and it will use the same reply in future. You can correct the incorrect replies to the right and then save and approve it.
Start creating your own Facebook Messenger Bot after reading this post, Api.ai supports more integration such as Twitter, Slack, and Telegram. You can create more and more complex and smarter bots easily without any programming using Api.ai do some more experiment in Api.ai and you will find many tools in it and one major important thing it is free and it is owned by Google.