我正在尝试使用Bot Emulator连接到我的Luis应用。
我在Luis应用程序中有一个名为“ Greet”的意图,并且正在Bot仿真器中对其进行测试。
在我输入训练短语后,机器人模拟器不断回复Oops there is something went wrong.
。
例如,“ Greet”意图中的“ Hi”。
请告诉我我做错了。非常感谢你!
以下图片是Bot仿真器和终端返回错误消息的屏幕截图。
Bot Emulator显示“糟糕,出现了问题,我们需要在我说” Hello”之后重新开始:
缓存在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.");
})
答案 0 :(得分:2)
您的错误消息似乎没有完全输出,我重现了您的问题,错误消息应该是:
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;