Step-by-Step Guide To Building Facebook Messenger Bots
Bots may be the big new trend, but that does not mean they are necessarily all that sophisticated.
Neural networks and artificial intelligence notwithstanding.
Bots, at their core, are basically interaction engines. Apps are also essentially interaction engines. The difference between the two is the primary mode of interaction: natural language and speech for bots, touch and swipe for apps.
It stands to reason then that the simple bots are not all that difficult to build. After all, the development of bots is not all that different from the backend processes of an app or website … just without all that tricky design and user experience work.
For instance, take a look at the new Facebook Messenger Platform bots. The basic tools are objects that developers will well recognize: send and receive APIs, webhooks and plugins. Tie all these items into the bot template and backend services and you have a fairly functional bot.
How To Get Started Building Facebook Messenger Platform Bots
Bots for Messenger Platform are easy enough to create that Facebook engineers were able to give a working example of simple bots in about 10 minutes during the F8 developer conference this week in San Francisco.
The general steps a developer needs to follow to start building a bot include:
- Create a Facebook app and a Facebook Page
- Setup the webhooks
- Generate the page access token
- Subscribe back to the Page and app
- Receive messages from the webhook
- Send a text message
- Send rich and/or structured data
- Handle postbacks interactions from the user
For more detail, follow specific instructions from the Facebook Developer Portal.
Essentially, the bot is operating on a fairly standard webook/postback model that has been in use for apps and websites for more than a decade. The setup of the webhook with a Facebook verified token and then tie it back to the Facebook App and Page.
If you have ever built a webhook for a Facebook App, the process for building one for a bot is no different. The same Facebook webhook subscription with a valid URL callback endpoint process with a verified token is the same from a Facebook App. Instead of an app, the webhook is being set up with the Facebook Messenger Platform bot. You can read all about the specifics in how to integrate Facebook webhooks here.