Facebook Messenger App

Messenger App make it easy to start conversations with your pages.To get in touch, people simply scanning below image using the Messenger app.

Digital Devnet Messenger@digitaldevnet
Click below link to launch messenger in your browser.
http://www.facebook.com/digitaldevnet

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
https://developers.facebook.com/docs/messenger-platform/guides/quick-start

Download the sample app from Github to follow along with this tutorial.
https://github.com/fbsamples/messenger-platform-samples

Prerequisites

  1. Create a Facebook App and Page
  2. Setup Webhook in Facebook
  3. Setup Heroku via node Js

Using Heroku
$ 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

Important Notes.
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.
https://XXXX.herokuapp.com/webhook

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

Resources
https://www.youtube.com/watch?v=ZlysN-027Q4
https://bottr.co/docs/deploying-your-first-bot.html
https://blog.hartleybrody.com/fb-messenger-bot/
https://codingislove.com/build-facebook-messenger-bot-javascript/
https://github.com/jw84/messenger-bot-tutorial

Leave a Comment

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