Multiple LUIS Mode Parent Child relationship
I trying to make bot that uses multiple LUIS models. I have designed my models in such a way that parent do the simple classification on input and on the basis of that sentence is further classified by child LUIS model. Here is my code :
var bot = new builder.UniversalBot(chatConnector);
var parentNlpModel = <parent luis model>;
var parentRecognizer = new builder.LuisRecognizer(parentNlpModel);
var parentIntent = new builder.IntentDialog({ recognizers: [parentRecognizer] });
var newsReporterNlpModel = <child luis model>;
var newsReporterRecognizer = new builder.LuisRecognizer(newsReporterNlpModel);
var newsReporterIntent = new builder.IntentDialog({ recognizers: [newsReporterRecognizer] });
bot.dialog('/', parentIntent);
parentIntent.matches('greeting', function (session) { greeting(session, builder) });
parentIntent.matches('newsReporter', function (session) { session.beginDialog('/newsReporter')});
parentIntent.onDefault(builder.DialogAction.send("I am not saying anything about this !!"));
bot.dialog('/newsReporter', newsReporterIntent);
newsReporterIntent.matches('weather', function (session) { session.send("Hi..") });
newsReporterIntent.onDefault(builder.DialogAction.send("I am not saying anything about thiss !!"));
First classication done correctly. But next classification is not giving any response. How to achive my usecase , Is this a correct way ?
Have you tried
var newsReporterIntent = new builder.IntentDialog({ recognizeMode: builder.RecognizeMode.onBegin, recognizers: [newsReporterRecognizer] });
Otherwise the newsReporterIntent will not automatically try to handle the sentence that triggered that dialog.
Here's a reference to that option.
The other thing you could do is create a new recognizer that aggregates both models and flattens them out:
var parentModel = new builder.LuisRecognizer('<model>');
var childModel = new builder.LuisRecognizer('<model>');
var myRecognizer = {
recognize: function (context, done) {
parentModel.recognize(context, function (err, intent) {
if (!err) {
switch (intent.intent) {
case 'ChildIntent':
childModel.recognize(context, done);
break;
default:
done(null, intent);
break;
}
} else {
done(err, null);
}
});
}
};
Closing since answered and no activity. If you have a further issue, please let us know.