【发布时间】:2019-03-27 22:54:10
【问题描述】:
我有一个机器人,其中根对话框是一个选择提示(是/否),我想在机器人启动时向用户显示。下面是 conversationUpdate 和根对话框的代码 sn-ps。这里的问题是当用户在根对话框(即欢迎消息)中单击“是”或“否”时,第二次触发根对话框并再次要求用户单击“是”或“否”。之后,机器人将继续其正常流程,但我希望根对话框只触发一次。
提前致谢
bot.on('conversationUpdate', function (message) {
if (message.membersAdded && message.membersAdded.length > 0) {
message.membersAdded.forEach(function (identity) {
if (identity.id === message.address.bot.id) {
bot.beginDialog(message.address, '/');
}
});
}
});
根对话框代码:
bot.dialog('/', [
function (session) {
builder.Prompts.choice(session,"some text", ["yes", "no"], { listStyle: builder.ListStyle.button });
},
function (session, results) {
if (results.response.entity == "yes"){
session.send("some text");
}
else if (results.response.entity == "no"){
session.send("some text");
}
session.beginDialog('/nextDialog');
}
]);
【问题讨论】:
标签: node.js azure botframework