How to create a chatbot for your Facebook page using Heroku in 10 minutes

How to create a chatbot for your Facebook page using Heroku in 10 minutes

It is now a very popular thing for organizations to own a “Page” on Facebook. Users are now used to communicate directly with a Facebook Page and they expect a quick answer to their questions, 24/7.


Hopefully, since April 2016, Facebook allows us to create messenger bots.
Here’s how.

Note that everything that follows can be found on Facebook’s documentation.

First, create a Facebook Page

This is an easy step. Simply follow the instructions here: Create a page

Then, create a Facebook App

This is another easy step. Follow this link: Create an app
Facebook will want to help you set up your app with “Quick start” steps. Just skip this.

Take note of your App Secret.

On you app Dashboard, under Product Settings, click “Add Product” and select “Messenger.”


Under “Token Generation”, choose your Page to generate a Token. Take note of that Page Access Token.

And keep this tab open. You will need it soon.

Deploy to Facebook’s messenger-platform-samples to Heroku

Because Facebook’API needs an HTTPS callback, you won’t be able to test your app from localhost. One easy way to test your app is to use Heroku.

  1. Create an account on Heroku.
  2. Now download Heroku-CLI from Heroku’sdocumentation
  3. Let’s go

git clone
cd messenger-platform-samples/node
heroku login
heroku create youroriginalnamehere #Replace with your original name
cp config/default.json config/production.json

Now edit the config/production.json file with the App Secret and the Page Access Token you got from last step.

The serverURL is something that should look like

Now, you get to choose your Validation Token. Take note of it, you will need it in a moment.

git add .
git commit -m "Prod"
git push heroku master

Add a Messenger webhook to your app

Back to your App Dashboard. In the Webhooks section, click “Setup Webhooks.”

The URL for your webhook is something like

Enter your Validation Token and select message_deliveries, messages, messaging_optins, and messaging_postbacks under Subscription Fields.

You can now subscribe your App to your Page.


You’re done!

You can now try to chat with your brand new Facebook bot. By default, it will simply echo your message. In development mode, it will only be accessible to admins of the page and testers of the app. Enjoy!

One thought on “How to create a chatbot for your Facebook page using Heroku in 10 minutes

Leave a Reply

Your email address will not be published. Required fields are marked *