Skip to content

Instantly share code, notes, and snippets.

@scomma
Last active July 4, 2017 17:02
Show Gist options
  • Save scomma/ef56c042f9b6cb14f7029174fe425594 to your computer and use it in GitHub Desktop.
Save scomma/ef56c042f9b6cb14f7029174fe425594 to your computer and use it in GitHub Desktop.
exports.dispatch = (req, res) ->
# Facebook's challenge
if req.query['hub.mode'] == 'subscribe' and \
req.query['hub.verify_token'] == 'c2f18de9'
return res.status(200).send req.query['hub.challenge']
# Actual webhooks
if req.body.object == 'page'
for entry in req.body.entry
for e in entry.messaging
console.log e.message.text
# Always acknowledge
res.sendStatus(202)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment