【问题标题】:botbuilder LuisRecognizer not working behind proxybotbuilder LuisRecognizer 不在代理后面工作
【发布时间】: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 工作得非常好,返回正确的意图,在浏览器中进行了测试。

如何调试?

【问题讨论】:

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


【解决方案1】:
import globalTunnel from 'global-tunnel';

process.env.http_proxy = 'http://proxy:80';
process.env.https_proxy = 'http://proxy:80';
globalTunnel.initialize();

在添加识别器bot.recognizer(recognizer)后添加globalTunnel.end()

成功了。

【讨论】:

    猜你喜欢
    • 2017-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-07
    相关资源
    最近更新 更多