Facebook Messenger configuration

Official Content
This documentation is valid for:

Here you will find instructions to configure an environment with Facebook and then use it through the Chatbots Channels API.

Create a Facebook Page

To create a page on Facebook, go through this link.

image_2019429143936_1_png

Continue the configuration process, where you are asked for a profile picture and other information. After the page is created, select the "Add Button" button.

image_2019429144140_1_png

Next, select the "Send Message" button type:

image_2019429144212_11_png

In step 2, select "Facebook Messenger."

In this way, you configure the page to send and receive messages.

Finally, to test the button, select "Send Message" so that a drop-down menu with the "Test Button" option is displayed. Clicking on it opens the chat.

image_2019429144414_1_png

So far, you have configured the page to be able to receive messages through it.

At development time, not publishing the page is recommended (by default it appears published).

Create a Facebook application

To create a Facebook APP, click on this link. There, you have an option to create your app.

image_2019827142841_1_png

It will open a dialog in which you will be asked for a Display Name and Contact Email.

From the App Dashboard, select "PRODUCTS" and click on the "SET UP" button in the Messenger option.

image_2019429145227_1_png

 

Under Products > Settings is the "Access Tokens" section. There, click on the "Edit Permissions" button.

image_2019827143539_1_png

In the window that is opened, select the page you've just created (step 1).
This action will generate a Page Access Token (which is going to be used later).

image_201982714492_1_png

Webhook configuration

For Facebook to be able to send messages and events, you need a service as "Webhook" which receives the requests. According to Facebook's documentation, the Messenger Platform sends events to your webhook to notify your bot when a variety of interactions or events happen, including when a person sends a message. Webhook events are sent by the Messenger Platform as POST requests to your webhook.

You have to program your own webhook, with some considerations.

To configure the Webhook, you need to expose that service, which has to run under HTTPS. To configure the webhhok, select the "Subscribe To Events" option:

image_2019429152847_1_png

In the Events box, it is enough to select: messages, messaging_postbacks, messaging_options, message_deliveries, message_reads.

image_2019827153916_1_png

In CallbackURL, enter the URL where you exposed the Webhook service. In Verify Token, you have to add any token which will be used later.

image_201982715488_1_png

When an event that calls the Webhook is triggered, you can easily obtain the user ID of the user interacting with your page from the Webhook.

Summary

To use Facebook Messenger as a channel, the following is required:

  • Create a Facebook page
  • Create an application on Facebook
  • Set up Facebook Messenger in the application
    • Relate the page to the application
    • Get the page access token
    • Raise a webhook service (public and https)
    • Set up the webhook on Facebook, subscribing to the necessary events.

Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.