This document briefs you on how to connect Orbita to the Facebook messenger bot.
Table of Contents | ||
---|---|---|
|
Setting up Facebook
In order to set up the Facebook integration for your agent, you'll need the following:
a Facebook page to add your chatbot
When a user visits your page and sends a message, they'll be talking to your chatbot.
Create a Facebook App
Log in to the Facebook Developer Console.
Click on My Apps in the upper right-hand corner.
Click on Create App
Select Manage Business Integrations and click Continue.
Add a display name and click on Create App.
Making the App Public
Go to the App page and click on Settings > Basics.
Fill in the necessary details and click on Save Changes.
Toggle the status to ON. Click on Confirm in the pop-up dialog box.
Adding messenger to your App
Click on Products from the side menu, select Messenger, and click on the Set Up button.
In the Products > Messenger > Settings page, click on “Add or Remove Pages” to add your Facebook page to the App.
Access Tokens
...
In the Access tokens section of the settings page, click on the Generate token against the page you added.
...
The access token should be kept safe for later use.
Webhooks
...
In the Webhooks section, click on Add Callback URL.
...
Click on the “Add Subscriptions” button and check the messages and messaging_postbacks options. Click on Save.
...
The Webhooks should have a "Complete" status with a green tick as shown in the screenshot below.
...
App icon
Valid privacy policy url
Business use
App category
Make the app public
Please ensure to toggle on the Live status to make the app public.
...
For Business users, you need to do Business Verification to make the app public.
Click on the Get started and submit the verification to Facebook.
...
Setting up the Experience Designer
Connect two function nodes before and after Bot provider V2 node. One for getting the input from Facebook and the other to Process the output sent to Facebook.
Design a flow as shown below.
...
For Facebook to verify our callback URL
Add “http in” node with URL as bot/messenger dockflow and the Method: GET
Add a function node (named Verification node in the sample flow screenshot) with the following code.
Code Block msg.payload = msg.payload['hub.challenge'];
return msg;
Add the “http out” node to the flow.
For connecting the chatbot
Add “http in” node with URL as bot/dockflow and the Method: POST
...
FB input
Place the below code in this function node.
...
Place the below code in this function node. Replace the in the code with Facebook’s Place the Facebook page Access token you copied generated when the page is connected to the Facebook App., in the code (denoted by XXXXXX)
Code Block |
---|
var stripTags = msg.payload.orbitaPayload.payload.multiagent.chat.chatText.replace(/<[^>]+>/g, '') msg.payload= { "messaging_type": "RESPONSE", "recipient": { "id": msg.orginalPayload.fbSenderId }, "message": { "text":stripTags } } msg.url = "https://graph.facebook.com/v4.0/me/messages?access_token=XXXXXX" msg.method = 'POST'; msg.headers = {}; msg.headers['Content-Type'] = 'application/json'; return msg; |
http request
Configure this the HTTP request node as shown in the below screenshot before connecting it to “http out” node.
...
Sample flow
...
View file | ||
---|---|---|
|
Setting up Facebook
In order to set up the Facebook integration for your agent, you'll need the following:
a Facebook page to add your chatbot
When a user visits your page and sends a message, they'll be talking to your chatbot.
Create a Facebook App
Log in to the Facebook Developer Console.
Click on My Apps in the upper right-hand corner.
Click on Create App
Select Manage Business Integrations and click Continue.
Add a display name and click on Create App.
Making the App Public
Go to the App page and click on Settings > Basics.
Fill in the necessary details and click on Save Changes.
Toggle the status to ON. Click on Confirm in the pop-up dialog box.
Adding messenger to your App
Click on Products from the side menu, select Messenger, and click on the Set Up button.
In the Products > Messenger > Settings page, click on “Add or Remove Pages” to add your Facebook page to the App.
Access Tokens
In the Access tokens section of the settings page, click on the Generate token against the page you added.
Check the I Understand checkbox, click on Copy,and select Done.
The access token should be kept safe for later use.
Webhooks
In the Webhooks section, click on Add Callback URL.
Copy your web chatbot URL and paste it here.
For example,https://<yourdomain>.orbita.cloud:8443/oeapi/bot/dockflowClick on Verify and save.
The Facebook will post a request to the callback URL and the Verify Token will be auto populated and saved in the Facebook app.Click on the “Add Subscriptions” button and check the messages and messaging_postbacks options. Click on Save.
The Webhooks should have a "Complete" status with a green tick as shown in the screenshot below.
Ensure you have the following checked.
App icon
Valid privacy policy url
App purpose / Business use
App category
Make the app public
Please ensure to toggle on the Live status to make the app public.
...
For Business users, you need to do Business Verification to make the app public.
Click on the Get started and submit the verification to Facebook.
...
Related articles
Filter by label (Content by label) | ||||||||
---|---|---|---|---|---|---|---|---|
|