【问题标题】:botframework mention conversation id in webchatbotframework 在网络聊天中提及对话 ID
【发布时间】:2017-01-10 12:06:12
【问题描述】:

我们如何在botframework webchat 中提及对话id 而不是随机生成?我们目前可以为webchat 提及useridusername,但无法提及id 的对话。

【问题讨论】:

  • 不清楚您所说的“提及对话”ID 是什么意思。你能澄清一下吗?
  • 当我们嵌入网络聊天时,我们可以传入 userId 和 userName 作为参数。我想知道是否有任何选项让我们手动设置 session.message.address 中的对话 ID,以便我们可以将消息推送到网络聊天。

标签: node.js botframework


【解决方案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);
}

【讨论】:

  • 其实问题是关于 => UserA 正在 WebChat 上,然后重新加载页面。重新加载页面时,用户仍然相同(cookie),但 Conversation.Id 不同。在这种情况下,builder.Message().address(address) 不起作用。除了对话 ID,地址相同。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-30
  • 1970-01-01
相关资源
最近更新 更多