I have replace the doctor.js to integrate conversation service instead of Q&A with following content and deployment was successful. But when I call to my Twillio number it says there is application error. I don't see any error in the bluemix log. What would be the issue.
doctor-watson-milroy-1232.mybluemix.net - [08/03/2017:03:26:18.060 +0000] "POST /calls HTTP/1.1" 403 461 33 "-" "TwilioProxy/1.1" 192.155.237.119:58081 x_forwarded_for:"52.71.186.66" x_forwarded_proto:"https" vcap_request_id:911980a4-5895-43ce-7699-8efaa8b8daa4 response_time:0.039229273 app_id:30f1cc31-f2f5-4fcd-8031-786ed88a4930 x_global_transaction_id:"208812065"
doctor.js
var watson = require("watson-developer-cloud"),
log = require("loglevel"),
cfenv = require("cfenv");
/*
var service = cfenv.getAppEnv().getService('question_and_answer')
var question_and_answer_healthcare = watson.question_and_answer({
username: service.credentials.username,
password: service.credentials.password,
version: 'v1',
dataset: 'healthcare'
})
*/
var ConversationV1 = require('watson-developer-cloud/conversation/v1');
var conversation = new ConversationV1({
username: "xxxxxxx",
password: "xxxx",
version_date: "2016-10-21"
});
/*
exports.ask = function (question, cb) {
question_and_answer_healthcare.ask({ text: question}, function (err, response) {
if (err || !response[0].question.evidencelist) {
log.error(err)
cb("Unfortunately, I'm unable to answer your question.")
return
}
cb(response[0].question.evidencelist[0].text)
})
}
*/
var updateMessage = (input, response) => {
var responseText = null;
if (!response.output) {
response.output = {};
} else {
return response;
}
if (response.intents && response.intents[0]) {
var intent = response.intents[0];
// Depending on the confidence of the response the app can return different messages.
// The confidence will vary depending on how well the system is trained. The service will always try to assign
// a class/intent to the input. If the confidence is low, then it suggests the service is unsure of the
// user's intent . In these cases it is usually best to return a disambiguation message
// ('I did not understand your intent, please rephrase your question', etc..)
if (intent.confidence >= 0.75) {
responseText = "I understood your intent was " + intent.intent;
} else if (intent.confidence >= 0.5) {
responseText = "I think your intent was " + intent.intent;
} else {
responseText = "I did not understand your intent";
}
}
response.output.text = responseText;
return response;
};
exports.ask = function (question, cb) {
var workspace = "xxx";
var payload = {
workspace_id: workspace,
context: question.body.context || {},
input: question.body.input || {}
};
// Send the input to the conversation service
conversation.message(payload, (error, data) => {
if (error) {
return error;
}
return cb.json(updateMessage(payload, data));
});
};