Skip to content

Commit 1cef7a2

Browse files
authored
Adds assistant service (#660)
* feat(assistant): assistant service added with unit tests * test(assistant tests): updates version date for integration tests * test(assistant): adds integration test for assistant. also updates checking for environment variable * ci(travis): updates travis credentials * test(conversation tests): removed nullcheck on removed field * test(assistant tests): added unit tests verifying credentials are obtained correctly in environment * docs(README update for assistant): * chore(gitignore): add assistant js files to gitignore * Fix travis build * docs(README): readme updates removing conversation example
1 parent feb0e29 commit 1cef7a2

File tree

11 files changed

+7718
-16
lines changed

11 files changed

+7718
-16
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ visual-recognition/*.js
2828
text-to-speech/*.js
2929
speech-to-text/*.js
3030
authorization/*.js
31+
assistant/*.js
3132
index.js
3233
.nyc_output
3334
**/*.d.ts

README.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Node.js client library to use the Watson APIs.
1919
* [Examples](#examples)
2020
* [IBM Watson Services](#ibm-watson-services)
2121
* [Authorization](#authorization)
22-
* [Conversation](#conversation)
22+
* [Assistant] (#assistant)
2323
* [Discovery](#discovery)
2424
* [Language Translator](#language-translator)
2525
* [Natural Language Classifier](#natural-language-classifier)
@@ -137,24 +137,23 @@ function (err, token) {
137137
});
138138
```
139139

140+
### Assistant
140141

141-
### Conversation
142-
143-
Use the [Conversation][conversation] service to determine the intent of a message.
142+
Use the [Assistant][assistant] service to determine the intent of a message.
144143

145-
Note: you must first create a workspace via Bluemix. See [the documentation](https://console.bluemix.net/docs/services/conversation/index.html#about) for details.
144+
Note: you must first create a workspace via Bluemix. See [the documentation](https://console.bluemix.net/docs/services/assistant/index.html#about) for details.
146145

147146
```js
148-
var ConversationV1 = require('watson-developer-cloud/conversation/v1');
147+
var AssistantV1 = require('watson-developer-cloud/assistant/v1');
149148

150-
var conversation = new ConversationV1({
149+
var assistant = new AssistantV1({
151150
username: '<username>',
152151
password: '<password>',
153-
url: 'https://gateway.watsonplatform.net/conversation/api/',
154-
version: '2017-05-26'
152+
url: 'https://gateway.watsonplatform.net/assistant/api/',
153+
version: '2018-02-16'
155154
});
156155

157-
conversation.message(
156+
assistant.message(
158157
{
159158
input: { text: "What's the weather?" },
160159
workspace_id: '<workspace id>'
@@ -169,6 +168,11 @@ conversation.message(
169168
);
170169
```
171170

171+
172+
### Conversation
173+
174+
This service has been renamed to Assistant.
175+
172176
### Discovery
173177

174178
Use the [Discovery Service][discovery] to search and analyze structured and unstructured data.
@@ -483,7 +487,7 @@ By default, the library tries to use Basic Auth and will ask for `api_key` or `u
483487
```javascript
484488
var watson = require('watson-developer-cloud');
485489

486-
var conversation = new watson.ConversationV1({
490+
var assistant = new watson.AssistantV1({
487491
use_unauthenticated: true
488492
});
489493
```
@@ -522,6 +526,7 @@ This library is licensed under Apache 2.0. Full license text is available in
522526
523527
See [CONTRIBUTING](https://github.com/watson-developer-cloud/node-sdk/blob/master/.github/CONTRIBUTING.md).
524528
529+
[assistant]: https://www.ibm.com/watson/services/assistant/
525530
[conversation]: https://www.ibm.com/watson/services/conversation/
526531
[discovery]: https://www.ibm.com/watson/services/discovery/
527532
[personality_insights]: https://www.ibm.com/watson/services/personality-insights/

assistant/v1-generated.js

Lines changed: 2217 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assistant/v1-generated.ts

Lines changed: 3421 additions & 0 deletions
Large diffs are not rendered by default.

auth.js.enc

0 Bytes
Binary file not shown.

index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
export import AuthorizationV1 = require('./authorization/v1');
2222

23+
export import AssistantV1 = require('./assistant/v1-generated');
24+
2325
export import ConversationV1 = require('./conversation/v1');
2426

2527
export import DiscoveryV1 = require('./discovery/v1');

lib/base_service.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,14 @@ export class BaseService {
207207
* @returns {Credentials}
208208
*/
209209
private getCredentialsFromEnvironment(name: string): Credentials {
210-
const _name: string = (name === 'watson_vision_combined' ? 'visual_recognition' : name).toUpperCase();
210+
if (name === 'watson_vision_combined') {
211+
return this.getCredentialsFromEnvironment('visual_recognition');
212+
}
213+
// Case handling for assistant - should look for assistant env variables before conversation
214+
if (name === 'conversation' && process.env[`ASSISTANT_USERNAME`]) {
215+
return this.getCredentialsFromEnvironment('assistant');
216+
}
217+
const _name: string = name.toUpperCase();
211218
// https://github.com/watson-developer-cloud/node-sdk/issues/605
212219
const _nameWithUnderscore: string = _name.replace(/-/g, '_');
213220
const _username: string = process.env[`${_name}_USERNAME`] || process.env[`${_nameWithUnderscore}_USERNAME`];

test/integration/test.adapter.conversation.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ describe('conversation_adapter_integration', function() {
111111
before(function() {
112112
const constructorParams = assign({}, auth.conversation, {
113113
version: 'v1',
114-
version_date: '2017-05-26',
114+
version_date: '2018-02-16',
115115
});
116116
conversation = watson.conversation(constructorParams);
117117
nock.enableNetConnect();
@@ -992,7 +992,6 @@ describe('conversation_adapter_integration', function() {
992992
);
993993
assert.equal(result.conditions, 'true', 'conditions field has unexpected value');
994994
assert.equal(result.description, null, 'description field is not null');
995-
assert.notEqual(result.created, null, 'created field is null');
996995
done();
997996
});
998997
});

0 commit comments

Comments
 (0)