Configure Botkit and Facebook Messenger

Note: This also applies for Facebook Workplace

Facebook is a constantly evolving platform, nominally you can find everything you need to create a bot on their platform page, but that information is subject to change.

1. Install Botkit

Once installed, you will need to do steps 2-4, and steps 5 in parallel. It helps to have your development enviroment and the Facebook for Developers page open at the same time.

2. Create a Facebook App for Web

Visit Facebook for Developers page and create a new app.

Screenshot of create an APP ID in Facebook developer portal

Screenshot of configuring your app in the Facebook developer portal

3. Get a Page Access Token for your app

Scroll down to Token Generation

Screenshot of page access tokens in Facebook portal

If you have not yet created your page yet, you can go ahead and do this now, or associate this new bot with an existing page.

Copy this Page Access Token, you'll need it when running your bot.

4. Setup webhooks

Click Setup Webhooks to link this application to your Botkit instance.

Screenshot of configuring webhooks in the Facebook portal

The callback url will be https://YOURURL/api/messages. This URL must be publically available, and SSL-secured. More information on this can be found in the next step.

You will also need to define a Verify Token for your page subscription. This is a user-defined string that you will keep secret and pass in with your environment variables.

5. Run your application

Run your application with your environment variables set:

If your application has been configured correctly, you will be able to talk to your bot through the page you specified in Step 3. Congratulations!

Additional resources

Is something missing or out of date?

This file is managed on Github. click here to view the source, and send us a pull request with your improvements!

Back to top