Facebook Integration

Customer Channel Manager provides out-of-the-box integration with Facebook Messenger.

To deploy a live webhook that can receive webhook events from the Messenger Platform, your code must be hosted on a public HTTPS server that meets has the following:

  • HTTPS support, Self-signed certificates are not supported
  • A valid SSL certificate
  • An open port that accepts GET and POST requests

Once the above pre-reqs are complete, follow these steps.

  1. Login to your Facebook developer account.
  2. Follow this documentation to create a Facebook App.
  3. Add a product Messenger. 
  4. Create or link a Facebook page and generate an access token.
  5. Copy Page access token and set it in the variable FACEBOOK_VERIFY_TOKEN in SMS Connector Environment Variables.
  6. Restart the sms-connector component.

Registering a webhook

Add a callback URL in the Messenger settings with these values,

  • Callback URL: https://<fqdn>/sms/webhook?hub.verify_token=<FACEBOOK_VERIFY_TOKEN>&hub.challenge=CHALLENGE_ACCEPTED&hub.mode=subscribe
  • Verify TokenFACEBOOK_VERIFY_TOKEN

Add subscriptions

  1. Subscribe to the messages field in the Messenger settings.
  2. Add one or more Facebook accounts as "Tester" under the Roles section. Each tester must accept the request by logging in to the Facebook Developer Account.

Environment Variables for Facebook Integration

Set the following variables in the SMS Connector Environment Variables.

Variable Name

Description

FACEBOOK_GRAPH_API_URL

https://graph.facebook.com/v4.0. This is the URL for the Facebook Graph APIs. 

FACEBOOK_VERIFY_TOKEN

FACEBOOK_VERIFY_TOKEN

FACEBOOK_USERNAME

Chat display name/ business name shown to the customer during the chat conversation.

ERROR_MESSAGE_RESPONSE

The error message shown in case the message from the customer is not processed successfully or if any error occurs.

Deployment Architecture

The architecture diagram below shows how the flow of communication happens between the different components in the case of Hybrid Chat and Facebook integration. Hybrid chat agent gadget, shown here as the Messenger App communicates directly to our Hybrid Chat server (shown here as the Business Server). It communicates directly with the Facebook server. It receives data through webhooks and sends it through the Facebook business APIs.