Skip to content

Commit c61b794

Browse files
committed
feat(assistant-v1): webhooks parameter added to createWorkspace and updateWorkspace
* `disambiguationOptOut` parameter added to `createDialogNode` * `newDisambiguationOptOut` parameter added to `updateDialogNode`
1 parent 8625111 commit c61b794

File tree

3 files changed

+83
-21
lines changed

3 files changed

+83
-21
lines changed

assistant/v1.ts

+68-14
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ class AssistantV1 extends BaseService {
258258
* @param {DialogNode[]} [params.dialogNodes] - An array of objects describing the dialog nodes in the workspace.
259259
* @param {Counterexample[]} [params.counterexamples] - An array of objects defining input examples that have been
260260
* marked as irrelevant input.
261+
* @param {Webhook[]} [params.webhooks] -
261262
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
262263
* @param {Function} [callback] - The callback that handles the response.
263264
* @returns {Promise<any>|void}
@@ -278,7 +279,8 @@ class AssistantV1 extends BaseService {
278279
'intents': _params.intents,
279280
'entities': _params.entities,
280281
'dialog_nodes': _params.dialogNodes,
281-
'counterexamples': _params.counterexamples
282+
'counterexamples': _params.counterexamples,
283+
'webhooks': _params.webhooks
282284
};
283285

284286
const sdkHeaders = getSdkHeaders('conversation', 'v1', 'createWorkspace');
@@ -422,6 +424,7 @@ class AssistantV1 extends BaseService {
422424
* @param {DialogNode[]} [params.dialogNodes] - An array of objects describing the dialog nodes in the workspace.
423425
* @param {Counterexample[]} [params.counterexamples] - An array of objects defining input examples that have been
424426
* marked as irrelevant input.
427+
* @param {Webhook[]} [params.webhooks] -
425428
* @param {boolean} [params.append] - Whether the new data is to be appended to the existing data in the workspace. If
426429
* **append**=`false`, elements included in the new data completely replace the corresponding existing elements,
427430
* including all subelements. For example, if the new data includes **entities** and **append**=`false`, all existing
@@ -459,7 +462,8 @@ class AssistantV1 extends BaseService {
459462
'intents': _params.intents,
460463
'entities': _params.entities,
461464
'dialog_nodes': _params.dialogNodes,
462-
'counterexamples': _params.counterexamples
465+
'counterexamples': _params.counterexamples,
466+
'webhooks': _params.webhooks
463467
};
464468

465469
const query = {
@@ -3234,6 +3238,8 @@ class AssistantV1 extends BaseService {
32343238
* @param {string} [params.digressOutSlots] - Whether the user can digress to top-level nodes while filling out slots.
32353239
* @param {string} [params.userLabel] - A label that can be displayed externally to describe the purpose of the node
32363240
* to users.
3241+
* @param {boolean} [params.disambiguationOptOut] - Whether the dialog node should be excluded from disambiguation
3242+
* suggestions.
32373243
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
32383244
* @param {Function} [callback] - The callback that handles the response.
32393245
* @returns {Promise<any>|void}
@@ -3272,7 +3278,8 @@ class AssistantV1 extends BaseService {
32723278
'digress_in': _params.digressIn,
32733279
'digress_out': _params.digressOut,
32743280
'digress_out_slots': _params.digressOutSlots,
3275-
'user_label': _params.userLabel
3281+
'user_label': _params.userLabel,
3282+
'disambiguation_opt_out': _params.disambiguationOptOut
32763283
};
32773284

32783285
const path = {
@@ -3433,6 +3440,8 @@ class AssistantV1 extends BaseService {
34333440
* slots.
34343441
* @param {string} [params.newUserLabel] - A label that can be displayed externally to describe the purpose of the
34353442
* node to users.
3443+
* @param {boolean} [params.newDisambiguationOptOut] - Whether the dialog node should be excluded from disambiguation
3444+
* suggestions.
34363445
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
34373446
* @param {Function} [callback] - The callback that handles the response.
34383447
* @returns {Promise<any>|void}
@@ -3471,7 +3480,8 @@ class AssistantV1 extends BaseService {
34713480
'digress_in': _params.newDigressIn,
34723481
'digress_out': _params.newDigressOut,
34733482
'digress_out_slots': _params.newDigressOutSlots,
3474-
'user_label': _params.newUserLabel
3483+
'user_label': _params.newUserLabel,
3484+
'disambiguation_opt_out': _params.newDisambiguationOptOut
34753485
};
34763486

34773487
const path = {
@@ -3678,8 +3688,9 @@ class AssistantV1 extends BaseService {
36783688
*
36793689
* @param {Object} params - The parameters to send to the service.
36803690
* @param {string} params.filter - A cacheable parameter that limits the results to those matching the specified
3681-
* filter. You must specify a filter query that includes a value for `language`, as well as a value for `workspace_id`
3682-
* or `request.context.metadata.deployment`. For more information, see the
3691+
* filter. You must specify a filter query that includes a value for `language`, as well as a value for
3692+
* `request.context.system.assistant_id`, `workspace_id`, or `request.context.metadata.deployment`. For more
3693+
* information, see the
36833694
* [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-filter-reference#filter-reference).
36843695
* @param {string} [params.sort] - How to sort the returned log events. You can sort by **request_timestamp**. To
36853696
* reverse the sort order, prefix the parameter value with a minus sign (`-`).
@@ -3929,6 +3940,7 @@ namespace AssistantV1 {
39293940
dialogNodes?: DialogNode[];
39303941
/** An array of objects defining input examples that have been marked as irrelevant input. */
39313942
counterexamples?: Counterexample[];
3943+
webhooks?: Webhook[];
39323944
headers?: OutgoingHttpHeaders;
39333945
}
39343946

@@ -3984,6 +3996,7 @@ namespace AssistantV1 {
39843996
dialogNodes?: DialogNode[];
39853997
/** An array of objects defining input examples that have been marked as irrelevant input. */
39863998
counterexamples?: Counterexample[];
3999+
webhooks?: Webhook[];
39874000
/** Whether the new data is to be appended to the existing data in the workspace. If **append**=`false`,
39884001
* elements included in the new data completely replace the corresponding existing elements, including all
39894002
* subelements. For example, if the new data includes **entities** and **append**=`false`, all existing entities in
@@ -4676,6 +4689,8 @@ namespace AssistantV1 {
46764689
digressOutSlots?: CreateDialogNodeConstants.DigressOutSlots | string;
46774690
/** A label that can be displayed externally to describe the purpose of the node to users. */
46784691
userLabel?: string;
4692+
/** Whether the dialog node should be excluded from disambiguation suggestions. */
4693+
disambiguationOptOut?: boolean;
46794694
headers?: OutgoingHttpHeaders;
46804695
}
46814696

@@ -4785,6 +4800,8 @@ namespace AssistantV1 {
47854800
newDigressOutSlots?: UpdateDialogNodeConstants.DigressOutSlots | string;
47864801
/** A label that can be displayed externally to describe the purpose of the node to users. */
47874802
newUserLabel?: string;
4803+
/** Whether the dialog node should be excluded from disambiguation suggestions. */
4804+
newDisambiguationOptOut?: boolean;
47884805
headers?: OutgoingHttpHeaders;
47894806
}
47904807

@@ -4863,8 +4880,8 @@ namespace AssistantV1 {
48634880
/** Parameters for the `listAllLogs` operation. */
48644881
export interface ListAllLogsParams {
48654882
/** A cacheable parameter that limits the results to those matching the specified filter. You must specify a
4866-
* filter query that includes a value for `language`, as well as a value for `workspace_id` or
4867-
* `request.context.metadata.deployment`. For more information, see the
4883+
* filter query that includes a value for `language`, as well as a value for `request.context.system.assistant_id`,
4884+
* `workspace_id`, or `request.context.metadata.deployment`. For more information, see the
48684885
* [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-filter-reference#filter-reference).
48694886
*/
48704887
filter: string;
@@ -5047,6 +5064,8 @@ namespace AssistantV1 {
50475064
digress_out_slots?: string;
50485065
/** A label that can be displayed externally to describe the purpose of the node to users. */
50495066
user_label?: string;
5067+
/** Whether the dialog node should be excluded from disambiguation suggestions. */
5068+
disambiguation_opt_out?: boolean;
50505069
/** For internal use only. */
50515070
disabled?: boolean;
50525071
/** The timestamp for creation of the object. */
@@ -5233,8 +5252,8 @@ namespace AssistantV1 {
52335252

52345253
/** DialogSuggestion. */
52355254
export interface DialogSuggestion {
5236-
/** The user-facing label for the disambiguation option. This label is taken from the **user_label** property of
5237-
* the corresponding dialog node.
5255+
/** The user-facing label for the disambiguation option. This label is taken from the **title** or
5256+
* **user_label** property of the corresponding dialog node, depending on the disambiguation options.
52385257
*/
52395258
label: string;
52405259
/** An object defining the message input, intents, and entities to be sent to the Watson Assistant service if
@@ -5640,8 +5659,8 @@ namespace AssistantV1 {
56405659
dialog_node?: string;
56415660
/** An array of objects describing the possible matching dialog nodes from which the user can choose.
56425661
*
5643-
* **Note:** The **suggestions** property is part of the disambiguation feature, which is only available for
5644-
* Premium users.
5662+
* **Note:** The **suggestions** property is part of the disambiguation feature, which is only available for Plus
5663+
* and Premium users.
56455664
*/
56465665
suggestions?: DialogSuggestion[];
56475666
}
@@ -5710,6 +5729,24 @@ namespace AssistantV1 {
57105729
pagination: Pagination;
57115730
}
57125731

5732+
/** A webhook that can be used by dialog nodes to make programmatic calls to an external function. **Note:** Currently, only a single webhook named `main_webhook` is supported. */
5733+
export interface Webhook {
5734+
/** The URL for the external service or application to which you want to send HTTP POST requests. */
5735+
url: string;
5736+
/** The name of the webhook. Currently, `main_webhook` is the only supported value. */
5737+
name: string;
5738+
/** An optional array of HTTP headers to pass with the HTTP request. */
5739+
headers?: WebhookHeader[];
5740+
}
5741+
5742+
/** A key/value pair defining an HTTP header and a value. */
5743+
export interface WebhookHeader {
5744+
/** The name of an HTTP header (for example, `Authorization`). */
5745+
name: string;
5746+
/** The value of an HTTP header. */
5747+
value: string;
5748+
}
5749+
57135750
/** Workspace. */
57145751
export interface Workspace {
57155752
/** The name of the workspace. This string cannot contain carriage return, newline, or tab characters. */
@@ -5742,6 +5779,7 @@ namespace AssistantV1 {
57425779
dialog_nodes?: DialogNode[];
57435780
/** An array of counterexamples. */
57445781
counterexamples?: Counterexample[];
5782+
webhooks?: Webhook[];
57455783
}
57465784

57475785
/** WorkspaceCollection. */
@@ -5758,14 +5796,16 @@ namespace AssistantV1 {
57585796
tooling?: WorkspaceSystemSettingsTooling;
57595797
/** Workspace settings related to the disambiguation feature.
57605798
*
5761-
* **Note:** This feature is available only to Premium users.
5799+
* **Note:** This feature is available only to Plus and Premium users.
57625800
*/
57635801
disambiguation?: WorkspaceSystemSettingsDisambiguation;
57645802
/** For internal use only. */
57655803
human_agent_assist?: JsonObject;
5804+
/** Workspace settings related to detection of irrelevant input. */
5805+
off_topic?: WorkspaceSystemSettingsOffTopic;
57665806
}
57675807

5768-
/** Workspace settings related to the disambiguation feature. **Note:** This feature is available only to Premium users. */
5808+
/** Workspace settings related to the disambiguation feature. **Note:** This feature is available only to Plus and Premium users. */
57695809
export interface WorkspaceSystemSettingsDisambiguation {
57705810
/** The text of the introductory prompt that accompanies disambiguation options presented to the user. */
57715811
prompt?: string;
@@ -5779,6 +5819,20 @@ namespace AssistantV1 {
57795819
* disambiguation feature to be triggered more often. This can be useful for testing or demonstration purposes.
57805820
*/
57815821
sensitivity?: string;
5822+
/** Whether the order in which disambiguation suggestions are presented should be randomized (but still
5823+
* influenced by relative confidence).
5824+
*/
5825+
randomize?: boolean;
5826+
/** The maximum number of disambigation suggestions that can be included in a `suggestion` response. */
5827+
max_suggestions?: number;
5828+
/** For internal use only. */
5829+
suggestion_text_policy?: string;
5830+
}
5831+
5832+
/** Workspace settings related to detection of irrelevant input. */
5833+
export interface WorkspaceSystemSettingsOffTopic {
5834+
/** Whether enhanced irrelevance detection is enabled for the workspace. */
5835+
enabled?: boolean;
57825836
}
57835837

57845838
/** Workspace settings related to the Watson Assistant user interface. */

test/integration/assistant.v1.test.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,7 @@ describe('assistant v1 integration', () => {
148148
expect(err).toBeNull();
149149
const { result } = res || {};
150150
expect(result).toBeDefined();
151-
expect(result.context.system.dialog_stack).toEqual([
152-
{ dialog_node: 'node_22_1467833484410' },
153-
]);
151+
expect(result.context.system.dialog_stack).toEqual([{ dialog_node: 'root' }]);
154152
done();
155153
});
156154
});
@@ -172,9 +170,7 @@ describe('assistant v1 integration', () => {
172170
expect(err).toBeNull();
173171
const { result } = res || {};
174172
expect(result).toBeDefined();
175-
expect(result.context.system.dialog_stack).toEqual([
176-
{ dialog_node: 'node_22_1467833484410' },
177-
]);
173+
expect(result.context.system.dialog_stack).toEqual([]);
178174
done();
179175
});
180176
});
@@ -196,7 +192,7 @@ describe('assistant v1 integration', () => {
196192
expect(err).toBeNull();
197193
const { result } = res || {};
198194
expect(result).toBeDefined();
199-
expect(result.context.system.dialog_stack).toEqual(['node_22_1467833484410']);
195+
expect(result.context.system.dialog_stack).toEqual([]);
200196
done();
201197
});
202198
});

test/unit/assistant.v1.test.js

+12
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ describe('AssistantV1', () => {
264264
const entities = 'fake_entities';
265265
const dialogNodes = 'fake_dialogNodes';
266266
const counterexamples = 'fake_counterexamples';
267+
const webhooks = 'fake_webhooks';
267268
const params = {
268269
name,
269270
description,
@@ -275,6 +276,7 @@ describe('AssistantV1', () => {
275276
entities,
276277
dialogNodes,
277278
counterexamples,
279+
webhooks,
278280
};
279281

280282
assistant.createWorkspace(params);
@@ -298,6 +300,7 @@ describe('AssistantV1', () => {
298300
expect(options.body['entities']).toEqual(entities);
299301
expect(options.body['dialog_nodes']).toEqual(dialogNodes);
300302
expect(options.body['counterexamples']).toEqual(counterexamples);
303+
expect(options.body['webhooks']).toEqual(webhooks);
301304
});
302305

303306
test('should prioritize user-given headers', () => {
@@ -467,6 +470,7 @@ describe('AssistantV1', () => {
467470
const entities = 'fake_entities';
468471
const dialogNodes = 'fake_dialogNodes';
469472
const counterexamples = 'fake_counterexamples';
473+
const webhooks = 'fake_webhooks';
470474
const append = 'fake_append';
471475
const params = {
472476
workspaceId,
@@ -480,6 +484,7 @@ describe('AssistantV1', () => {
480484
entities,
481485
dialogNodes,
482486
counterexamples,
487+
webhooks,
483488
append,
484489
};
485490

@@ -504,6 +509,7 @@ describe('AssistantV1', () => {
504509
expect(options.body['entities']).toEqual(entities);
505510
expect(options.body['dialog_nodes']).toEqual(dialogNodes);
506511
expect(options.body['counterexamples']).toEqual(counterexamples);
512+
expect(options.body['webhooks']).toEqual(webhooks);
507513
expect(options.qs['append']).toEqual(append);
508514
expect(options.path['workspace_id']).toEqual(workspaceId);
509515
});
@@ -4497,6 +4503,7 @@ describe('AssistantV1', () => {
44974503
const digressOut = 'fake_digressOut';
44984504
const digressOutSlots = 'fake_digressOutSlots';
44994505
const userLabel = 'fake_userLabel';
4506+
const disambiguationOptOut = 'fake_disambiguationOptOut';
45004507
const params = {
45014508
workspaceId,
45024509
dialogNode,
@@ -4517,6 +4524,7 @@ describe('AssistantV1', () => {
45174524
digressOut,
45184525
digressOutSlots,
45194526
userLabel,
4527+
disambiguationOptOut,
45204528
};
45214529

45224530
assistant.createDialogNode(params);
@@ -4548,6 +4556,7 @@ describe('AssistantV1', () => {
45484556
expect(options.body['digress_out']).toEqual(digressOut);
45494557
expect(options.body['digress_out_slots']).toEqual(digressOutSlots);
45504558
expect(options.body['user_label']).toEqual(userLabel);
4559+
expect(options.body['disambiguation_opt_out']).toEqual(disambiguationOptOut);
45514560
expect(options.path['workspace_id']).toEqual(workspaceId);
45524561
});
45534562

@@ -4770,6 +4779,7 @@ describe('AssistantV1', () => {
47704779
const newDigressOut = 'fake_newDigressOut';
47714780
const newDigressOutSlots = 'fake_newDigressOutSlots';
47724781
const newUserLabel = 'fake_newUserLabel';
4782+
const newDisambiguationOptOut = 'fake_newDisambiguationOptOut';
47734783
const params = {
47744784
workspaceId,
47754785
dialogNode,
@@ -4791,6 +4801,7 @@ describe('AssistantV1', () => {
47914801
newDigressOut,
47924802
newDigressOutSlots,
47934803
newUserLabel,
4804+
newDisambiguationOptOut,
47944805
};
47954806

47964807
assistant.updateDialogNode(params);
@@ -4826,6 +4837,7 @@ describe('AssistantV1', () => {
48264837
expect(options.body['digress_out']).toEqual(newDigressOut);
48274838
expect(options.body['digress_out_slots']).toEqual(newDigressOutSlots);
48284839
expect(options.body['user_label']).toEqual(newUserLabel);
4840+
expect(options.body['disambiguation_opt_out']).toEqual(newDisambiguationOptOut);
48294841
expect(options.path['workspace_id']).toEqual(workspaceId);
48304842
expect(options.path['dialog_node']).toEqual(dialogNode);
48314843
});

0 commit comments

Comments
 (0)