Microsoft Bot Framework with LUIS not detecting all intents

非 Y 不嫁゛ 提交于 2019-12-25 05:09:35

问题


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.

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:


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.



来源:https://stackoverflow.com/questions/43593728/microsoft-bot-framework-with-luis-not-detecting-all-intents

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!