Table of contents


Official Content

 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.

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

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

Step 2 - 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

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:

image_2019429152847_1_png

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

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

See Also

HowTo: Integrate Chatbots using Facebook Messenger

Last update: November 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant