Last active
July 4, 2017 17:02
-
-
Save scomma/ef56c042f9b6cb14f7029174fe425594 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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