Botframework在使用当前的“意图对话框"完成之前,不会从其他“意图对话框"中中断 [英] Botframework No Interruptions from other Intent Dialogs until done with current Intent Dialog

查看:48
本文介绍了Botframework在使用当前的“意图对话框"完成之前,不会从其他“意图对话框"中中断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算使用LUIS.ai来实现A和B.目的A我正在使用builder.Prompts.text询问用户几个问题.但是,有时取决于答案,它会切换到意图B.我猜想它恰好与我的意图B相匹配,即使我认为不应该.有办法防止这种情况发生吗?如果我正在通过意图A的对话框,那么在完成之前,我不希望其他意图引起任何干扰.这是我的代码示例.

I've intent A and B using LUIS.ai. In intent A I'm using builder.Prompts.text to ask user couple questions. However, sometimes depending on the answer it would switched to intent B. I'm guessing it happens to match with my intent B even though I think it shouldn't. Is there a way to prevent this from happening? If I'm going through intent A's dialogs, I don't want any interruptions from other intents until I'm done. Here is an example of my code.

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

推荐答案

这就是triggerAction对您的作用.它们可以非常方便地使您的对话框保持打开状态( http://www. pveller.com/smarter-conversations-part-2-open-dialogs ),但在您的情况下,它们会妨碍您的操作.

That's what triggerActions do to you. They can be very handy to keep your dialogs open (http://www.pveller.com/smarter-conversations-part-2-open-dialogs) but in your case they get in the way.

如果您将对话框置于IntentDialog下,则可以使它们保持对全局路由系统的免疫.如果您要做的只是AB,那么这将等效于您的代码:

You can keep your dialogs immune to the global routing system, if you place them under the IntentDialog. If all you do is A and B, then this would be an un-interruptible equivalent of your code:

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

这篇关于Botframework在使用当前的“意图对话框"完成之前,不会从其他“意图对话框"中中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆