Skip to content

Instantly share code, notes, and snippets.

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