Creating a Facebook Messenger Bot

There are 2 ways to connect your bot to Facebook Messenger. The easiest (and default) method is page-only. This will connect a Facebook page to Flow XO's own app. It's highly recommend you follow this route.

For more advanced users, you can set up a bot with an app and a page. This will require more set up steps, and also a manual app review from Facebook.

Set Up Page-Only (recommended)

Getting Your Page

Before you can set up your bot in Flow XO, you'll need a Facebook page. If you don't already have one, you should create one. The page profile pic and name will be used to form the 'identity' of your bot and is what people will see when they engage it.

Connecting the bot in Flow XO

When you have a Facebook page, follow these steps:

  1. In Flow XO, click Bots in the top menu bar, then choose +New.
  2. Now choose Messenger as the platform.
  3. Type in a descriptive name for the bot.
  4. If you like, you can fill out the Welcome Text box. This is optional.
  5. Click the Facebook button. This will allow us to fetch the list of pages associated with your Facebook profile, and also give us the necessary permissions to run your bot once you've selected a page.
  6. A list of Facebook pages should now show up. Choose the page that you want your bot to identify as.
  7. Finally, click Next and your bot should now be connected and working.

Messenger Specific Features

Messenger has a few powerful features that are unique. Because Flow XO supports many channels, not just Messenger, our standard flow building tools cannot take advantage of many of these features. However, if you are building Messenger specific flows you can take advantage of these from within Flow XO by using our Messenger Actions integration, which provides easy access to most Messenger bot functionality.

Set Up Using App & Page (advanced)

Getting Your App & Page

Before you can set up your app & page bot in Flow XO, you'll need a Facebook app and a page. If you don't have either of those, follow the links and set them up. The page profile pic and name will be used to form the 'identity' of your bot and is what people will see when they engage it.

Connecting the bot in Flow XO

When you have a Facebook app and page, follow these steps:

  1. In Flow XO, click Channels in the top menu bar, then choose + New.
  2. Now choose Messenger as the platform.
  3. Type in a descriptive name for the bot.
  4. If you like, you can fill out the Welcome Text box. This is optional.
  5. Tick the option to Use own app (advanced).
  6. Next you'll need your Facebook App ID & Facebook App Secret. Sign in to Facebook Developers to get these. On the left hand side menu, click Settings, then Basic, and you'll see your ID & secret:

  7. Back in Flow XO, copy and paste your Facebook App ID & Facebook App Secret into your bot settings.
  8. Now click the Facebook button. This will only fetch the list of pages associated with your Facebook profile.
  9. A list of Facebook pages should now show up. Choose the page that you want your bot to identify as.
  10. Now head back to Facebook Developers. Under Products, click the plus (+) button, find the Messenger product, and click Set Up.
  11. To get a page access token, you'll need to head over to Facebook's Graph API Explorer.
  12. On the right hand side, choose the Facebook app and Facebook page you want to connect. If you don't see the list of pages you own, you may first need to click on Get Page Access Token and follow the steps to authorize. Then select your page.
  13. Make sure that you have at least the permissions shown in the screenshot below:

  14. Copy the token that is generated into the Facebook Page Access Token field in Flow XO. You can click the info icon to make sure the token is for the correct app, page, and has the correct scopes (permissions):
  15. Finally, click Next and your bot should now be connected and working.

App Review

Note that app review is only applicable to bots set up with an app & page. If you connect your bot with the page-only option, then you won't need to go through a review process.

Currently, Facebook require that all apps go through a (free) manual review process.

Once you've set up the bot, you'll be given a link so that you can connect with your bot. Until your app is approved by Facebook, only you (as the app owner) can see it and use it.

As soon as you're happy with how your bot behaves, you should follow Facebook's app review guide to submit your app for approval.

Testing

You can test your bot either by using the shortlink, or by finding your own page and clicking the Message button.

Distributing Your Bot

Facebook currently offer these options:

  • If your app is public, you can be discovered through search in Messenger.
  • You can create a shortlink with the format http://m.me/<PAGE_USERNAME>
  • Use the Message Us plugin to add a button to your site.

You can use Flow XO's own web tools to create plugins like the Message Us plugin.

Get Started Button & Referral Links

When the user connects to the bot for the first time (they click the 'Get Started' button in Messenger), the message 'start' will be sent to the bot. You can look for the presence of this to know that the user clicked 'Get Started' and welcome the user for the first time.

If a referral parameter has been used (i.e. a link in the format http://m.me/mybot?ref=myparam) or the Send-to-Messenger Plugin, the value of ref will be sent in a data output field called Metadata along with the message 'start'.

Handling Likes

If a user 'likes' your bot, your bot will receive the message '/like'. You can create a flow to handle this as a word/phrase.

Persistent Menu

You can set up a persistent menu in the settings for your Messenger bot. This menu will be shown when the user first installs your bot, after a period of inactivity, or when the user accesses it through the menu button.

To add a menu item, edit your bot, and click Persistent Menu > Add. In the left box, type the name for the menu item (what the user sees). On the right, type the keyword that will be triggered when the user clicks that option.

You can click Add again to add more menu items. All items appear in a single layer menu. Of course, make sure you save your bot when you're finished.

Let us know how we can improve Flow XO on our feedback site.

Still need help? Contact Us Contact Us