Git Product home page Git Product logo

doctor-watson's Introduction

Doctor Watson

BlueMix application using Watson Cloud Services with Twilio to create your own doctor on the phone.

This demo app doesn't work due to the deprecation of the IBM Watson Q & A API. We've leaving the code up as a reference on integration Twilio with IBM Watson services.

Bluemix button

js-standard-style

Setting up on Bluemx

Pushing this application to Bluemix will allow you to run your own version of Doctor Watson. The following services need to be available, the application will automatically bind to them at runtime...

Service (service identifier)

  • Twilio (twilio)
  • Watson Speech To Text (speech_to_text)
  • Watson Q&A API (question_and_answer)

Once these services are availble, the following command line will start your new version of Doctor Watson running.

$ cf push your_app_name

When the deployment has finished, your application will be available at your_app_name.mybluemix.net

Setting up Twilio

Once the application has ben deployed, you need to register the API endpoints with Twilio. Using the Twilio configuration page, set the sample phone number "Request URL" to HTTP POST incoming requests to http://your_app_name.mybluemix.net/calls for Voice and http://your_app_name.mybluemix.net/sms for Messaging

Running locally

Running the application on your local machine for development is supported. Ensure you the VCAP_SERVICES environment variable set with the credential details from the remote environment.

$ node app.js

doctor-watson's People

Contributors

germanattanasio avatar jsloyer avatar jthomas avatar maqnouch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

doctor-watson's Issues

Handle Watson service returning no answers

2015-04-16T13:11:47.12+0100 [App/0] ERR /home/vcap/app/lib/doctor.js:22
2015-04-16T13:11:47.12+0100 [App/0] ERR cb(response[0].question.evidencelist[0].text);
2015-04-16T13:11:47.12+0100 [App/0] ERR ^
2015-04-16T13:11:47.12+0100 [App/0] ERR TypeError: Cannot read property '0' of undefined
2015-04-16T13:11:47.12+0100 [App/0] ERR at /home/vcap/app/lib/doctor.js:22:43
2015-04-16T13:11:47.12+0100 [App/0] ERR at Request._callback (/home/vcap/app/node_modules/watson-developer-cloud/lib/requestwrapper.js:68:5)
2015-04-16T13:11:47.12+0100 [App/0] ERR at Request.self.callback (/home/vcap/app/node_modules/request/request.js:344:22)
2015-04-16T13:11:47.12+0100 [App/0] ERR at Request.emit (events.js:110:17)
2015-04-16T13:11:47.12+0100 [App/0] ERR at Request. (/home/vcap/app/node_modules/request/request.js:1239:14)
2015-04-16T13:11:47.12+0100 [App/0] ERR at Request.emit (events.js:129:20)
2015-04-16T13:11:47.12+0100 [App/0] ERR at IncomingMessage. (/home/vcap/app/node_modules/request/request.js:1187:12)
2015-04-16T13:11:47.12+0100 [App/0] ERR at IncomingMessage.emit (events.js:129:20)
2015-04-16T13:11:47.12+0100 [App/0] ERR at _stream_readable.js:908:16
2015-04-16T13:11:47.12+0100 [App/0] ERR at process._tickCallback (node.js:355:11)

Integrate Conversation instead of Q&A

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

};

Can't deploy to Bluemix

Clicking the 'Deploy to Bluemix' button fails at the 'Repository cloning' step.

The underlying cause appears to be the Twilio service:

{
  "code": 10001,
  "description": "Service broker error: This service cannot be created via the CLI.  Create this service using the Bluemix console.",
  "error_code": "CF-ServiceBrokerBadResponse",
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.