1
votes

I'm currently taking my first steps into chatbots with the Microsoft Botframework for NodeJS.

I've so far seen 'normal' intents and LUIS.ai intents

Is it possible to combine the two?

I've had an .onDefault intent that wasn't a LUIS one and a LUIS intent but no matter what the input was it always returned the output of the LUIS intent.

Could someone give me a quick example or point me to one?

Thanks in advance

1
Did you go through this - Sunil D S
It's not different from the docs. It also doesn't explain why any input goes straight to the LUIS intent. It's not that my code is different from the docs. - Kyriediculous
The idea of a bot framework is to enable you(a bot designer) to build a bot without having to deal with the complexity of natural language input. For the same reason, you don't receive the text input but instead receive the intent of the text input after Luis identifies it. - Sunil D S
Your job as a bot designer is to implement the function that is executed once the intent is identified. For example, this function handles any text input that Luis identified as 'SearchHotels' - Sunil D S

1 Answers

1
votes

It is possible to combine LUIS intents and normal intents. To do this we'll use two IntentRecognizers; LuisRecognizer and RegExpRecognizer.

let pizzaRecognizer = new builder.LuisRecognizer('YOUR-LUIS-MODEL');
let mathRecognizer = new builder.RegExpRecognizer('MathHelp', /(^mathhelp$|^\/mathhelp$)/i);

Now let's create our IntentDialog and configure its options...

let intents = new builder.IntentDialog({ recognizers: [mathRecognizer, pizzaRecognizer], recognizeOrder: 'series' })

By combining our pizzaRecognizer and mathRecognizer into a list, we can pass this list to our 'recognizers' property so IntentDialog uses both recognizers. The last property we're going to fiddle with is 'recognizerOrder', its default is 'parallel'. By changing the value to 'series', the IntentDialog will now trigger our RegExpRecognizer 'mathRecognizer' first. If a match with a score of 1 exists, the LuisRecognizer will not be used, saving a wasted LUIS endpoint hit.

I would like to reiterate, if you are trying to use RegExpRecognizers to speed up a chatbot's response and reduce the amounts of LUIS calls your chatbot makes, you need to pass in those recognizers first to your recognizers list. Then you need to set your recognizerOrder to 'series'. Without setting your order to series, your chatbot will continue to perform LUIS calls. Also note that any matched intent must have a score of 1.0 to prevent the other recognizers from being employed. To encourage perfect matches, you should use the RegExp quantifiers ^ and $ to define clear start and ending points for your patterns to match against. (See mathRecognizer for an example)

If accuracy is your primary priority, then you should not change the value of 'recognizerOrder', which will then employ all the recognizers at once.

I've built an example here for you to examine. I included the Luis model as well, named LuisModel.json.