我们如何在botframework webchat
中提到会话id
,而不是随机生成它?我们目前可以提到webchat
的userid
和username
,但不能有id
提到的对话。
发布于 2017-05-09 23:38:34
有关此主题的更多信息,请查看指南:Send proactive messages。
为了能够向用户发送即席消息,机器人必须首先从当前对话中收集并保存有关该用户的信息。消息的address属性包括机器人稍后向用户发送即席消息所需的所有信息。
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);
}
https://stackoverflow.com/questions/41568479
复制相似问题