triggerAction which matches LuisRecognizer intent cannot interrupt current dialog e.g. choice.
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'
});
hiwhat do you want? (1. pizza, 2. whiskey, or 3. water)byeI didn't understand. Please choose an option from the list.After typing bye, console should show see you soon.
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:

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:

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.
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:
hi (trained in my LUIS model to be recognised as hello intent)what do you want? (1. pizza, 2. whiskey, or 3. water)see you later (trained in my LUIS model to be recognised as bye intent)I didn't understand. Please choose an option from the list.Here's the screenshot:

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?
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?