azure - 如何为特定的 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 推送瀑布对话框吗?你们能帮帮我吗?
解决方案
尝试使用 session.replaceDialog 而不是 context.beginDialog 并且无需返回等待,只需按照链接中的示例进行操作:
编辑:
你也可以检查
关于如何对 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'
})
推荐阅读
- python - 使用任何 python 库从宏 excel 调用中获取单元格值到另一个工作表
- javascript - 后台切换分两部分
- reactjs - 在 axios.post 之后属性保持未定义
- reactjs - 由于 Typescript 枚举,Next.js 在 Safari 中呈现空白屏幕
- python - Django - MongoDb - GraphQL 查询返回一个空数组
- datepicker - Nativescript RadDataForm DatePicker 编辑器将样式更改为轮子
- amazon-web-services - 当主体设置为 aws lambda.amazonaws.com 时访问被拒绝
- json - Serilog 不解析文件名模板
- android - 颤振 - “无法找到 Android SDK。”
- java - Selenium 从日期选择器中选择第一个和最后一个活动日期