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