Create Instant Messenger Account for Facebook Messenger

The following steps give you an overview of the steps necessary to create a bot for the Facebook Messenger. Since the user interface of Facebook is regularly subject to change, the following steps are not entitlement to completeness or accurateness. However, we update the documentation on a regular basis and look forward to your hints.

Brief overview: The installation takes place in multiple steps:
  1. (BBP) Create a new bot account for Facebook Messenger
  2. (Facebook) Create a new bot account at Facebook
  3. (BBP) Complete bot account configuration on Business Bot Platform

Step 1: (BBP) Create a new bot account for Facebook Messenger

Webhooks are used to send various events including messages, authentication events and callback events from Facebook to the Business Bot Platform. Because Facebook only supports the WebHook concept for receiving messages from Facebook Messenger, no other methods are supported.

  1. Login to the Business Bot Platform
  2. Choose Chatbot Administration -> Instant Messenger Accounts -> Create Bot Account. The following data is required to create the bot account:
Field Example value
Name: MyFMBotAccount
Description: BotAccount for department Z
Instant Messenger: Facebook Messenger
  1. The bot account has been created and must still be configured with the instant messenger account information. To do this, click on the icon Settings and modify the following parameters:
Required Fields Description Example value
FacebookMessenger.UserInfo.UserId [UserId] is the Facebook user ID 1785460681483403
FacebookMessenger.PageToken [179 character string] is the Page Access Token EAAZA9aTEEH4YBANfxb9NSrOz9...
FacebookMessenger.ValidationToken [Verify Token] is the key to access the webhook password
FacebookMessenger.WebhookId xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx the Webhook-Id which is a part of the Webhook-URL db6a19e5-e281-4683-947c-e5490cbf98da

The FacebookMessenger.WebhookId is the unique identifier for the bot account. Facebook requires for the webhook a full URL which contains the WebhookId. In Facebook, the WebHook URL is the following compound address:

  • Syntax: https://demo.mmgw.de/bbp/webhook/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  • Example: https://demo.mmgw.de/bbp/webhook/db6a19e5-e281-4683-947c-e5490cbf98da

In addition to the webhook URL, you must assign a key that validates the Facebook connection to the Business Bot Platform. The key is set with parameter: FacebookMessenger.ValidationToken. For example, the key can be password.

Note

The Facebook Messenger accepts only secure connections (HTTPS), therefore the Business Bot platform with webhook must be reachable on an SSL-enabled server. HTTP is not supported by Facebook Messenger.

Other mandatory fields such as FacebookMessenger.UserInfo.UserId and FacebookMessenger.PageToken can not be filled yet until the Facebook bot has been configured, which will be explained in the next section.

Step 2: (Facebook) Create a new bot account at Facebook

Facebook for Developers provides a configuration page for the Messenger platform to create a new bot.

Configure Facebook App

  1. Open website https://developers.facebook.com/apps
  2. Click button Add a New App
Facebook Messenger: Create a New App Id
  1. Enter the Display Name (z.B. TestActor) and contakt email and subsequently confirm the Captcha
  2. Select product category Messenger
Facebook Messenger: Select product category
  1. Click button Create App ID
  2. In section Token Generation: Select the Facebook-Page, e.g. TestActor
Facebook Messenger: Token Generation

Webhooks

  1. In section Webhooks, you have to configure the webhook. Therefore click Setup Webhooks.
  2. Enter the webhook URL (Callback URL) of the Business Bot Platform and key (Verify Token) as well as check following Subscription fields. Subscription Fields:
    • messages
    • messaging_postbacks
    • messaging_optins
    • message_deliveries
    • message_reads
    • messaging_account_linking
    • message_echoes
Facebook Messenger: Configure webhook
  1. Click button Verify and Save. Facebook validates and confirms the webhook data immediately.
  2. On the left navigation panel, click Webhooks and select the created Facebook page in order to subscribe the webhook of the Business Bot Platform to the events of the Facebook page, (e.g. TestActorPage).

Step 3: (BBP) Complete bot account configuration on Business Bot Platform

Finally, the configuration of the bot account has to be completed on the Business Bot Platform.

  1. Choose Chatbot Administration -> Instant Messenger Accounts -> Icon Settings.
  2. The parameter value FacebookMessenger.PageToken must be configured with Facebook’s Page Access Token in section Token Generation.
Facebook Messenger: Copy Page Access Token from Facebook to the Business Bot Platform
  1. Parameter FacebookMessenger.UserInfo.UserId represents the user identifier of the bot account. These can be found in the URL of the created Facebook page.
Facebook Messenger: Determination of the bot account user id

The user account for the bot is now configured and will be used later when creating a bot for the Facebook Messenger.