Botframework-sdk: [Question] triggerAction matching LuisRecognizer intent cannot interrupt current dialog

Created on 26 May 2017  路  6Comments  路  Source: microsoft/botframework-sdk

Pre-flight checklist

- [x] I have searched the existing issues before logging a new one.

System Information (Required)

  • SDK Platform: Node.js
  • SDK Version: 3.8.3
  • Development Environment: localhost

Issue Description

triggerAction which matches LuisRecognizer intent cannot interrupt current dialog e.g. choice.

Example Code

I modified Node/examples/basics-naturalLanguage code (btw the current code in master branch doesn't work anymore because the luis url returns { "statusCode": 404, "message": "Resource not found" }, I should probably create another issue for this).

var builder = require('../../core/');

// Create bot and bind to console
var connector = new builder.ConsoleConnector().listen();
var bot = new builder.UniversalBot(connector, function (session) {
    session.send("Hi... I'm a bot sample that when I'm asking for a choice I cannot be interrupted by user intent.");
});

// Add global LUIS recognizer to bot
var model = process.env.model || 'https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/b24dac03-c682-4e41-be69-c56513dcd748?subscription-key=76b1f832aa0c4e589bead8241e06aac0';
bot.recognizer(new builder.LuisRecognizer(model));

bot.dialog('/hello', [
    function (session, args, next) {
        builder.Prompts.choice(session, 'what do you want?', 'pizza|whiskey|water')
    },
    function (session, results, next) {
        switch (results.response) {
            case 'pizza':
                session.endDialog('I love pizza as well');
                break;
            case 'whiskey':
                session.endDialog('Which brand do you like?');
                break;
            case 'water':
                session.endDialog('Good taste');
                break;
            default:
                session.endDialog();
                break;
        }
    }
]).triggerAction({
    matches: 'hello',
});

bot.dialog('/bye', [
    function (session, args, next) {
        session.endDialog('see you soon');
    }
]).triggerAction({
    matches: 'bye'
});

Steps to Reproduce

  1. type hi
  2. console shows what do you want? (1. pizza, 2. whiskey, or 3. water)
  3. type bye
  4. console shows I didn't understand. Please choose an option from the list.

Expected Behavior

After typing bye, console should show see you soon.

Actual Results

Console shows I didn't understand. Please choose an option from the list. meaning that even if there's a dialog that matches bye intent in triggerAction, the previous dialog is not interrupted, which is contradictory to another example feature-triggerAction which you can interrupt a flip dialog by typing roll.

Here's a screenshot when I run this example with NODE_DEBUG=botbuilder node app.js:

screen shot 2017-05-26 at 5 59 44 pm

You can see that the console shows that both score for GlobalAction and ActiveDialog are 0.4737741, which are the same as the LUIS intent score. I think ActiveDialog is the builder.Prompts.choice and GlobalAction is the bye dialog. Because both score are the same, therefore WARN: Prompt - no intent handler found for bye is shown in the log and BotBuilder asks the user to choose an option from the list instead of routing to byedialog.

Please compare the previous screenshot with the feature-triggerAction example:

screen shot 2017-05-26 at 6 10 47 pm

This time by using regex as matches of triggerAction, GlobalAction's score is 1 while ActiveDialog's score is 0.1, which makes roll dialog able to interrupt the previous builder.Prompts.choice dialog.

I think ActiveDialog's score is definitely wrong in the first case because it has nothing to do with LUIS and it should not equal to the LUIS score. Please fix this asap because it affects lots of users who use LuisRecoginzer or 3rd party NLP recognizer libraries e.g. botbuilder-wit. Thank you.

customer-replied-to

Most helpful comment

I am experiencing the same problem as described by @josephktcheung. It is a bug in my opinion. The problem first appeared after upgrading to botbuilder v3.8.0. Do you know when a fix will be released?

All 6 comments

The code that causes this issue is this line where Prompt sets its result to context.intent. The interruption works if I change this line from this:

let result: IIntentRecognizerResult = context.intent || { score: 0.0, intent: null };

to this:

let result: IIntentRecognizerResult = { score: 0.0, intent: null };

@Stevenic is there any reason why a prompt needs to use context.intent as IIntentRecognizerResult?

@josephktcheung The reason you're seeing this behavior is because you used a string instead of a regular expression in your /bye dialog triggerAction.

After changing the triggerAction to { matches: /^bye$/ } is works as you would expect.

Working example:

var builder = require('../../core/');

// Create bot and bind to console
var connector = new builder.ConsoleConnector().listen();
var bot = new builder.UniversalBot(connector, function (session) {
    session.send("Hi... I'm a bot sample that when I'm asking for a choice I cannot be interrupted by user intent.");
});

// Add global LUIS recognizer to bot
var model = process.env.model || 'https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/b24dac03-c682-4e41-be69-c56513dcd748?subscription-key=76b1f832aa0c4e589bead8241e06aac0';
bot.recognizer(new builder.LuisRecognizer(model));

bot.dialog('/hello', [
    function (session, args, next) {
        builder.Prompts.choice(session, 'what do you want?', 'pizza|whiskey|water')
    },
    function (session, results, next) {
        switch (results.response) {
            case 'pizza':
                session.endDialog('I love pizza as well');
                break;
            case 'whiskey':
                session.endDialog('Which brand do you like?');
                break;
            case 'water':
                session.endDialog('Good taste');
                break;
            default:
                session.endDialog();
                break;
        }
    }
]).triggerAction({
    matches: 'hello',
});

bot.dialog('/bye', [
    function (session, args, next) {
        session.endDialog('see you soon');
    }
]).triggerAction({ matches: /^bye$/ });

Sorry @nwhitmont I am afraid that you missed my point. What I intended to show is that the app has 2 LUIS intents, hello and bye. When there's an active dialog e.g. waiting for user's input for his choice and user types bye or see you later (which are trained in LUIS as bye intent), botbuilder does not interrupt the active dialog but shows I didn't understand. Please choose an option from the list.. Perhaps it's because I said "type bye" in "steps to reproduce" section and you misinterpreted that I only wanted to match single term bye, but that's not what I meant. I don't want to use regex here, but use intent recognisers like LUIS or botbuilder-wit to return the intent of the user input.

So here's the clarified steps:

  1. type hi (trained in my LUIS model to be recognised as hello intent)
  2. console shows what do you want? (1. pizza, 2. whiskey, or 3. water)
  3. type see you later (trained in my LUIS model to be recognised as bye intent)
  4. console shows I didn't understand. Please choose an option from the list.

Here's the screenshot:
screen shot 2017-06-06 at 4 58 52 pm

According to the documentation, triggerAction can be a named intent, which should be a string like what I showed in the example code, is that correct?

I am experiencing the same problem as described by @josephktcheung. It is a bug in my opinion. The problem first appeared after upgrading to botbuilder v3.8.0. Do you know when a fix will be released?

2859 seems to fix this for me.

Was this page helpful?
0 / 5 - 0 ratings