diff --git a/examples/tone_analyzer.v3.js b/examples/tone_analyzer.v3.js index b5777f9a40..e2dc5f61ef 100644 --- a/examples/tone_analyzer.v3.js +++ b/examples/tone_analyzer.v3.js @@ -17,23 +17,24 @@ tone_analyzer.tone({ text: 'Greetings from Watson Developer Cloud!' }, function( } }); -const utterances = { - utterances: [ - { text: 'My charger isn’t working.', user: 'customer' }, - { text: 'Thanks for reaching out. Can you give me some more detail about the issue?', user: 'agent' }, - { - text: "I put my charger in my phone last night to charge and it isn't working. Which is ridiculous, it's a new charger, I bought it yesterday.", - user: 'customer' - }, - { text: 'I’m sorry you’re having issues with charging. What kind of charger do you have?', user: 'agent' } - ] -}; - -tone_analyzer.tone_chat({ utterances: utterances }, function(err, tone) { - if (err) { - console.log(err); - } else { - console.log('tone_chat endpoint:'); - console.log(JSON.stringify(tone, null, 2)); +tone_analyzer.tone_chat( + { + utterances: [ + { text: 'My charger isn’t working.', user: 'customer' }, + { text: 'Thanks for reaching out. Can you give me some more detail about the issue?', user: 'agent' }, + { + text: "I put my charger in my phone last night to charge and it isn't working. Which is ridiculous, it's a new charger, I bought it yesterday.", + user: 'customer' + }, + { text: 'I’m sorry you’re having issues with charging. What kind of charger do you have?', user: 'agent' } + ] + }, + function(err, tone) { + if (err) { + console.log(err); + } else { + console.log('tone_chat endpoint:'); + console.log(JSON.stringify(tone, null, 2)); + } } -}); +); diff --git a/package.json b/package.json index c6fb0e086f..826d06f175 100644 --- a/package.json +++ b/package.json @@ -119,4 +119,4 @@ "minify": "uglifyjs --compress --mangle --screw-ie8 dist/watson.js --output dist/watson.min.js --preamble \"// Watson Developer Cloud\n// JavaScript SDK$npm_package_version\n// Generated at `date`\n// Copyright IBM ($npm_package_license)\n// $npm_package_homepage\"", "build": "npm run browserify && npm run minify" } -} +} \ No newline at end of file diff --git a/tone-analyzer/v3.js b/tone-analyzer/v3.js index a88d61cc7a..6246b2d2f7 100644 --- a/tone-analyzer/v3.js +++ b/tone-analyzer/v3.js @@ -106,7 +106,8 @@ ToneAnalyzerV3.prototype.tone_chat = function(params, callback) { options: { url: '/v3/tone_chat', method: 'POST', - body: JSON.stringify(params.utterances) + json: true, + body: pick(params, ['utterances']) }, defaultOptions: extend(true, this._options, { headers: {