Skip to content

Instantly share code, notes, and snippets.

@gittimos
Created May 15, 2017 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gittimos/9a4fcbe37d26687526136c2e8cfaa7ea to your computer and use it in GitHub Desktop.
Save gittimos/9a4fcbe37d26687526136c2e8cfaa7ea to your computer and use it in GitHub Desktop.
Using the Watson API with the Node.js SDK
var watson = require('watson-developer-cloud');
// username and password of the service
// see https://www.ibm.com/watson/developercloud/doc/common/getting-started-credentials.html
var conversation = watson.conversation({
username: process.env.WATSON_USERNAME,
password: process.env.WATSON_PASSWORD,
version: 'v1',
version_date: '2017-04-21'
});
var context = {}
conversation.message({
workspace_id: process.env.WATSON_WORKSPACE_ID,
input: {'text': 'SOMETEXT',
context: context
}, function(err, response) {
if (err)
console.log('error:', err);
else
console.log(JSON.stringify(response, null, 2));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment