1
votes

I'm creating a chatbot using the MS Bot Framework with LUIS in node js. I have created a couple of intents called "Book" and "Pending" and an entity called "Annual Leave" in LUIS. I have added the LUIS URL to my chatbot code and when I test it in my console, I see that certain utterances get a response while some don't.

For example when I say "How do I check my remaining annual leave?", I get a response saying "You can find your remaining A/L here". But when I say "How can I check my pending annual leave?", I get no reply.

My Git Bash response for the working utterance

ChatConnector: message received.

session.beginDialog(/)

/ - session.sendBatch() sending 0 messages

/ - IntentDialog.matches(Pending)

/ - waterfall() step 1 of 1

/ - session.beginDialog(BotBuilder:Prompts)

.Prompts.text - session.send()

.Prompts.text - session.sendBatch() sending 1 messages

My Git Bash response for the non-working utterance

ChatConnector: message received.

.Prompts.text - session.endDialogWithResult()

/ - session.endDialogWithResult()

session.sendBatch() sending 0 messages

But when I test the exact same utterances on LUIS, it detects the intent and entity with a high confidence score.

enter image description here

This is happening with a lot of utterances. I can't figure out what's causing this issue.

My Chatbot code

var restify = require('restify');
var builder = require('botbuilder');

//=========================================================
// Bot Setup
//=========================================================

// Setup Restify Server
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
   console.log('%s listening to %s', server.name, server.url); 
});
  
// Create chat bot
var connector = new builder.ChatConnector({
    appId: 'MY_APP_ID',
    appPassword: 'MY_APP_PASSWORD'
});
var bot = new builder.UniversalBot(connector);
server.post('/api/messages', connector.listen());

server.get('/', restify.serveStatic({
 directory: __dirname,
 default: '/index.html'
}));


//=========================================================
// Bots Dialogs
//=========================================================
    
var recognizer = new builder.LuisRecognizer('MY_LUIS_URL');
var intents = new builder.IntentDialog({ recognizers: [recognizer] });
bot.dialog('/', intents);
   

intents.matches('Book', [
    function (session, args, next) {
       var task = builder.EntityRecognizer.findEntity(args.entities, 'Annual Leave');
                  builder.Prompts.text(session, "You can book your A/L here.");  
    }
]),

intents.matches('Pending', [
    function (session, args, next) {
        var task = builder.EntityRecognizer.findEntity(args.entities, 'Annual Leave');
                  builder.Prompts.text(session, "You can find your remaining A/L here.");
       
    }
]);
1
Hi Anish, have you retrained and updated your models recently? (Or at least after your example utterances?)Steven G.
Hi @StevenG., I've trained them after my example utterances and I've trained them again now and the examples I provided above work now but certain new utterances are not. For example, I say 'I want to find out how much leave I have left' and I get no response but LUIS gets it right with 0.95 confidence. I have already trained it with about 30 utterances. Should I be training it with every single possibility?Anish
Hmm, LUIS is... not intelligent starting off, but you shouldn't have to be training it with every single possibility. I should have asked you this in my initial comment, but you've republished your model, correct?Steven G.
Yes, republished every time i train it. So what's the approach i should be taking here then? Train it with every failed utterance i come across? Or will LUIS eventually learn?Anish
Please see Pavel's answer below; I believe he is right on target with the second point. I'm guessing that talking to your bot it will recognize the first utterance and then after that not work? That's because you're not calling session.endDialog() or session.endConversation(). Without these your bot becomes stuck on its current dialog.Steven G.

1 Answers

2
votes

First, I suggest that you add the intents.onDefault() dialog so you had a fallback for None intent. This way you will know if it's LUIS not recognizing the intent, or if it's something else.

Second, I would explicitly end dialogs if you are using the IntentDialog. When you do builder.Prompts.text(), the bot framework will push a special Prompts dialog on stack and would wait for the answer to pass it to the next in your waterfall that is not there. I am wondering if that's what you're experiencing. Try replacing your Prompts.text(message) with session.endDialog(message).

Last, consider using the new triggerAction syntax. I explained some of it here: http://www.pveller.com/smarter-conversations-part-2-open-dialogs/#Trigger-Actions

p.s. you can also debug your bot. I am big fan of VS Code and it's as easy as setting breakpoints in the botbuilder sources in your node_modules to see what's going on, how the user utterances are recognized, and routed.