首页 > 解决方案 > 如何为特定的 LUIS 意图 beginDialog?

问题描述

这是我的代码:

 async dispatchToTopIntentAsync(context, intent, recognizerResult) {
         console.log(context);
         switch (intent) {
             case 'INeedInsurance':{ 
                 const bookingDetails={};
                  bookingDetails.type="Auto"; 
                return await context.beginDialog(ConfirmAuto)

             }

             default:
                 console.log(`Dispatch unrecognized intent: ${ intent }.`);
                 await context.sendActivity(`Dispatch unrecognized intent: ${ intent }.`);
                 // await next();
                 break;
         } 
     }

我需要根据 LUIS Intent Result 推送瀑布对话框吗?你们能帮帮我吗?

标签: azureandroid-intentbotframeworkazure-language-understanding

解决方案


尝试使用 session.replaceDialog 而不是 context.beginDialog 并且无需返回等待,只需按照链接中的示例进行操作:

https://docs.microsoft.com/en-us/azure/bot-service/nodejs/bot-builder-nodejs-dialog-replace?view=azure-bot-service-3.0

编辑:

你也可以检查

https://docs.microsoft.com/en-us/azure/bot-service/nodejs/bot-builder-nodejs-recognize-intent-luis?view=azure-bot-service-3.0

关于如何对 LUIS 意图做出反应?更确切地说

// Make sure you add code to validate these fields
var luisAppId = process.env.LuisAppId;
var luisAPIKey = process.env.LuisAPIKey;
var luisAPIHostName = process.env.LuisAPIHostName || 'westus.api.cognitive.microsoft.com';

const LuisModelUrl = 'https://' + luisAPIHostName + '/luis/v2.0/apps/' + luisAppId + '?subscription-key=' + luisAPIKey;

// Create a recognizer that gets intents from LUIS, and add it to the bot
var recognizer = new builder.LuisRecognizer(LuisModelUrl);
bot.recognizer(recognizer);

// Add a dialog for each intent that the LUIS app recognizes.
// See https://docs.microsoft.com/bot-framework/nodejs/bot-builder-nodejs-recognize-intent-luis 
bot.dialog('GreetingDialog',
    (session) => {
        session.send('You reached the Greeting intent. You said \'%s\'.', session.message.text);
        session.endDialog();
    }
).triggerAction({
    matches: 'Greeting'
})

bot.dialog('HelpDialog',
    (session) => {
        session.send('You reached the Help intent. You said \'%s\'.', session.message.text);
        session.endDialog();
    }
).triggerAction({
    matches: 'Help'
})

bot.dialog('CancelDialog',
    (session) => {
        session.send('You reached the Cancel intent. You said \'%s\'.', session.message.text);
        session.endDialog();
    }
).triggerAction({
    matches: 'Cancel'
}) 

推荐阅读