Simple chat bot server for the Hodor Bot Facebook application. Based on Sample-FB-ChatBot.
$ npm i
$ npm start
You'll need to set up the FB_TOKEN
environment variable with the app access token provided by Facebook in your app settings dashboard.
- Clone this repo
$ git clone https://github.com/gvilarino/hodor-bot-fb.git
- Install NodeJs dependencies
$ cd Sample-FB-ChatBot
$ npm install
- Run server
$ npm start
If you are seeing "Example app listening on port 3010!", your server has been started successfully.
- Stop the server for now
- Set this to your
FB_TOKEN
env variable - Start the server
- Since Facebook only accept public https URLs as their webhooks, we need to expose our local server endpoints as public https. Quick way to do that is use https://localtunnel.me/
- Create a https public endpoint using https://localtunnel.me/ (Please make sure you disable your firewalls)
$ npm install -g localtunnel
- Tunnel our local server port
- lt --port 3010
- You will get something like https://something.localtunnel.me which is your public base URL
- If you goto https://something.localtunnel.me/webhook in your web browser you will get a message saying "Error, wrong validation token"
- Once this is done goto https://developers.facebook.com/docs/messenger-platform/implementation#setup_webhook and setup the webhook that we just created in the Facebook Application
- Subscribe your application with your page (link
- Now goto your Facebook page and send it a chat message, it will echo back the text you send.
Keep in mind that only app admins, developers and testers will be able to see the bot's anwsers until the app is public and approved by Facebook.