【问题标题】:Microsoft Bot Framework: LuisRecognizer Error While Trying to Connect nodeJS with Luis Using Bot Emulator; Cannot Receive Desired MessageMicrosoft Bot Framework:尝试使用 Bot Emulator 将 nodeJS 与 Luis 连接时出现 LuisRecognizer 错误;收不到想要的消息
【发布时间】:2018-12-16 02:26:53
【问题描述】:

我正在尝试使用 Bot Emulator 连接到我的 Luis 应用。

我在 Luis 应用中有一个名为“Greet”的意图,并且正在 Bot Emulator 中对其进行测试。

在我输入训练短语后,机器人模拟器不断回复 Oops there is something went wrong.。

例如,“问候”意图中的“嗨”。

请告诉我我做错了什么。非常感谢!

下图是Bot Emulator和终端返回错误信息的截图。

机器人模拟器显示“糟糕,出了点问题,我们需要在我说“你好”后重新开始。

Cache 在request._callback 和self._callback 给出了错误消息:

以下是我的 NodeJS 代码(我在本地的代码中有我的 LuisAPIKey 和 LuisAppId,这里我删除了它们):

var restify = require('restify');
var builder = require('botbuilder');
var server = restify.createServer();

server.listen(process.env.port || process.env.PORT || 3987, function () {
     console.log('%s listening to %s', server.name, server.url); 
});
var connector = new builder.ChatConnector();

server.post('/api/messages', connector.listen());

var bot = new builder.UniversalBot(connector);

var luisAppId = '';
var luisAPIKey = '';
var luisAPIHostName = 'https://westus.api.cognitive.microsoft.com';

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

var recognizer = new builder.LuisRecognizer(luisModelUrl);
var intents = new builder.IntentDialog({
    recognizers: [recognizer]
})

bot.dialog('/', intents);

intents.matches('Greet', (session) =>{
    session.send("Hello there! How can I help you today?");
})
.onDefault((session, args, next) => {
    console.log(args);
    session.send("Sorry, I did not understand.");
})

【问题讨论】:

    标签: node.js botframework bots azure-language-understanding


    【解决方案1】:

    您的错误信息似乎没有完整输出,我重现了您的问题,错误信息应该是:

    Error: { "statusCode": 404, "message": "Resource not found" }
    UniversalBot.js:548
        at Request._callback (c:\WorkSpace\bot framework\nodejs test\node_modules\botbuilder\lib\dialogs\LuisRecognizer.js:101:31)
        at Request.self.callback (c:\WorkSpace\bot framework\nodejs test\node_modules\request\request.js:185:22)
        at Request.emit (events.js:180:13)
        at Request.emit (domain.js:421:20)
        at Request.<anonymous> (c:\WorkSpace\bot framework\nodejs test\node_modules\request\request.js:1157:10)
        at Request.emit (events.js:180:13)
        at Request.emit (domain.js:421:20)
        at IncomingMessage.<anonymous> (c:\WorkSpace\bot framework\nodejs test\node_modules\request\request.js:1079:12)
        at Object.onceWrapper (events.js:272:13)
        at IncomingMessage.emit (events.js:185:15)
    / - ERROR: { "statusCode": 404, "message": "Resource not found" }
    

    因此,根本情况是,您以不正确的格式编造了 LUIS URL。你在/luis/v2.0/apps之后错过了\, 请修改为:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-29
      • 2020-06-04
      • 1970-01-01
      • 1970-01-01
      • 2017-11-01
      相关资源
      最近更新 更多