$ npm install
$ node index.js
- Create a Facebook App and Page.
- Setup your webhook for your app by going here, selecting your app, and selecting the Messenger tab on the left. Register new webhook by putting in "https://your domain here/webhook" for the webhook, entering a verify token that you decide, and selecting the "messages" subscription field.
- Get your access token by selecting your App under the "Token Generation" header.
At this point, create a secrets.json
file under this repository with the following format:
{
"accessToken": "<enter your access token from step 3>",
"verifyToken": "<enter your verify token from step 2>"
}
Don't forget to subscribe your App to the Page (this only needs to be done once per app unless you get unsubscribed:
curl -ik -X POST "https://graph.facebook.com/v2.6/me/subscribed_apps?access_token=<token>"
Now you can run this service on your server and have your bot start responding to chats!
To run the service in the background forever, use forever.
$ [sudo] npm install forever -g
$ forever start index.js