I have a QnA bot and a LUIS bot. I would like to make a post request inside my LUIS dialog when the dialog for QnA is triggered to get a response. I have it testing just with the question: Hi which should respond hello.
I am not sure if my port is correct because I got it from another stackoverflow question that is similar so that might be where my error is. I have tried without any port as well.
When I ask questions I get the error: Error: read ECONNRESET
I am running this on Azure Bot Service which I suspect could be a reason for this peticular error.
Here is my code:
var request = require('request');
var http = require('http');
var options = {
host:'westus.api.cognitive.microsoft.com',
path:'/qnamaker/v2.0/knowledgebases/<kb-key>/generateAnswer',
port:443,
method:'POST',
headers:{
'Ocp-Apim-Subscription-Key':<sub-key>,
'Content-Type':'application/json'
}
};
//http POST request
var reqPost = http.request(options,function(res){
res.setEncoding('utf-8');
var responseString = '';
res.on('data',function(chunk){
responseString += chunk;
});
res.on('end', function () {
session.send(responseString);
});
});
//LUIS dialog when question is asked.
bot.dialog('qnaReq', function (session, args) {
//call QnA Bot and ask that bot the question
reqPost.write({"question":"hi"}); //Just testing "hi" for now.
reqPost.end();
reqPost.on('error',function(e){
session.send('error: ' + e);
});
}).triggerAction({
matches: 'QnA'
});