gpt4 book ai didi

node.js - Chatbot 消息不会显示在 Facebook Messenger 聊天头像中

转载 作者:行者123 更新时间:2023-12-03 12:50:46 25 4
gpt4 key购买 nike

我正在使用 Microsoft Bot Framework 为 Facebook Messenger 开发聊天机器人。机器人向用户发送主动消息(提醒)。不幸的是,出于某种原因,消息永远不会出现在聊天头(用于对话的 Android 小部件)中,如果之前没有出现在屏幕上,也不会弹出聊天头。它确实发生在其他聊天机器人上(例如 Jarvis)。

这是发送提醒的代码:

Reminder.find({ next_reminder: { $lte: new Date() } }, (err, res) => {
if (err !== null) {
return console.error(err);
}

res.forEach(reminder => {
// Build a notification message and address it to user who created the reminder

const msg = new builder.Message().text('...');

bot.beginDialog(reminder.user_address, '*:/sendReminder', {message: msg, nudnik: nudnik});

});
});
};
};

我还尝试了 bot.send(msg, () => ....)session.beginDialog('sendReminder', msg)。但是,当收到消息时,Messenger 仍然没有任何指示。这里会出什么问题?

最佳答案

好的,我明白了!显然,Facebook 消息的默认通知设置是不显示通知。要更改它,在 NodeJS 中,您应该使用以下代码将特定于 channel 的数据添加到消息中:

msg = msg.sourceEvent({
facebook:
{notification_type: 'REGULAR'}
});

您可以在 Microsoft 的官方文档(herehere)以及 this Github discussion 中找到更多信息.

关于node.js - Chatbot 消息不会显示在 Facebook Messenger 聊天头像中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51277002/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com