Facebook Messenger Integration Overview

Applies to

Bridge by Smartsheet

Set up the Facebook Messenger integration

Create a new app in Facebook for Developers 

  1. Go to Facebook for Developers and create a new app. You can find the option Create App under the My Apps menu.Create App in Facebook
  2. Give your new app a name, enter your email address, and select an appropriate category (like Apps for Pages or Apps for Messenger).
  3. From the products section, select Messenger from the left menu. If it is not there you can add it in.
  4. 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.

Facebook Messenger Token Generation

Find the integration in Bridge

  1. Navigate to the Integrations page in Bridge. 
  2. Click on the Messenger image to begin setup.
  3. In the window that appears, click Continue.
  4. In the Settings tab, enter the Page Access Token from Facebook into the Messenger Access Token field. 
  5. Select Save.

This will generate the Web Hook URL that you will use in Facebook if the access token is validated successfully.

Messenger Integration in Bridge

Verify settings in Facebook

In Facebook, under Token Generation, find Webhooks.

Messenger Integration Webhook

  1. Select Setup Webhooks.
  2. Copy the Web Hook URL generated from Bridge to the New Page Subscription form.
  3. Copy the Messenger Access Token to Verify Token
  4. Under Subscription Fields, select message and messaging_postbacks. You can also select messaging_referrals for additional functionality with the M.ME Messenger Links.
  5. Verify and save these settings. 

Messenger Integration verify and save 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

HTML

https://m.me/{{page_name}}

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

HTML

https://m.me/{{page_name}}?ref={{ref_value}}

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:

JSON

{

  "intent":"workflow_name",

  "entities":{

    "state_name":"state_value"

  }

}

Therefore, when URL encoded our link would look something like this:

HTTP

https://m.me/{{page_name}}?ref=%7B%22intent%22%3A%22workflow_name%22%2C%22entities%22%3A%7B%22state_name%22%3A%22state_value%22%7D%7D

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.