Facebook Messenger Integration Overview
This Help Article Appears in the Following Learning Tracks
Set up the Facebook Messenger integration
Create a new app in Facebook for Developers
- Go to Facebook for Developers and create a new app. You can find the option Create App under the My Apps menu.
- Give your new app a name, enter your email address, and select an appropriate category (like Apps for Pages or Apps for Messenger).
- From the products section, select Messenger from the left menu. If it is not there you can add it in.
- In the Messenger panel, scroll down to find Token Generation. Select the page you want to link to the bot to. This will generate a Page Access Token that you can use in Bridge to register the extension.
Find the integration in Bridge
- Navigate to the Integrations page in Bridge.
- Click on the Messenger image to begin setup.
- In the window that appears, click Continue.
- In the Settings tab, enter the Page Access Token from Facebook into the Messenger Access Token field.
- Select Save.
This will generate the Web Hook URL that you will use in Facebook if the access token is validated successfully.
Verify settings in Facebook
In Facebook, under Token Generation, find Webhooks.
- Select Setup Webhooks.
- Copy the Web Hook URL generated from Bridge to the New Page Subscription form.
- Copy the Messenger Access Token to Verify Token.
- Under Subscription Fields, select message and messaging_postbacks. You can also select messaging_referrals for additional functionality with the M.ME Messenger Links.
- Verify and save these settings.
Under Webhooks, you can now select a page to subscribe to these page events. To do so, select a page from the drop down menu and click Subscribe.
Additional setup steps
The Messenger settings contain read-only parameters for the get started button, greeting text, and persistent menu which will display any existing information that has been set before the update to Messenger version 1.4.
M.ME Messenger links
A feature available to Messenger is a trackable short link using M.ME.
A link in the format
will take the user to Messenger for the given page name. You can expand on this by having Bridge react when the user opens Messenger using this link
The ref_value can either be a workflow name or a URL encoded JSON object that defines the workflow name and state values.
When the user follows the link for the first time, they are shown the Get Started Button and the interaction behaves as it would be if they started talking without the M.ME link. If they are returning using the link after previously talking to your bot, they will not see if the Get Started Button. Instead, they will be informed that by following the link you have been notified they have opened Messenger and the ref_value is sent to Bridge to trigger the conversation with the user.
For example, if the user followed this link https://m.me/bridgebot?ref=returned, it would start a new conversation with the user using the workflow returned which could be something simple, like say Welcome back, or do something more complex, like adding keys to the user to show they were referred from a particular link.
For more complex referrals, and to expand the Get Started Button functionality further, you can use the URL encoded JSON object as the ref_value:
Therefore, when URL encoded our link would look something like this:
This would start the workflow called workflow_name and set the value for the state state_name as state_value so whatever question state_name asked would be skipped as the response state_value has already been supplied.
You can also use this object to expand the Get Started Button when a user first talks to your bot through the M.ME link. The entities section of the object will be used to complete the named states if the Get Started Button trigger message is the workflow name, allowing for different behaviour if the user uses the M.ME link to talk to your bot for the first time or finds you some other way. This would allow you to have a simple conversation that can track where users have found your bot from by having different state values set by the link.
For referrals to be passed onto Bridge you will need to have added the webhook permission messaging_referrals when setting up your Bridge webhook. You can update this at any time without having to create a new webhook.