Direct Facebook Messenger Integration

This procedure is for a direct integration with Facebook Messenger. We recommend using the integration via Conversation API.

You can receive customer messages via your Facebook page when you have an application with Messenger connected to the Facebook page.

Integration Overview

The integration utilizes three different components: SMS Server, Facebook Messenger, and the Facebook Webhook service, configured with the Facebook application. The purpose of the Webhook service is to monitor Facebook Messenger page. If a new chat is initialized, the Webhook delivers the message to a preconfigured destination. In this case the destination is the SMS Server that takes care of incoming and outgoing chat messages.

Configuring Facebook Messenger

The configuration may change so you should check the latest instructions from Facebook.

  1. If you already have a developer account, open https://developers.facebook.com and log in.

    Otherwise create or promote an existing Facebook account by clicking the Log In button. For more information, see https://developers.facebook.com/docs/messenger-platform/guides/setup.

  2. Go to My Apps and click Add a New App.
  3. Insert details for your new application.
  4. Assign new products to your application:
    1. Go to the Add a Product section and select Messenger.
    2. Click Set Up.

    A new application with the Messenger is created. Now you connect this application to a Facebook page. If you don't have one, create it at https://www.facebook.com/pages/create.

  5. Assign the Facebook page with Messenger in App Dashboard > Products > Messenger > Settings > Token Generation and then select your page.

    A popup window is opened requesting a permission. Accept it.

  6. Enable the Webhooks service by scrolling down the page to the Webhooks section and clicking Setup Webhooks.
  7. Configure a new page subscription:
    1. Insert a callback URL that points to Sinch Contact Pro SMS Server .

      This is of format http[s]://[smsserverlocalhttpserverip]:[port]/sms/facebook/facebook.

      It should be via proxy or directly pointing to SMS Server in Infrastructure Administrator > SMS Server > Local HTTP Server .

    2. Add a random string, for example 12345678, to the Verify Token field.

      A verify token is required although it's not used by Sinch Contact Pro.

    3. In the Subscription Fields section, select messages.
    4. Click Verify and Save.

      If everyting works, you'll see Webhooks icon turning to green on the left pane. An error message is displayed if Facebook fails to connect to the SMS Server. For more information, see Troubleshooting and Tips.

  8. Add a Send Message button to your Facebook page by opening the page and clicking Add a Button.
  9. Click the Contact you row.
  10. Select Send Message and click Next.
  11. Select Facebook Messenger and click Finish.

Creating Facebook Messenger Service in Sinch Contact Pro

  1. Define the following SMS Server variables in Infrastructure Administrator (IA):
    • Local HTTP Server Address

    • Local HTTP Port

    • Local HTTP Certificate (optional)

      If HTTPS is not used then certificates are not necessary. But if you use HTTPS, the certificate name should be same as the server address (IP address or domain name).

    • HTTP Proxy Policy:

      Named: Give the HTTP proxy address in the HTTP Proxy Name field

      Automatic: The proxy setting will be taken from the Internet options of the HAC user

      Default Proxy: Retrieves the static proxy or direct configuration from the registry. This option is deprecated in OS win 8.1 and newer.

      No Proxy: No proxy is used.

    • HTTP Proxy Name:

      The address of the proxy server if the value Named is selected for HTTP Proxy Policy

  2. Define the SMS Server to run in HTTP mode in System Configurator > System Management > Modules > SMS Server:
    1. In the SMS Interface block, choose the option HTTP for the Session Object field.
    2. Reset SMS Server.
  3. Configure a Facebook messaging service in System Configurator > System Management > Messaging Services:
    1. Click Add New and choose facebook.
    2. In the Basics block, enter:
    3. In the Authentications block, enter:
      • Facebook app ID and secret

        The system will work without the configuration of app ID and secret but then there is no security check. Therefore, for security reasons, we recommend that you configure them.

      • One or more entries of page ID and page access token
        Table 1.
        Facebook Configuration Item Authentication ID Password

        App

        There can be only one app in Sinch Contact Pro .

        Enter app ID located in Facebook Graph API Explorer > Settings > Basic with a prefix app:.

        For example: app:1234567890123

        Note:

        Only one account can have the app: prefix.

        Enter the app secret located in Facebook Graph API Explorer > Settings > Basic.

        Page

        There can be as many pages as needed.

        Enter page ID located in Facebook Graph API Explorer > Products > Messenger > Setting.

        Enter page access token located in Facebook Graph API Explorer > Products > Messenger > Setting.

        Note: If you change your Facebook password, you have to generate a new token in Facebook > Settings > Access Tokens and enter it here as a password.
  4. Create a chat new queue or update an existing one in Queue Management > Queues and as a queue address add [PageID]@facebook.com.

    Depending on the configuration, one queue can handle multiple pages, or there can be one queue per page.