在Microsoft Bot Framework SDK V3中,欢迎消息两次触发

时间:2019-03-26 23:50:41

标签: node.js azure botframework

我有一个机器人,其中的根对话框是一个选择提示(是/否),我想在机器人启动时向用户显示。以下是对话更新和根对话框的代码片段。这里的问题是,当用户在根对话框中单击是或否时,即欢迎消息,将再次触发根对话框,并再次要求用户单击是或否。之后,该机器人将继续其正常流程,但我希望根对话框仅触发一次。

预先感谢

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');
}
]);

1 个答案:

答案 0 :(得分:1)

相关问题