Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

This document briefs you on how to connect Orbita to the FaceBook messenger bot.

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 a message, they'll be talking to your chatbot.

Create a Facebook App

  1. Log in to the Facebook Developer Console.

  2. Click on My Apps in the upper right-hand corner.

  3. Click on Create App

  4. Select Manage Business Integrations and click Continue.

  5. Add a display name and click on Create App.

Making the App Public

  1. Go to the App page and click on Settings > Basics.

  2. Fill in the necessary details and click on Save Changes.

  3. Toggle the status to ON. Click on Confirm in the pop-up dialog box.

Adding messenger to your App

  1. Click on Products from the side menu and Click on Set Up button from Messenger.

  2. Click on “Add or Remove Pages” to add your page to the App.

  3. Connect the Generate Page Access Token.

For Facebook to verify our callback URL

  1. Add “http in” node with URL as bot/messenger and the Method: GET

  2. Add a function node (Verification node in the sample flow screenshot) with the following code
    msg.payload = msg.payload['hub.challenge'];
    return msg;

  3. Add “http out” node.

Facebook Webhook Configuration

  1. Click the Settings from the side menu. In Webhooks section, click on Add Callback URL. Copy your web chatbot URL and paste it here.
    For example, https://aurora.orbita.cloud:8443/oeapi/bot/messenger

  2. Click on “Add Subscriptions” button and check the messages and messaging_postbacks options. Click on Save.

  3. The Webhooks should have a "Complete" status as shown in the screenshot below.

Build a flow in Orbita 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.

FB input

Place the below code in this function node.

if(msg.payload.entry[0].messaging[0].message)

msg.payload.text = msg.payload.entry[0].messaging[0].message.text

else

msg.payload.text="Launch"

msg.payload.fbSenderId = msg.payload.entry[0].messaging[0].sender.id;

return msg;

Process FB output

Place the below code in this function node. Replace the XXXXXXX in the code with Facebook’s page access token

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=XXXXXXXXXXX"

msg.method = 'POST';

msg.headers = {};

msg.headers['Content-Type'] = 'application/json';

return msg;

http request

Configure this node as shown in the below screenshot before connecting it to “http out”.

Sample flow

 

  • No labels