[英]How to send welcome message AND load a specific dialog automatically in Microsoft Bot Framework v.3 (Node.js)?
I'm trying both to show a welcome message when my bot starts up and also load a specific dialog.我正在尝试在我的机器人启动时显示欢迎消息并加载特定对话框。 We are using version 3 in the company where I'm working (I know, it's old and not supported).
我们在我工作的公司中使用第 3 版(我知道,它很旧且不受支持)。
As far as the welcome message, https://docs.microsoft.com/en-us/azure/bot-service/nodejs/bot-builder-nodejs-handle-conversation-events?view=azure-bot-service-3.0 says to use on conversationUpdate
, which works fine, but this seems to be contradicted by https://blog.botframework.com/2018/07/12/how-to-properly-send-a-greeting-message-and-common-issues-from-customers/ , which suggests one should not use conversationUpdate
, except when using DirectLine, but instead send an event.至于欢迎消息, https://docs.microsoft.com/en-us/azure/bot-service/nodejs/bot-builder-nodejs-handle-conversation-events?view=azure-bot-service-3.0说要
on conversationUpdate
上使用,效果很好,但这似乎与https://blog.botframework.com/2018/07/12/how-to-properly-send-a-greeting-message-and-common相矛盾-issues-from-customers/ ,这表明不应使用conversationUpdate
,除非使用 DirectLine,而是发送事件。 Is this the final word on the matter?这是对此事的最终决定吗? Is there a better way?
有没有更好的办法?
I'd also like to load a dialog automatically after the welcome message.我还想在欢迎消息之后自动加载一个对话框。 How do I do this?
我该怎么做呢? Can I access the session during the 'on conversationUpdate' event above and load the dialog directly there?
我可以在上面的“on conversationUpdate”事件期间访问 session 并直接在那里加载对话框吗? Is there a better way?
有没有更好的办法?
Thanks for any help!谢谢你的帮助!
It is contradictory, but conversationUpdate
is likely your best bet in most situations.这是矛盾的,但在大多数情况下,
conversationUpdate
可能是您最好的选择。 However, because channels handle this differently, you should be aware that the result can vary.但是,由于渠道对此的处理方式不同,因此您应该知道结果可能会有所不同。 For direct line, it is a better option to utilize sending events.
对于直线,使用发送事件是一个更好的选择。
An example, in case of need:一个例子,以备不时之需:
bot.on('conversationUpdate', function(message) {
if (message.membersAdded) {
message.membersAdded.forEach(function(identity) {
if (identity.id === message.address.bot.id) {
var reply = new builder.Message()
.address(message.address)
.text("Welcome");
bot.send(reply);
}
});
}
});
For immediately calling a specific dialog, do this:要立即调用特定对话框,请执行以下操作:
bot.on('conversationUpdate', function (message) {
if (message.membersAdded) {
message.membersAdded.forEach(function (identity) {
if (identity.id === message.address.bot.id) {
bot.beginDialog(message.address, '/main');
}
});
}
});
bot.dialog('/main', [
function (session, args, next) {
session.send("Glad you could join.");
session.beginDialog('/next');
}
]);
Simply combine the two for sending the welcome message and starting up a dialog.只需将两者结合起来发送欢迎消息并启动对话。
Hope of help!希望有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.