Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

askwatson

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

askwatson

Ask IBM Watson a question on Bluemix

  • 1.0.11
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

This module is in npm as askwatson. It provides a simple API for asking Watson a question on Bluemix using the question_and_answer service.

Basically you will need to get set up on Bluemix/CF and follow the instructions given for the sample Node.js application here https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/qaapi/#commonApplication, including running the cf commands, but I have factored out that code a bit into two modules, so your application can be cleaner. In case you need help finding the cf command line program you can download it from here https://github.com/cloudfoundry/cli/releases (under Installers) and install it with dpkg -i <filename>.

The first module is called bluemix-request-simple and it has the parts for pulling the host and port out of the environment and using them in a request.

The other module is this one, which is very simple to use:

watson.ask('healthcare', 'What is the most common kind of cancer', function(err, answers) {
  console.log(answers);
});

This will need to run on Bluemix so a more complete example would be:

var watson = require('askwatson')
  , restify = require('restify');

var server = restify.createServer();

server.get('/:domain/:question', function(req, res) {
  watson.ask(req.params.domain, req.params.question, function(e, ans) {
    res.send(ans);
  });    
});

server.listen(process.env.VCAP_APP_PORT, process.env.VCAP_APP_HOST, function() {
  console.log('%s listening at %s', server.name, server.url);
});

Note that if you use GET as in this example it will be simpler to test but you can only use short questions (try curl "http://whatever.mybluemix.net/healthcare/What+is+the+most+common+kind+of+cancer"). If you use something longer for the question it will blow up the app, so you will probably want to use POST.

Keywords

FAQs

Package last updated on 27 Dec 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc