Chatbot消息不会显示在Facebook Messenger聊天头中

时间:2018-07-11 03:53:26

标签: node.js notifications botframework chatbot facebook-messenger

我正在使用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仍然没有任何指示。这里可能出什么问题了?

1 个答案:

答案 0 :(得分:1)

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

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

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

相关问题