Skip to content

Instantly share code, notes, and snippets.

@julie-mills
Created July 31, 2019 23:15
Show Gist options
  • Save julie-mills/e1bd8ea33acca23a5d5d093caf68a9d4 to your computer and use it in GitHub Desktop.
Save julie-mills/e1bd8ea33acca23a5d5d093caf68a9d4 to your computer and use it in GitHub Desktop.
Facebook Bot
// Accepts POST requests at the /webhook endpoint
app.post('/webhook', (req, res) => { let body = req.body; if
(body.object === 'page') { body.entry.forEach(function(entry) { let
event = entry.messaging[0]; if (event.message && event.message.text)
{ // handle the message handleMessage(event); } }); // Return a '200
OK' response res.status(200).send('EVENT_RECEIVED'); } else { //
Return a '404 Not Found' res.sendStatus(404); } });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment