HowTo: Use Facebook Messenger as a channel

Official Content
This documentation is valid for:

 The purpose of this article is to explain the necessary steps to configure an environment with Facebook and then use it through the Chatbots Channels API.

Step 1 - Create a Facebook Page

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


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.


Next, select the "Send Message" button type:


In step 2, select "Facebook Messenger."

In this way, the page is configured to send and receive messages.

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


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).

Step 2 - Create a Facebook application

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


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.


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


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).


Step 3 - 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 webhook, select the "Subscribe To Events" option:


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


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.


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. See HowTo: Integrate Chatbots using Facebook Messenger.

See Also

HowTo: Integrate Chatbots using Facebook Messenger