Messenger from Meta

Using the Meta Messenger Integration, you can create a Meta Messenger bot to interact with your users.

How it works

This is how the integration works:

Setup

Make sure billing is enabled on your project before testing the integration.

To set up the integration:

  1. Follow the steps to create a Meta app: Meta App Development.
  2. Set up the Meta app to use the Meta Messenger Platform. Follow the steps in the Meta Webhooks for Messenger Platform documentation to accomplish the following:
    • Add the Messenger Platform to your Meta app.
    • Subscribe your app to a Meta page. Make sure messages and messaging_postbacks are enabled in the page subscription.
    • Copy the access token provided at this step. This token is used to configure the integration from the Dialogflow CX console.
    • Don't configure the webhook or test your integration yet.
  3. Configure the integration from the Dialogflow CX console:
    1. Go to the Dialogflow CX console.
    2. Select the Manage tab on the navigation menu.
    3. Select Integrations.
    4. Click the Connect button on the Meta Messenger tile.
    5. Complete the configuration dialog fields:
      • App secret: Enter the app secret from App Dashboard Basic Settings.
      • Verify token: Enter any private token you need. Copy this value. This is used to configure the Meta Messenger Webhook.
      • Page access token: Enter the access token you copied during the Meta app setup.
      • Enable get started button: Select this checkbox to enable the Get started button.
      • Webhook URL: Copy this value. This is used to configure the Meta Messenger Webhook.
      • Start: Select this checkbox to start the integration service for your agent.
  4. Finish setup of the Meta app and test it. Follow the steps in the Meta Webhooks for Messenger Platform documentation to accomplish the following:
    • Configure the Meta webhook for your app. Use the Webhook URL and Verify token values you copied earlier. Be sure to enable messages and messaging_postbacks in the page subscription.
    • Test your app.

Events

The following events are invoked by this integration. You can create custom event handlers to define what to do when the events are triggered.

Event Description
FACEBOOK_WELCOME Triggered when an end-user clicks the Meta Messenger Get Started Button.
FACEBOOK_MEDIA Triggered when the message from an end-user contains attachments (for example, audio, image, or video).

Get started button

Set up the Meta Messenger get started button:

  1. Toggle Enable Get Started Button when enabling this integration service.

    • This integration service lets you enable the button by calling the Messenger Profile API.

      curl -X POST \
      -H "Content-Type: application/json" \
      -d '{"get_started": {"payload": "FACEBOOK_WELCOME"}}' \
      "https://graph.facebook.com/v10.0/me/messenger_profile?access_token=${PAGE_ACCESS_TOKEN}"
      
  2. Create a custom event handler for the FACEBOOK_WELCOME event.

To test it:

  1. Delete the previous conversation with your Meta page if applicable.
    • The Get Started button only shows up on new conversations.
  2. Start a new conversation with your Meta page.
  3. Click the Get Started button, and verify the response from the custom event handler.

You can call Messenger Profile API to manage the Get Started button. This can help with testing.

To check the status of the Get Started button, use the following request:

curl -X GET \
"https://graph.facebook.com/v10.0/me/messenger_profile?fields=get_started&access_token=${PAGE_ACCESS_TOKEN}"

You can use the following request to disable the Get Started button:

curl -X DELETE \
-H "Content-Type: application/json" \
-d '{"fields": ["get_started"]}' \
"https://graph.facebook.com/v10.0/me/messenger_profile?access_token=${PAGE_ACCESS_TOKEN}"

Rich response messages

Rich response messages are supported using Custom Payload in Fulfillment. For more information, see the Send API Parameters Message Object documentation for the message format.

For example, the following custom payload provides a text message:

{
  "text": "Hello, world"
}

The following custom payload provides an image message:

{
  "attachment": {
    "type": "image",
    "payload": {
      "url": "https://example.com/test.jpg"
    }
  }
}

Channel-specific responses

After you configure the channel-specific responses, the agent automatically uses the DF_CX_FB_MESSENGER channel to respond to Meta Messenger messages.