botframework在网聊中提及对话ID

时间:2017-01-10 12:06:12

标签: node.js botframework

我们如何在id中提及对话botframework webchat而不是随机生成?我们目前可以提及userid的{​​{1}}和username,但无法提及webchat对话。

1 个答案:

答案 0 :(得分:1)

有关此主题的更多信息,请查看指南:Send proactive messages

  

为了能够向用户发送即席消息,机器人必须首先从当前对话中收集并保存有关用户的信息。消息的地址属性包括机器人稍后需要向用户发送即席消息所需的所有信息。

bot.dialog('/', function(session, args) {
    var savedAddress = session.message.address;

     // (Save this information somewhere that it can be accessed later, such as in a database.)

    var message = 'Hello user, good to meet you! I now know your address and can send you notifications in the future.';
    session.send(message);
});
  

在机器人收集了有关用户的信息后,它可以随时向用户发送临时主动消息。为此,它只是检索先前存储的用户数据,构造消息并发送它。

function sendProactiveMessage(address) {
    var msg = new builder.Message().address(address);
    msg.text('Hello, this is a notification');
    msg.textLocale('en-US');
    bot.send(msg);
}
相关问题