将 LUIS 连接到 Microsoft Bot Framework

Connecting LUIS to Microsoft Bot Framework

在假期周末,我一直在尝试让机器人使用 Microsoft Bot Framework 工作。我正在为 Node.js 使用 3.9.1 版的 botbuilder 包。

我在 www.luis.ai 创建了一个应用程序和模型。我已经能够通过 "Train & Test" 功能成功测试我的意图。然后,在我的实际节点代码中,我有以下内容:

let connector = new BotBuilder.ChatConnector({ 
  appId: 'myId', 
  appPassword: 'myAppSecret'
});

let bot = new BotBuilder.UniversalBot(connector);
let luis = new BotBuilder.LuisRecognizer('myLuisAppUrl');

let intent = new BotBuilder.IntentDialog({ });
intent.recognizer(luis);                

intent.matches('Intent.1', '/execute-report');
intent.matches('Intent.2', '/execute-batch-job');
intent.onDefault('/unknown');

bot.dialog('/', intent);

bot.dialog('/execute-report', [function(session, args, next) {
  var result = ((Date.now() % 2) === 0) ? 'Report Ran!' : 'Failed';                        
  session.send(result);
}]);

bot.dialog('/execute-batch-job', [function(session, args, next) {
  var result = ((Date.now() % 2) === 0) ? 'Batch Job Ran!' : 'Unable to run Batch Job';
  session.send(result);
}]);

bot.dialog('/unknown', [function(session, args, next) {
  session.send('What did you ask for?');
}]);

与我的机器人交互时,我总是得到 "What did you ask for?"。换句话说,在这一点上,我知道:

  1. 我可以成功地与我的机器人交互。但是,/unknown 对话框总是被调用,这不是正确的交互。
  2. 我在 LUIS 中的模型看起来正确:

    一个。如果我在 LUIS.ai 测试应用程序中输入 "Run Report",得分最高的意图是 "Intent.1"

    b。如果我在 LUIS.ai 测试应用程序中输入 "Execute Batch Job",得分最高的意图是 "Intent.2"

但是,我的机器人没有发送适当的响应。 /execute-report/execute-batch-job 对话框从未被使用过,尽管它们应该被使用。我不明白我做错了什么。对我来说,我相信我已经正确设置了我的机器人。我不明白我做错了什么。有人可以告诉我我做错了什么吗?有没有办法在我的节点代码中查看从 LUIS 返回的响应,类似于在 LUIS.ai

的 "Test" 应用程序中看到的响应

如果转到 LuisRecognizer 的第 89 行并在新行中添加以下内容:console.log(result); 您将看到机器人收到的 LUIS 响应对象。

我认为你的代码是正确的,所以问题可能出在 LUIS 方面。你发布了你的应用程序吗?