Skip to content

Commit 4757091

Browse files
committed
refactor(assistant-v2): remove MessageContextSkill interface
1 parent 6fac701 commit 4757091

File tree

4 files changed

+66
-146
lines changed

4 files changed

+66
-146
lines changed

UPGRADE-4.0.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
- [Default Methods Compatibility]
66
- [Removed Services]
77
- [Constructor Compatibility]
8-
- [Assistant Compatibility]
8+
- [Assistant V1 Compatibility]
9+
- [Assistant V2 Compatibility]
910
- [Discovery Compatibility]
1011
- [Natural Language Classifier Compatibility]
1112
- [Personality Insights v3 Compatibility]
@@ -57,9 +58,12 @@ The following services have been deprecated for an extended period of time and w
5758
- Parameter name changed: `version_date` -> `version`
5859
- The parameter `apikey` is no longer supported
5960

60-
### Assistant Compatibility
61+
### Assistant V1 Compatibility
6162
- Parameter name changed: `export` -> `_export` (_All instances_)
6263

64+
### Assistant V2 Compatibility
65+
- Interface `MessageContextSkill` removed
66+
6367
### Discovery Compatibility
6468
#### getSourceCredentials
6569
- Method name changed: `getSourceCredentials` -> `getCredentials`

assistant/v2.ts

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616

1717
import { AxiosResponse } from 'axios';
1818
import * as extend from 'extend';
19-
import { BaseService } from 'ibm-cloud-sdk-core';
20-
import { getMissingParams } from 'ibm-cloud-sdk-core';
19+
import { BaseService, getMissingParams } from 'ibm-cloud-sdk-core';
2120
import { getSdkHeaders } from '../lib/common';
2221

2322
/**
@@ -70,12 +69,12 @@ class AssistantV2 extends BaseService {
7069
* @param {Object} params - The parameters to send to the service.
7170
* @param {string} params.assistant_id - Unique identifier of the assistant. You can find the assistant ID of an
7271
* assistant on the **Assistants** tab of the Watson Assistant tool. For information about creating assistants, see
73-
* the [documentation](https://console.bluemix.net/docs/services/assistant/create-assistant.html#creating-assistants).
72+
* the [documentation](https://console.bluemix.net/docs/services/assistant/assistant-add.html#assistant-add-task).
7473
*
7574
* **Note:** Currently, the v2 API does not support creating assistants.
7675
* @param {Object} [params.headers] - Custom request headers
7776
* @param {Function} [callback] - The callback that handles the response.
78-
* @returns {NodeJS.ReadableStream|void}
77+
* @returns {Promise<any>|void}
7978
*/
8079
public createSession(params: AssistantV2.CreateSessionParams, callback?: AssistantV2.Callback<AssistantV2.SessionResponse>): Promise<any> | void {
8180
const _params = extend({}, params);
@@ -100,7 +99,7 @@ class AssistantV2 extends BaseService {
10099
};
101100

102101
const sdkHeaders = getSdkHeaders('conversation', 'v2', 'createSession');
103-
102+
104103
const parameters = {
105104
options: {
106105
url: '/v2/assistants/{assistant_id}/sessions',
@@ -110,7 +109,6 @@ class AssistantV2 extends BaseService {
110109
defaultOptions: extend(true, {}, this._options, {
111110
headers: extend(true, sdkHeaders, {
112111
'Accept': 'application/json',
113-
'Content-Type': 'application/json',
114112
}, _params.headers),
115113
}),
116114
};
@@ -126,13 +124,13 @@ class AssistantV2 extends BaseService {
126124
* @param {Object} params - The parameters to send to the service.
127125
* @param {string} params.assistant_id - Unique identifier of the assistant. You can find the assistant ID of an
128126
* assistant on the **Assistants** tab of the Watson Assistant tool. For information about creating assistants, see
129-
* the [documentation](https://console.bluemix.net/docs/services/assistant/create-assistant.html#creating-assistants).
127+
* the [documentation](https://console.bluemix.net/docs/services/assistant/assistant-add.html#assistant-add-task).
130128
*
131129
* **Note:** Currently, the v2 API does not support creating assistants.
132130
* @param {string} params.session_id - Unique identifier of the session.
133131
* @param {Object} [params.headers] - Custom request headers
134132
* @param {Function} [callback] - The callback that handles the response.
135-
* @returns {NodeJS.ReadableStream|void}
133+
* @returns {Promise<any>|void}
136134
*/
137135
public deleteSession(params: AssistantV2.DeleteSessionParams, callback?: AssistantV2.Callback<AssistantV2.Empty>): Promise<any> | void {
138136
const _params = extend({}, params);
@@ -158,7 +156,7 @@ class AssistantV2 extends BaseService {
158156
};
159157

160158
const sdkHeaders = getSdkHeaders('conversation', 'v2', 'deleteSession');
161-
159+
162160
const parameters = {
163161
options: {
164162
url: '/v2/assistants/{assistant_id}/sessions/{session_id}',
@@ -189,15 +187,17 @@ class AssistantV2 extends BaseService {
189187
* @param {Object} params - The parameters to send to the service.
190188
* @param {string} params.assistant_id - Unique identifier of the assistant. You can find the assistant ID of an
191189
* assistant on the **Assistants** tab of the Watson Assistant tool. For information about creating assistants, see
192-
* the [documentation](https://console.bluemix.net/docs/services/assistant/create-assistant.html#creating-assistants).
190+
* the [documentation](https://console.bluemix.net/docs/services/assistant/assistant-add.html#assistant-add-task).
193191
*
194192
* **Note:** Currently, the v2 API does not support creating assistants.
195193
* @param {string} params.session_id - Unique identifier of the session.
196-
* @param {MessageInput} [params.input] - The user input.
197-
* @param {MessageContext} [params.context] - State information for the conversation.
194+
* @param {MessageInput} [params.input] - An input object that includes the input text.
195+
* @param {MessageContext} [params.context] - State information for the conversation. The context is stored by the
196+
* assistant on a per-session basis. You can use this property to set or modify context variables, which can also be
197+
* accessed by dialog nodes.
198198
* @param {Object} [params.headers] - Custom request headers
199199
* @param {Function} [callback] - The callback that handles the response.
200-
* @returns {NodeJS.ReadableStream|void}
200+
* @returns {Promise<any>|void}
201201
*/
202202
public message(params: AssistantV2.MessageParams, callback?: AssistantV2.Callback<AssistantV2.MessageResponse>): Promise<any> | void {
203203
const _params = extend({}, params);
@@ -228,12 +228,11 @@ class AssistantV2 extends BaseService {
228228
};
229229

230230
const sdkHeaders = getSdkHeaders('conversation', 'v2', 'message');
231-
231+
232232
const parameters = {
233233
options: {
234234
url: '/v2/assistants/{assistant_id}/sessions/{session_id}/message',
235235
method: 'POST',
236-
json: true,
237236
body,
238237
path,
239238
},
@@ -284,15 +283,15 @@ namespace AssistantV2 {
284283

285284
/** Parameters for the `createSession` operation. */
286285
export interface CreateSessionParams {
287-
/** Unique identifier of the assistant. You can find the assistant ID of an assistant on the **Assistants** tab of the Watson Assistant tool. For information about creating assistants, see the [documentation](https://console.bluemix.net/docs/services/assistant/create-assistant.html#creating-assistants). **Note:** Currently, the v2 API does not support creating assistants. */
286+
/** Unique identifier of the assistant. You can find the assistant ID of an assistant on the **Assistants** tab of the Watson Assistant tool. For information about creating assistants, see the [documentation](https://console.bluemix.net/docs/services/assistant/assistant-add.html#assistant-add-task). **Note:** Currently, the v2 API does not support creating assistants. */
288287
assistant_id: string;
289288
headers?: Object;
290289
return_response?: boolean;
291290
}
292291

293292
/** Parameters for the `deleteSession` operation. */
294293
export interface DeleteSessionParams {
295-
/** Unique identifier of the assistant. You can find the assistant ID of an assistant on the **Assistants** tab of the Watson Assistant tool. For information about creating assistants, see the [documentation](https://console.bluemix.net/docs/services/assistant/create-assistant.html#creating-assistants). **Note:** Currently, the v2 API does not support creating assistants. */
294+
/** Unique identifier of the assistant. You can find the assistant ID of an assistant on the **Assistants** tab of the Watson Assistant tool. For information about creating assistants, see the [documentation](https://console.bluemix.net/docs/services/assistant/assistant-add.html#assistant-add-task). **Note:** Currently, the v2 API does not support creating assistants. */
296295
assistant_id: string;
297296
/** Unique identifier of the session. */
298297
session_id: string;
@@ -302,13 +301,13 @@ namespace AssistantV2 {
302301

303302
/** Parameters for the `message` operation. */
304303
export interface MessageParams {
305-
/** Unique identifier of the assistant. You can find the assistant ID of an assistant on the **Assistants** tab of the Watson Assistant tool. For information about creating assistants, see the [documentation](https://console.bluemix.net/docs/services/assistant/create-assistant.html#creating-assistants). **Note:** Currently, the v2 API does not support creating assistants. */
304+
/** Unique identifier of the assistant. You can find the assistant ID of an assistant on the **Assistants** tab of the Watson Assistant tool. For information about creating assistants, see the [documentation](https://console.bluemix.net/docs/services/assistant/assistant-add.html#assistant-add-task). **Note:** Currently, the v2 API does not support creating assistants. */
306305
assistant_id: string;
307306
/** Unique identifier of the session. */
308307
session_id: string;
309-
/** The user input. */
308+
/** An input object that includes the input text. */
310309
input?: MessageInput;
311-
/** State information for the conversation. */
310+
/** State information for the conversation. The context is stored by the assistant on a per-session basis. You can use this property to set or modify context variables, which can also be accessed by dialog nodes. */
312311
context?: MessageContext;
313312
headers?: Object;
314313
return_response?: boolean;
@@ -384,7 +383,7 @@ namespace AssistantV2 {
384383
typing?: boolean;
385384
/** The URL of the image. */
386385
source?: string;
387-
/** The title to show before the response. */
386+
/** The title or introductory text to show before the response. */
388387
title?: string;
389388
/** The description to show with the the response. */
390389
description?: string;
@@ -416,37 +415,31 @@ namespace AssistantV2 {
416415
input?: MessageInput;
417416
}
418417

419-
/** State information for the conversation. */
418+
/** MessageContext. */
420419
export interface MessageContext {
421-
/** Contains information that can be shared by all skills within the Assistant. */
420+
/** Information that is shared by all skills used by the Assistant. */
422421
global?: MessageContextGlobal;
423-
/** Contains information specific to particular skills within the Assistant. */
422+
/** Information specific to particular skills used by the Assistant. **Note:** Currently, only a single property named `main skill` is supported. This object contains variables that apply to the dialog skill used by the assistant. */
424423
skills?: MessageContextSkills;
425424
}
426425

427-
/** Contains information that can be shared by all skills within the Assistant. */
426+
/** Information that is shared by all skills used by the Assistant. */
428427
export interface MessageContextGlobal {
429-
/** Properties that are shared by all skills used by the assistant. */
428+
/** Built-in system properties that apply to all skills used by the assistant. */
430429
system?: MessageContextGlobalSystem;
431430
}
432431

433-
/** Properties that are shared by all skills used by the assistant. */
432+
/** Built-in system properties that apply to all skills used by the assistant. */
434433
export interface MessageContextGlobalSystem {
435434
/** The user time zone. The assistant uses the time zone to correctly resolve relative time references. */
436435
timezone?: string;
437436
/** A string value that identifies the user who is interacting with the assistant. The client must provide a unique identifier for each individual end user who accesses the application. For Plus and Premium plans, this user ID is used to identify unique users for billing purposes. This string cannot contain carriage return, newline, or tab characters. */
438437
user_id?: string;
439-
/** A counter that is automatically incremented with each turn of the conversation. A value of 1 indicates that this is the the first turn of a new conversation, which can affect the behavior of some skills. */
438+
/** A counter that is automatically incremented with each turn of the conversation. A value of 1 indicates that this is the the first turn of a new conversation, which can affect the behavior of some skills (for example, triggering the start node of a dialog). */
440439
turn_count?: number;
441440
}
442441

443-
/** Contains information specific to a particular skill within the Assistant. */
444-
export interface MessageContextSkill {
445-
/** Arbitrary variables that can be read and written to by a particular skill within the Assistant. */
446-
user_defined?: string;
447-
}
448-
449-
/** Contains information specific to particular skills within the Assistant. */
442+
/** Information specific to particular skills used by the Assistant. **Note:** Currently, only a single property named `main skill` is supported. This object contains variables that apply to the dialog skill used by the assistant. */
450443
export interface MessageContextSkills {
451444
/** MessageContextSkills accepts additional properties. */
452445
[propName: string]: any;
@@ -512,7 +505,7 @@ namespace AssistantV2 {
512505
export interface MessageResponse {
513506
/** Assistant output to be rendered or processed by the client. */
514507
output: MessageOutput;
515-
/** State information for the conversation. */
508+
/** State information for the conversation. The context is stored by the assistant on a per-session basis. You can use this property to access context variables. **Note:** The context is included in message responses only if **return_context**=`true` in the message request. */
516509
context?: MessageContext;
517510
}
518511

test/integration/assistant.v2.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const AssistantV2 = require('../../assistant/v2');
44
const authHelper = require('../resources/auth_helper.js');
55

66
const auth = authHelper.auth.assistant;
7-
auth.version = '2018-09-19';
7+
auth.version = '2019-03-27';
88

99
describe('assistant v2 integration', function() {
1010
const assistant = new AssistantV2(auth);

0 commit comments

Comments
 (0)