首页 > 解决方案 > Microsoft Bot 框架 session.endDialog() 使用

问题描述

如果您替换对话框,然后之前的对话框存储在堆栈中并存储在某处,我会在人们发布的某个地方阅读 Bot 文档。

现在我尝试按照 endDialog() 然后 replaceDialog();

callRequest.GetWebAPICall(session, urlData, function (body) {
        if(body.statusCode == 200) { 
            if(body.data == undefined) { 
                builder.Prompts.choice(session,Want to Select List?", "Yes|No",{listStyle: builder.ListStyle.button});
            } else { 
                session.endDialog();
                session.replaceDialog('/Show List');                
            }
        } else {
            session.send('Something went wrong. You can use the back or top command.');
            session.replaceDialog('/menu');
        }
    });

需要知道我是否替换以下行

session.endDialog();
session.replaceDialog('/Show List');  

经过

session.endDialog('/Show List');

标签: node.jsbotframework

解决方案


endDialog(),没有启动新对话框的功能。可以参考函数定义界面endDialog(message?: TextOrMessageType, ...args: any\[\]): Session;

在您的情况下,'/Show List'将作为消息发送给用户。

并且还有一个关于 的误解replaceDialog()

结束当前对话框并开始一个新的对话框。在新对话框完成之前,不会恢复父对话框。

如果需要存储之前的对话框,可以使用beginDialog()


推荐阅读