bot框架识别器不会覆盖默认对话框

时间:2018-07-18 14:22:08

标签: javascript node.js botframework

我试图在用户点击某些关键字(例如“浴室”)时触发自定义对话框,并且根据recognizing user intent from message content上的Bot Framework教程:Intent recognizers are global, which means that the recognizer will run for every message received from the user. If a recognizer detects an intent that is bound to a dialog using a triggerAction, it can trigger interruption of the currently active dialog. Allowing and handling interruptions is a flexible design that accounts for what users really do.完成后,将创建一个识别器,该识别器镜像本教程中的识别器的格式,然后有一个触发该识别器的对话框,还镜像本教程的格式。但是,无论我键入什么,使用关键字还是使用其他关键字,该漫游器都只会启动默认对话框,这似乎与意图识别器的global方面相矛盾。我想将默认对话框保留在bot的实例中,因为它是与bot应该进行的主要交互,所以有什么办法可以解决该约束问题?

以下相关代码段:

//instantiate the bot with the default dialog
let bot = new builder.UniversalBot(connector, [
    (session) =>{
        //default dialog code here
    }
]);

//recognizers
//for nearest bathroom
bot.recognizer(new builder.RegExpRecognizer("NearestBathroom", {en_us: /^(bathroom|restroom|toilet)/i}));

//Dialog for locating a room triggered by the recognizers above
bot.dialog('locationDialog', [
    (session) => {
        //dialog code here
    }
]).triggerAction({ matches: 'NearestBathroom' });

0 个答案:

没有答案