This example is a Hubot script that messages a chat room when a Facebook Page post is published using Facebook's Graph API Webhooks. The message includes a link to the Facebook post. The bot will post another message with the number of likes on the post after a configurable number of minutes.
These instructions assume you have already set up Hubot on Heroku or Hubot on another platform.
- Download
graph-api-webhooks.coffee
. - Add a line to
hubot-scripts.json
withgraph-api-webhooks
. - Create a new Facebook application and/or register an Instagram API client.
- Using
token
as the verify_token, set up your Facebook application's Graph API Webhooks subscription usinghttps://<your-subdomain>.herokuapp.com/facebook
as the callback URL, and/or your Instagram client's subscription using yourhttps://<your-subdomain>.herokuapp.com/instagram
as the callback URL. - Set the Heroku configuration values defined at the top of
graph-api-webhooks.coffee
before deploying.FACEBOOK_APP_ACCESS_TOKEN
- access token for your Facebook appREAL_TIME_ROOM
- chat room for Hubot to post inWAIT_MINUTES
- number of minutes to wait before retrieving the number of likes on the post
- Install the Facebook app on your Facebook Page using the Page subscribed apps endpoint.