Created
February 7, 2015 21:38
-
-
Save tankcdr/82e841a77514708bae75 to your computer and use it in GitHub Desktop.
watson-developer-cloud and restify question answer service example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
var wdc = require('watson-developer-cloud-alpha'), | |
restify = require('restify'), | |
server = restify.createServer(), | |
question_and_answer_travel = wdc.question_and_answer({ | |
username: '[user name]', | |
password: '[password]', | |
version: 'v1', | |
dataset: 'travel' | |
}) | |
server.use(restify.fullResponse()) | |
.use(restify.bodyParser()) | |
server.post('/travel/ask', function(req,res,next) { | |
var options = { | |
text: req.params.question | |
} | |
question_and_answer_travel.ask(options, function (err, response) { | |
if (err) | |
res.send(500,err) | |
else | |
res.send(200,response) | |
return res.next(); | |
}) | |
}) | |
server.listen(8080,function() { | |
console.log('Travel service listening on '+server.url) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment