Skip to content

Commit 06cdb2e

Browse files
committed
docs(readme): add assistant v2 example to readme
1 parent 4324e9f commit 06cdb2e

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ Node.js client library to use the Watson APIs.
2727
* [Questions](#questions)
2828
* [IBM Watson services](#ibm-watson-services)
2929
* [Authorization](#authorization)
30-
* [Assistant](#assistant)
30+
* [Assistant v2](#assistant-v2)
31+
* [Assistant v1](#assistant-v1)
3132
* [Discovery](#discovery)
3233
* [Language Translator v3](#language-translator-v3)
3334
* [Language Translator v2](#language-translator-v2)
@@ -279,7 +280,39 @@ function (err, token) {
279280
});
280281
```
281282

282-
### Assistant
283+
### Assistant v2
284+
285+
Use the [Assistant][conversation] service to determine the intent of a message.
286+
287+
Note: You must first create a workspace via IBM Cloud. See [the documentation](https://console.bluemix.net/docs/services/conversation/index.html#about) for details.
288+
289+
```js
290+
var AssistantV1 = require('watson-developer-cloud/assistant/v1');
291+
292+
var assistant = new AssistantV2({
293+
username: '<username>',
294+
password: '<password>',
295+
url: 'https://gateway.watsonplatform.net/assistant/api/',
296+
version: '2018-09-19'
297+
});
298+
299+
assistant.message(
300+
{
301+
input: { text: "What's the weather?" },
302+
assistant_id: '<assistant id>',
303+
session_id: '<session id>',
304+
},
305+
function(err, response) {
306+
if (err) {
307+
console.error(err);
308+
} else {
309+
console.log(JSON.stringify(response, null, 2));
310+
}
311+
}
312+
);
313+
```
314+
315+
### Assistant v1
283316

284317
Use the [Assistant][conversation] service to determine the intent of a message.
285318

0 commit comments

Comments
 (0)