Messenger App make it easy to start conversations with your pages.To get in touch, people simply scanning below image using the Messenger app.
Facebook Messenger Setup
Messenger bots uses a web server to process messages it receives or to figure out what messages to send. You also need to have the bot be authenticated to speak with the web server and the bot approved by Facebook to speak with the public.
Get started with Facebook guide
Download the sample app from Github to follow along with this tutorial.
- Create a Facebook App and Page
- Setup Webhook in Facebook
- Setup Heroku via node Js
$ heroku login
$ git init
$ heroku git:remote -a <YourHerokuAppName>
$ heroku buildpacks:set heroku/nodejs
Install NPM and dependencies as per download app
$ npm install express body-parser request –save
Create a Procfile to invoke to start your Bot.
web: node app.js
Creative .ENV file + Heroku Config Vars
PAGE_ACCESS_TOKEN: “Facebook Page Token”
appSecret: “ App Secret Key”
pageAccessToken: “Facebook Page Token”
serverURL: “ Bot Public URL “
validationToken: “ Webhook Key”
Run locally using NPM
$ npm start
Node app is running on port 5000
For deployment, it need a cloud server or some shared hosting to deploy your bot.
Callback URL – The Heroku Webhook does not require addon during heroku setup.
You need to subscribe your custom webhook to the Page events by issuing a POST request and providing PAGE_ACCESS_TOKEN. The simplest way to do it is to use “curl” it.
heroku config:add PAGE_ACCESS_TOKEN=$your_page_token_here
heroku config:add VERIFY_TOKEN=$your_verification_token_here