Publish Your Bot on Facebook Messenger

Learn how to configure the integration with Messenger.

In order to publish your channel to Facebook, you will need to create an app in Facebook Developer portal that will work with NativeChat, and publish the app in an existing Facebook Page.

Once published, your users will be able to interact with your chatbot by simply messaging your page. Further, you will be able to monitor all conversations between the chatbot and your Facebook users in the Facebook Page administration panel.

Sign up as a Developer for Facebook

Before you can create and publish a chatbot for Facebook, you need to sign up for a Developer account by registering at https://developers.facebook.com/.

Create a new Facebook app

  1. Create a new App from by clicking on Add a New App on Facebook for Developers at https://developers.facebook.com/apps/. The new app will be used to hold the integration between NativeChat and your Facebook Page.
  2. Once your app is created, open the Dashboard of your new app, and click on Show to view your App Secret. Store it somewhere safe as you will need it in a second. Before you can enable the Facebook Integration with NativeChat, you will need to Create a Messenger product within the new App.

Create a Messenger product

  1. Select the +Add Product action button from the left menu, find the Messenger product, and click on its Get Started button.
  2. Locate the Token Generation section, and select your Page that you want to connect to. This will generate a Page Access Token that you will need to store and provide within the NativeChat Portal.

Create a new channel in NativeChat

To receive messages and other events sent by Messenger users, the app should enable webhooks integration with NativeChat. For this purpose, you will need to retrieve your App Secret and Page Access Token and enable the Facebook channel in your app.

  1. Open the Publishing section of your NativeChat bot,
  2. Click the Add button for Facebook to open the Add Facebook configuration form, and provide the App Secret and Page Access Token you have obtained earlier from your Facebook App.
  3. Click the Add configuration button. You will receive a Webhook URL and Verify Token that you will use to create a Webhook in your Facebook App.

Setup a webhook in Facebook

Once you’ve created a Facebook channel for your bot, go to your Facebook app page and follow these steps:

  1. Within your Facebook app, click Messenger link on the left side, and find the Webhooks section.
  2. Click on the Setup Webhooks button
  3. Enter the Callback URL and Verify Token that you received from NativeChat
  4. Select a page to subscribe your webhook to the page events by clicking on the Select a Page button, selecting your Page, and clicking the Subscribe button.

Webhooks Section on the Messenger Settings page.

Test your bot

Now you should be able to message your Facebook Page by navigating to its public URL, and sending it a message by clicking on the Message button and selecting Test Message. Alternatively, you can navigate to Messenger’s web interface https://www.messenger.com/ and start a chat session with your Page.

Restrictions for EU citizens and businesses

Facebook announced that multiple API restrictions will be enforced after Dec 15, 2020. These changes affect any page whose owner is from the EU as well as every Facebook user who is from the EU. In order to cope with these changes NativeChat now performs multiple mitigation steps when it encounters errors related to this condition:

  1. Single-select, Carousel and Authentication steps will send fallback URLs when the button templates that they normally use happen to be restricted. Users of the bot will now have to click these links and open the selection UI in a separate browser (or application) window.
  2. The carousel template will be shown as a single-select template.
  3. Typing indicator will not be visible to the user
  4. EU users will no longer be allowed to directly upload files in the chat, NativeChat’s Facebook Messenger channel will now consider an URL sent as plain text as an attachment. While this might not be the most convenient option, it will allow users to share a file by uploading it on the internet and sending its URL to the bot.
  5. User profile information will not be retrievable. I.e., in the history tab affected users will appear as anonymous.

The description of all the changes and restrictions made by Facebook can be found here.

Known issues

Facebook chatbot stops responding

The problem could be that Facebook unsubscribes your app from listening for events from your page.

You can check if this is the case by going to https://developers.facebook.com/apps/, select your app, Find the Messenger product section in the navigation and click it.

Under Webhooks section there is information about which page(s) is your app subscribed to (see the image above).

If your page is not listed there, use the “Select a page” dropdown and subscribe your app to the page events.