Building a Facebook Messenger Bot Within a Week
Rapid bot development using Chatfuel, API.ai, and Heroku.
I have recently launched my first messenger bot — Product Huntian. It was built using Chatfuel, API.AI, and Heroku in less than 10 days. Many Developers in the bot community have asked about integration of chatfuel with API.AI . This post will help you on the selection of tools for your bot development as well integration of different platform to get best out of them.
To develop my bot as a novice, I started to explore various bot development platforms and decided to go with API.AI. The main reasons that attracted me to use API.AI were :-
- Powerful AI & context understanding
- Easy expand on multiple platforms
- Well documented detailed examples & demo for almost everything.
- Easy webhook integration (as I am using the third party APIs. )
The problem with API.AI is that it is a trigger system. It only sends response when a user asks something. To add other features (as mentioned below) you need to write code for it.
- Welcome Message
- User profile details
- Persistent Menu
Going through all discussion on API.AI and then trying the solution suggested by others were timing consuming. To overcome all these hurdles, I started to explore Chatfuel. Chatfuel has all of these in-built functionalities in addition to broadcast and analytics features.
I decided to connect chatfuel with API.AI . Chatfuel has JSON API plugin that helps to send data to server and response back to the user. API.AI also has query request and response with JSON structure. The major problem is a JSON structure of the response sent by API.AI is different from than JSON structured accepted by Chatfuel.
Below is the sample example of a comparison of structures for Send a Gallery to the messenger.
- Chatfuel
To solve this problem, I have written simple code in Python that converts response sends by API.AI into responses accepts by chatfuel and deployed on Heroku. The Python code is written using the Flask framework that makes it easy to maintain. The Flask tutorials were really helpful to quickly learn the flask framework.
Now, when a user says something in Facebook Messenger, the flow will be as follow-
Finally, I launched my bot on Product Hunt. After one week of the launch -
- Featured on Product Hunt
- 92 upvotes on Product Hunt
- 190+ unique users
- 200+ views BotList
- 16th on Chatbottle
Building a chatbot is not as complex as you think. The major part is a simplification of user interaction cases. Once you have figured out them, just use the tools to build the bot.
This is my first medium post. I would love to hear your feedback. Feel free to try the bot — Product Huntian on Facebook and comment your thoughts on Product Hunt.
If you are developing bots Bot Stash and Bot Tutorials will be helpful resources. If need any help or want to discuss ideas contact me on @keyul .
Links:-
- Connecting with API.AI
- ChatFuel Json Plugin
- API.AI Queries
- API.AI Webhook response format
UPDATE:
https://chatbotsmagazine.com/how-solving-my-own-problem-went-viral-a2cd54302ec6