Facebook Messenger

Kinvey Chat allows publishing a chatbot for Facebook. In order to publish your channel to Facebook, you will need to create an app in Facebook Developer portal that will work with Kinvey Chat, 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 Kinvey Chat 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 Kinvey Chat, 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 Kinvey Chat Portal.

Create a new channel in Kinvey Chat

To receive messages and other events sent by Messenger users, the app should enable webhooks integration with Kinvey Chat. 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 Channels & Publishing section of your Kinvey Chat bot,
  2. Click the Publish button for Facebook, and provide the App Secret and Page Access Token you have obtained earlier from your Facebook App.
  3. Click the Connect 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 Kinvey Chat
  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.

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 developers.facebook.com, 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.