Botbuilder-samples: Embed LUIS inside a Dialog

Created on 29 Nov 2017  路  6Comments  路  Source: microsoft/BotBuilder-Samples

SDK Platform


Node SDK

URL of Code Sample


https://github.com/Microsoft/BotBuilder-Samples/blob/master/Node/demo-ContosoFlowers/bot/dialogs/shop.js

Problem Description

No reference on how to embed LUIS inside a Dialog

i.e.
lib.dialog('who-is', [
function (session, args, next) {
// Resolve and store any Note.Title entity passed from LUIS.
var intent = args.intent;
var title = builder.EntityRecognizer.findEntity(intent.entities, 'Note.Title');

LUIS question

Most helpful comment

builder.Prompts.choice(session, 'what do you want?', 'pizza|whiskey|water');

I'll take a whiskey please 馃憤

All 6 comments

Hi @daveRendon

The sample you've referenced is not a LUIS sample. There are some references to LUIS in the readme: https://github.com/Microsoft/BotBuilder-Samples/tree/master/Node/demo-ContosoFlowers#more-advanced-features This document also provides more information: https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-recognize-intent-luis

You pretty much need to embed something like this in your dialog

function (err, intents, entities) {
     switch (intents[0]) {
       case 'HelpIntent':
          session.send('You\'ve triggered the help intent.');
          session.beginDialog('HelpIntent');
          break;
       default:
          session.send('What?');
          session.beginDialog('/');
     }
}

Thanks for your quick response @EricDahlvang @JasonSowers

I read that "The key thing here is creating an IntentDialog with a LuisRecognizer, and bind the Actions array to the bot and dialog using the bindToBotDialog helper function." However there are no explicit references at all around LUIS binding using bot in Node.JS, i.e.

lib.dialog('/', [
function (session, args, next) {
builder.Prompts.choice(session, 'what do you want?', 'pizza|whiskey|water');
},

Will take a look around your advise, thank you Gentlemen!

builder.Prompts.choice(session, 'what do you want?', 'pizza|whiskey|water');

I'll take a whiskey please 馃憤

Thank you Gentlemen! @EricDahlvang @JasonSowers

I followed your recommendations and was able to do some little testing as follows:
var intentDialog = new builder.IntentDialog({ recognizers: [recognizer, qnarecognizer] });
lib.dialog('/', intentDialog);
intentDialog.matches('who-is-who', builder.DialogAction.send('Inside Intent1''));
intentDialog.matches('expertise-lookup', builder.DialogAction.send('Inside Intent 2.'));
intentDialog.matches('ticket-status', builder.DialogAction.send('Inside Intent 3.'));

intentDialog.onDefault([
function(session){
session.send('Sorry!! No match!!');
}
]);

intentDialog.matches('qna', [
function (session, args, next) {
var answerEntity = builder.EntityRecognizer.findEntity(args.entities, 'answer');
session.send(answerEntity.entity);
}
]);

Now I麓m able to detect LUIS & QnA, appreciate your support, THANKS!

@daveRendon We are glad you've got it working!

Was this page helpful?
0 / 5 - 0 ratings