2017-08-02 71 views
0

我寫了一個自定義識別器。botbuilder LuisRecognizer不在代理後面工作

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); 
    } 
) 

的路易斯模型的網址工作完全正常,返回正確的意圖,在瀏覽器中進行了測試。

如何調試?

+1

不確定「不起作用」的含義。請提供有關錯誤的詳細信息,您的luis模型,是否經過培訓併發布等等。 –

+0

您是否瀏覽過https://github.com/Microsoft/BotBuilder-Samples/blob/master/Node/intelligence-LUIS/? –

+0

是的,我做到了。在這裏可以代理是一個問題? – chandan

回答

0
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()

+0

解決它你能接受你的答案,所以它被標記爲已回答?謝謝 :) –