-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebhook.js
35 lines (34 loc) · 1.39 KB
/
webhook.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module.exports = function(req, res) {
if (req.body.object === 'page') {
req.body.entry.forEach(function(entry) {
entry.messaging.forEach(function(event) {
if(event.message) {
if(event.message.text && !event.message.attachments) {
req.loopsController({
senderId: event.sender.id,
text_message: event.message.text
})
} else if(event.message.quick_reply){
req.loopsController({
senderId: event.sender.id,
quick_reply: event.message.quick_reply
})
} else if(event.message.attachments) {
req.loopsController({
senderId: event.sender.id,
coordinates: event.message.attachments[0].payload.coordinates
})
}
} else if(event.postback) {
if(event.postback.payload) {
req.loopsController({
senderId: event.sender.id,
payload: event.postback.payload
})
}
}
});
});
res.sendStatus(200);
}
}