Skip to content

Instantly share code, notes, and snippets.

@julie-mills
Created July 31, 2019 23:14
Show Gist options
  • Save julie-mills/584899885525bde207f04ca5e1d2185f to your computer and use it in GitHub Desktop.
Save julie-mills/584899885525bde207f04ca5e1d2185f to your computer and use it in GitHub Desktop.
FacebookMessengerBot
// 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