Facebook Messenger

The Dialogflow Facebook integration allows you to easily create a Facebook Messenger bot with natural language understanding, based on the Dialogflow technology.

Setting Up Facebook

In order to set up the Facebook integration for your agent, you'll need the following:

When a user visits your page and sends you a message, they'll be talking to your agent.

Create a Facebook App

  1. Log into the Facebook Developer Console.
  2. Click on My Apps in the upper right hand corner.
  3. Click on Create App and enter a name and contact email address
  4. Click Create App ID.

  5. On the left side of the next page, click the add button and add Messenger to Products.

  6. Under the Token Generation section, click on Add or Remove pages to add a new page.

  7. Click on Generate Token to generate an access token.

This will generate a Page Access Token. Keep this token handy, as you'll need to enter it in Dialogflow.

Setting Up Dialogflow

  1. Click on the Integrations option in the left menu and switch on Facebook Messenger. In the dialog that opens, enter the following information:
    • Verify Token - This can be any string and is solely for your purposes
    • Page Access Token - Enter the token generated in the Facebook Developer Console
  2. Click the Start button.

Webhook Configuration

To configure your agent's webhook:

  1. Click the Add Callback URL button under the Webhooks section and enter the following information:
    • Callback URL - This is the URL provided on the Facebook Messenger integration page
    • Verify Token - This is the token you created
  2. Click the Verify and Save button.
  3. Click the Add Subscriptions button and check messages and messaging_postbacks under Subscription Fields, then save.

You'll be taken back to the settings page and Webhooks should have a "Complete" status.


In order to make your agent available for testing, you'll need to make your app public:

  1. Toggle the "Publish" button from OFF to ON. You are prompted to choose a category for your app.

  1. Choose Apps for Messenger from the list
  2. Click the Confirm button.

You will also need to set a username for your page. This is the username users will chat with when using your agent. To set the username, click the Create Page @Username link under your page's profile picture and title.


The following events are invoked by this integration:

Event Description
FACEBOOK_WELCOME Triggered when an end-user starts a conversation with your bot.
FACEBOOK_LOCATION Triggered when an end-user accepts or rejects a request for the end-user's location. See more info below.

The FACEBOOK_LOCATION event allows you to get a location from Facebook Messenger. Create an intent to request the location using a custom payload:

  "facebook": {
    "text": "give me your location please",
    "quick_replies": [
        "content_type": "location"

Create another intent to process the location and set the event to FACEBOOK_LOCATION. In the webhook, you'll receive the latitude and longitude from the originalRequest field:

  "originalDetectIntentRequest": {
    "source": "facebook",
    "payload": {
      "postback": {
        "data": {
          "lat": 14.556761479425,
          "long": 121.05444780425
        "payload": "FACEBOOK_LOCATION"
      "sender": {
        "id": "1588949991188331"

For more information, see Facebook Messenger's API documentation for sending location.

Hai trovato utile questa pagina? Facci sapere cosa ne pensi:

Invia feedback per...

Dialogflow Documentation
Hai bisogno di assistenza? Visita la nostra pagina di assistenza.