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