到目前为止,我正在为fb Messenger创建聊天机器人。我面临以下问题:使用请求创建新的fb帖子
{myPageID}/feed?message=For all Math geniuses :)&payload={"value":"test"}&call_to_action={"type":"MESSAGE_PAGE","value":"test"}&link=someLink&access_token={my_token}
我正在附加CTA按钮“ MESSAGE_PAGE”,其中添加了“向我的帖子发送消息按钮”
当我点击“发送消息”按钮时,我的页面就会自动响应并带有链接预览
我已订阅所有Messenger事件,并且我收到的唯一事件是传递事件。有什么方法可以捕捉此自动响应消息的标题或链接?当我通过请求发布时,我添加了有效负载,将值均匀地发布回了按钮,除了此交付事件之外,什么都没有发生
到目前为止,这是我的接收消息:
app.post('/webhook', (req, res) => {
let body = req.body; // Checks this is an event from a page subscription
if (body.object === 'page') {
// Iterates over each entry - there may be multiple if batched
body.entry.forEach(function (entry) {
// Iterate over each messaging event
entry.messaging.forEach(function (event) {
console.log(event);
if (event.message) {
receivedMessage(event);
}
else if (event.delivery) {
//TO DO
}
else {
payloadMessage(event);
}
});
});
// Returns a '200 OK' response to all requests
res.status(200).send('EVENT_RECEIVED');
} else {
// Returns a '404 Not Found' if event is not from a page subscription
res.sendStatus(404);
}
});
这是交货事件
{ sender: { id: 'senderID' },
recipient: { id: 'recipientID' },
timestamp: 1558957571235,
delivery:
{ mids:
[ '8KsvyN2iL2upEhwddr_uQXeOJLgKhhdQtqQ8RzPxlPczGgR2T1w7Inqg8TJK-4gpWNQS-HZvLUBS5R-g1FcWdQ' ],
watermark: 1558957571029,
seq: 0 } }