【问题标题】:Chatbot messages do not show up in Facebook Messenger chat heads聊天机器人消息未显示在 Facebook Messenger 聊天头中
【发布时间】:2018-07-11 03:53:26
【问题描述】:

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

【问题讨论】:

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


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-14
      • 1970-01-01
      • 1970-01-01
      • 2020-03-28
      • 1970-01-01
      • 1970-01-01
      • 2019-01-03
      • 1970-01-01
      相关资源
      最近更新 更多