How to add a Facebook Messenger Bot to the Chat API

Let’s get started with Facebook Messenger! Follow these steps to be up and running in no time! The first part of this guide will explain how you can set up a testing/personal-use Bot, this takes less than 5 minutes. The second part will explain how you can submit your Bot for use in production.

 

  1. Go to https://developers.facebook.com/apps/.
         a. Click on ‘+ Add a new App’ in the top right corner.
         b. In the next pop-up you can choose for Basic Setup. Fill out the short form that’s presented, and then click ‘Create App ID’. 

  2. After submitting this form you’ll be taken to an overview page with various products you can set up.
         a. Before jumping into this, navigate to ‘Settings’ in the left sidebar.
         b. Click on ‘Show’ and you will see 2 values: AppId and AppSecret. Write these down somewhere as we will need them later.

  3. Click on ‘+ Add Product’ under ‘Products’ in the left sidebar.
         a. Click on ‘Get Started’ at the ‘Messenger’ section.
         b. You’ll be redirected to a new page with some explanation on Messenger and Bots.
         c. Click again on the blue ‘Get Started’ button to be redirected to the Messenger overview page. 

  4. In the ‘Token Generation’ section, select the Page you’d like to link to Chat API.
         a. After going through the Facebook oAuth flow, a Page Access Token will be generated. Write this one down as well. 

  5. At this point, you can go back to the MessageBird Dashboard.
         a. Fill in the AppId, AppSecret and Page Access Token you wrote down earlier.
         b. The only required open fields now is Page Id.
         c. The Page Id is the ID of the page you’ll be adding to the Chat API. You can find the Page ID of any page here: http://findmyfbid.com/.
         e. The Verify Token will be a prefilled token which is needed in step 7. Write this one down.

  6. Once you’ve filled this in you can click on ‘Add’ and the Channel will be connected to your account!

  7. Last step, head back to Facebook Developers.
         a. Go to the section under Token Generation’ named ‘Webhooks’.
         b. Click on the ‘Setup Webhooks’ button. This will present you with a pop-up form.
         c. The URL you’ll have to fill in here is https://chat.messagebird.com/facebook/webhook/<appId>.
         d. Where it mentions <AppId>, you have to fill in the AppId you wrote down during Step 2.
         e. Apart from the URL you’ll also have to fill in the Verify Token you received from us at Step 5-e.
         f. All Subscription Field checkboxes must be checked. After this you can click on ‘Verify and Save’.
         g. After this, select a page to subscribe your Webhook to. Do this by selecting the correct page in the dropdown and clicking on the blue ‘Subscribe’ button.

 

Done! You’ve just created and connected a Facebook Page to the Chat API. Now, you’re all set to send the first message to your Facebook Messenger Bot. Be aware that your current App is still in testing mode, so only you and the testers specified under the ‘Roles’ section in the left sidebar can actually use this Messenger integration.

Once you are ready to use your Messenger Bot in production, you will have to submit it for review. To do so, follow these steps: 

  1. Go to https://developers.facebook.com/apps/ and click on the App you want to use for Chat API and in production. In the left sidebar, click on ‘App Review’.
  2. On the ‘App Review’ page click on the ‘Start a Submission’ button.
         a. In the pop-up, select ‘pages_messaging’ and then, click on the blue ‘Add 1 Item’ button in the bottom right corner.
  3. You may be presented with a list of issues that must be resolved before you can submit the App for review - this could include anything from a Privacy URL to a missing App Icon.
  4. An important step to complete requires that you visit the ‘Settings’ page in the left sidebar.
         a. Here, click on ‘+ Add Platform’ at the bottom.
         b. Choose ‘Website’ as your platform, then simply enter the URL of your website.
         c. After this you can go back to the ‘App Review’ page.
  5. The most important hurdle before you can submit the App can be found under ‘pages_messaging’ in the submission overview.
         a. Here, click on ‘notes’ in the ‘Complete the notes for this item before submitting.’ text below pages_messaging.
         b. 
    After clicking on ‘notes’, a pop-up form with questions about the goal of your Bot will appear. You’ll also have to upload a screencast of how the App should work. This is obligatory and must be done well, as Facebook will really test your Bot and reject it if it doesn’t meet the description and screencast you provide.
  6. When you’ve filled in all the information and uploaded the screencast, click on ‘Save’, which will allow you to click on the ‘Submit for review’ button.
  7. When you click on ‘Submit for review’, you’ll be asked to accept Facebook’s Terms & Conditions. The last step is to click on ‘Submit’.

 

Facebook says they review all submissions within 2 weeks, but it often takes less than that. Be aware of the fact that they can reject your submission if it doesn’t meet the Facebook Messenger guidelines or doesn’t match the functionality as described and shown in the screencast. Even though we have no influence on this process and their decision, we are happy to help you out if something doesn’t work out. Just send us an email at support@messagebird.com.