Botframework No Interruptions from other Intent Dialogs until done with current Intent Dialog

给你一囗甜甜゛ 提交于 2019-11-30 17:13:01

问题


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

回答1:


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.

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



回答2:


All you have to do is this:

var recognizer = new builder.LuisRecognizer(url) 
    .onEnabled(function (context, callback) {
        // LUIS is only ON when there are no tasks pending(e.g. Prompt text) 
        var enabled = context.dialogStack().length === 0; 
        callback(null, enabled); 
    });


来源:https://stackoverflow.com/questions/43351517/botframework-no-interruptions-from-other-intent-dialogs-until-done-with-current

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!