Botframework在使用当前的Intent对话框之前不会中断其他意图对话

use*_*376 5 node.js botframework azure-language-understanding

我使用LUIS.ai打算使用A和B. 在意图A我builder.Prompts.text用来问用户几个问题.然而,有时取决于答案,它会切换到意图B.我猜它恰好与我的意图B匹配,即使我认为它不应该.有没有办法防止这种情况发生?如果我正在通过意图A的对话框,我不希望任何其他意图的中断,直到我完成.这是我的代码示例.

bot.dialog('A', [
    function (session, args, next) {
        ...
    }, 
    function (session, args, next) {
        ...
    },
    function (session, args) {
        ...
    }
]).triggerAction({
    matches: 'A'
});


bot.dialog('B', [
    function (session, args, next) {
        ...
    }, 
    function (session, args, next) {
        ...
    },
    function (session, args) {
        ...
    }
]).triggerAction({
    matches: 'B'
});
Run Code Online (Sandbox Code Playgroud)

Pav*_*ler 6

这就是你要做triggerAction的事情.它们可以非常方便地保持对话框打开(http://www.pveller.com/smarter-conversations-part-2-open-dialogs)但在你的情况下它们会妨碍你.

如果将对话框置于其下,则可以使对话框免受全局路由系统的影响IntentDialog.如果您所做的只是AB,那么这将是您的代码的不可中断的等价物:

const intents = new builder.IntentDialog({
    recognizers: [
        new builder.LuisRecognizer(process.env.LUIS_ENDPOINT)
    ]
});

intents.matches('A', 'A');
intents.matches('B', 'B');

bot.dialog('/', intents);
bot.dialog('A', []);
bot.dialog('B', []);
Run Code Online (Sandbox Code Playgroud)

  • `cancelAction`应该附加到*inner*对话框.你已将它附加到绑定到`/`的*outer*`IntentDialog`.你需要像`intent.matches('A','A')`然后`bot.dialog('A',[]).cancelAction()`.这会将取消操作附加到对话框"A"而不是"/".说得通? (2认同)