【发布时间】:2018-01-09 15:11:44
【问题描述】:
我写了一个自定义识别器。
bot.recognizer({
recognize: function (context, done) {
var intent = { score: 1.0, intent: 'Greetings'};
if (context.message.text.toLowerCase() == 'hello' ) {
done(null, intent);
}
}
});
var bot = new builder.UniversalBot(connector, (session) => {
session.send("Sorry couldn't understand");
});
// here is the dialog
bot.dialog('Greetings', [(session, args, next) => {
sesson.send("hey there");
}]).triggerAction({
matches: 'Greetings',
onInterrupted: function (session) {
session.send('hey there');
}
});
当我在模拟器中输入“Hello”时,它会回复hey there。有用。
但是当我尝试使用 Luis API 时它不起作用。回复"Sorry couldn't understand".
const model = "https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/**?subscription-key=***&verbose=true";
var recognizer = new builder.LuisRecognizer(model);
bot.recognizer(recognizer)
我在终端(节点>)中尝试了以下操作,但它不起作用。 here is the doc I followed
var builder = require('botbuilder');
var model = "https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/***?subscription-key=***&verbose=true&timezoneOffset=330&spellCheck=false";
var recognizer = new builder.LuisRecognizer(model);
recognizer.recognize(
"hello",
model,
function (err, intents, entities) {
console.log(intents);
}
)
Luis Model url 工作得非常好,返回正确的意图,在浏览器中进行了测试。
如何调试?
【问题讨论】:
-
不确定“它不起作用”是什么意思。请提供有关错误的详细信息、您的 luis 模型、您是否训练并发布了它等。
-
是的,我做到了。代理在这里会是个问题吗?
-
我发现问题是由于代理,更新了问题标题。我可以使用npmjs.com/package/global-tunnel 解决它
标签: node.js bots botframework azure-language-understanding