处理来自Facebook Messenger的消息传递JSON

嗨,我想抓住从我的机器人的Facebook信使传递JSON响应消息,以便我可以发送后续消息,当我知道一个图像的图库已经​​呈现。

我已阅读( https://developers.facebook.com/docs/messenger-platform/webhook-reference/message-delivered ),并可以看到消息传递JSON。

{ "sender":{ "id":"USER_ID" }, "recipient":{ "id":"PAGE_ID" }, "delivery":{ "mids":[ "mid.1458668856218:ed81099e15d3f4f233" ], "watermark":1458668856253, "seq":37 } } 

我也订阅了消息传递webhook。

我已经写了代码来抓住消息传递JSON,但没有运气:

 // handler receiving messages app.post('/webhook', function (req, res) { if(req.hasOwnProperty('watermark')){ console.log('message delivery found'); } } 

任何帮助将非常感激。

我只是评论,但即时通讯新:)

即时通讯不知道,如果你正在使用bodyparser或不,但我会检查req.body像波纹pipe

 // add this to the app file var bodyParser = require('body-parser'); app.use(bodyParser.json()); app.post('/webhook', function (req, res) { console.log(req.body); // inspect the body data if(req.body.delivery && req.body.delivery.watermark) console.log('message delivery found'); } }