@unboundcx/sdk 4.13.52 → 4.13.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/services/taskRouter/TaskService.js +120 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.54",
|
|
4
4
|
"description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -89,6 +89,7 @@ export class TaskService {
|
|
|
89
89
|
aiChatSessionId,
|
|
90
90
|
parentTaskId,
|
|
91
91
|
preferredWorkerId,
|
|
92
|
+
isRoutable,
|
|
92
93
|
metadata,
|
|
93
94
|
source,
|
|
94
95
|
} = options;
|
|
@@ -112,6 +113,7 @@ export class TaskService {
|
|
|
112
113
|
aiChatSessionId,
|
|
113
114
|
parentTaskId,
|
|
114
115
|
preferredWorkerId,
|
|
116
|
+
isRoutable,
|
|
115
117
|
metadata,
|
|
116
118
|
source,
|
|
117
119
|
},
|
|
@@ -133,6 +135,7 @@ export class TaskService {
|
|
|
133
135
|
aiChatSessionId: { type: 'string', required: false },
|
|
134
136
|
parentTaskId: { type: 'string', required: false },
|
|
135
137
|
preferredWorkerId: { type: 'string', required: false },
|
|
138
|
+
isRoutable: { type: 'boolean', required: false },
|
|
136
139
|
metadata: { type: 'object', required: false },
|
|
137
140
|
source: { type: 'string', required: false },
|
|
138
141
|
},
|
|
@@ -205,6 +208,10 @@ export class TaskService {
|
|
|
205
208
|
params.body.preferredWorkerId = preferredWorkerId;
|
|
206
209
|
}
|
|
207
210
|
|
|
211
|
+
if (isRoutable !== undefined) {
|
|
212
|
+
params.body.isRoutable = isRoutable;
|
|
213
|
+
}
|
|
214
|
+
|
|
208
215
|
if (metadata !== undefined) {
|
|
209
216
|
params.body.metadata = metadata;
|
|
210
217
|
}
|
|
@@ -468,44 +475,53 @@ export class TaskService {
|
|
|
468
475
|
}
|
|
469
476
|
|
|
470
477
|
/**
|
|
471
|
-
* Toggle task hold status
|
|
478
|
+
* Toggle or set task hold status
|
|
472
479
|
* Place a connected task on hold or resume a held task.
|
|
473
|
-
* If the
|
|
474
|
-
* If
|
|
480
|
+
* If `held` is omitted, the current status is toggled: 'connected' -> 'hold'
|
|
481
|
+
* and 'hold' -> 'connected'. If `held` is a boolean, it explicitly sets the
|
|
482
|
+
* target status: `true` -> 'hold', `false` -> 'connected'.
|
|
475
483
|
*
|
|
476
484
|
* @param {Object} options - Parameters
|
|
477
485
|
* @param {string} options.taskId - The task ID to hold/resume (required)
|
|
486
|
+
* @param {boolean} [options.held] - Explicit target hold state; omit for legacy toggle behavior
|
|
478
487
|
* @returns {Promise<Object>} Object containing the task ID and new status
|
|
479
488
|
* @returns {string} result.taskId - The task ID that was modified
|
|
480
489
|
* @returns {string} result.status - The new status ('hold' or 'connected')
|
|
490
|
+
* @returns {boolean} result.changed - Whether the status actually changed
|
|
481
491
|
*
|
|
482
492
|
* @example
|
|
483
493
|
* // Put a connected task on hold
|
|
484
|
-
* const result = await sdk.taskRouter.task.hold({ taskId: 'task123' });
|
|
494
|
+
* const result = await sdk.taskRouter.task.hold({ taskId: 'task123', held: true });
|
|
485
495
|
* console.log(result.status); // "hold"
|
|
486
496
|
*
|
|
487
497
|
* @example
|
|
488
498
|
* // Resume a held task
|
|
489
|
-
* const result = await sdk.taskRouter.task.hold({ taskId: 'task123' });
|
|
499
|
+
* const result = await sdk.taskRouter.task.hold({ taskId: 'task123', held: false });
|
|
490
500
|
* console.log(result.status); // "connected"
|
|
501
|
+
*
|
|
502
|
+
* @example
|
|
503
|
+
* // Legacy toggle (no `held`)
|
|
504
|
+
* const result = await sdk.taskRouter.task.hold({ taskId: 'task123' });
|
|
491
505
|
*/
|
|
492
506
|
async hold(options = {}) {
|
|
493
|
-
const { taskId } = options;
|
|
507
|
+
const { taskId, held } = options;
|
|
494
508
|
|
|
495
509
|
this.sdk.validateParams(
|
|
496
|
-
{ taskId },
|
|
510
|
+
{ taskId, held },
|
|
497
511
|
{
|
|
498
512
|
taskId: { type: 'string', required: true },
|
|
513
|
+
held: { type: 'boolean', required: false },
|
|
499
514
|
},
|
|
500
515
|
);
|
|
501
516
|
|
|
502
517
|
const params = {
|
|
503
518
|
body: {
|
|
504
519
|
taskId,
|
|
520
|
+
...(typeof held === 'boolean' && { held }),
|
|
505
521
|
},
|
|
506
522
|
};
|
|
507
523
|
|
|
508
|
-
const result = await internalRequest(this.sdk,
|
|
524
|
+
const result = await internalRequest(this.sdk,
|
|
509
525
|
'/taskRouter/tasks/hold',
|
|
510
526
|
'PUT',
|
|
511
527
|
params,
|
|
@@ -904,6 +920,35 @@ export class TaskService {
|
|
|
904
920
|
);
|
|
905
921
|
}
|
|
906
922
|
|
|
923
|
+
/**
|
|
924
|
+
* Resume a parked task ("customer is back"). Flips the task back to
|
|
925
|
+
* pending so the distributor re-offers it; preferredWorkerId (stamped by
|
|
926
|
+
* park) is left alone so the parking worker gets first refusal.
|
|
927
|
+
*
|
|
928
|
+
* PUT /taskRouter/tasks/unpark
|
|
929
|
+
*
|
|
930
|
+
* @param {Object} options - Parameters
|
|
931
|
+
* @param {string} options.taskId - The parked task ID (required)
|
|
932
|
+
* @returns {Promise<Object>} { taskId, status: 'pending' }
|
|
933
|
+
*/
|
|
934
|
+
async unpark(options = {}) {
|
|
935
|
+
const { taskId } = options;
|
|
936
|
+
|
|
937
|
+
this.sdk.validateParams(
|
|
938
|
+
{ taskId },
|
|
939
|
+
{ taskId: { type: 'string', required: true } },
|
|
940
|
+
);
|
|
941
|
+
|
|
942
|
+
const params = { body: { taskId } };
|
|
943
|
+
|
|
944
|
+
return await internalRequest(
|
|
945
|
+
this.sdk,
|
|
946
|
+
'/taskRouter/tasks/unpark',
|
|
947
|
+
'PUT',
|
|
948
|
+
params,
|
|
949
|
+
);
|
|
950
|
+
}
|
|
951
|
+
|
|
907
952
|
/**
|
|
908
953
|
* Public reply on a ticket task: writes the customer-visible post and
|
|
909
954
|
* emails requester + CCs (transactional) from the queue mailbox.
|
|
@@ -1021,30 +1066,39 @@ export class TaskService {
|
|
|
1021
1066
|
}
|
|
1022
1067
|
|
|
1023
1068
|
/**
|
|
1024
|
-
* Transfer a task to a different queue and/or worker.
|
|
1025
|
-
*
|
|
1069
|
+
* Transfer a task to a different queue and/or worker. Creates a new task
|
|
1070
|
+
* in the target queue and re-points live channels to it; the old task is
|
|
1071
|
+
* completed (blind) or left connected pending completeTransfer/cancelTransfer
|
|
1072
|
+
* (attended).
|
|
1026
1073
|
*
|
|
1027
1074
|
* @param {Object} options - Parameters
|
|
1028
1075
|
* @param {string} options.taskId - The task ID to transfer (required)
|
|
1029
1076
|
* @param {string} [options.queueId] - Destination queue ID
|
|
1030
1077
|
* @param {string} [options.workerId] - Destination worker ID
|
|
1031
|
-
* @
|
|
1078
|
+
* @param {string} [options.mode='blind'] - 'blind' or 'attended'. Attended is only
|
|
1079
|
+
* meaningful when a live voice leg exists; otherwise treated as blind.
|
|
1080
|
+
* @param {string} [options.note] - Optional note for the receiving agent
|
|
1081
|
+
* @returns {Promise<Object>} { taskId, newTaskId, mode }
|
|
1032
1082
|
*/
|
|
1033
1083
|
async transfer(options = {}) {
|
|
1034
|
-
const { taskId, queueId, workerId } = options;
|
|
1084
|
+
const { taskId, queueId, workerId, mode, note } = options;
|
|
1035
1085
|
|
|
1036
1086
|
this.sdk.validateParams(
|
|
1037
|
-
{ taskId, queueId, workerId },
|
|
1087
|
+
{ taskId, queueId, workerId, mode, note },
|
|
1038
1088
|
{
|
|
1039
1089
|
taskId: { type: 'string', required: true },
|
|
1040
1090
|
queueId: { type: 'string', required: false },
|
|
1041
1091
|
workerId: { type: 'string', required: false },
|
|
1092
|
+
mode: { type: 'string', required: false },
|
|
1093
|
+
note: { type: 'string', required: false },
|
|
1042
1094
|
},
|
|
1043
1095
|
);
|
|
1044
1096
|
|
|
1045
1097
|
const params = { body: { taskId } };
|
|
1046
1098
|
if (queueId !== undefined) params.body.queueId = queueId;
|
|
1047
1099
|
if (workerId !== undefined) params.body.workerId = workerId;
|
|
1100
|
+
if (mode !== undefined) params.body.mode = mode;
|
|
1101
|
+
if (note !== undefined) params.body.note = note;
|
|
1048
1102
|
|
|
1049
1103
|
return await internalRequest(
|
|
1050
1104
|
this.sdk,
|
|
@@ -1054,6 +1108,59 @@ export class TaskService {
|
|
|
1054
1108
|
);
|
|
1055
1109
|
}
|
|
1056
1110
|
|
|
1111
|
+
/**
|
|
1112
|
+
* Complete an attended transfer: unhold the caller, hang up the old
|
|
1113
|
+
* agent's leg, and complete the old task.
|
|
1114
|
+
*
|
|
1115
|
+
* @param {Object} options - Parameters
|
|
1116
|
+
* @param {string} options.taskId - The old task ID (required)
|
|
1117
|
+
* @returns {Promise<Object>} { taskId }
|
|
1118
|
+
*/
|
|
1119
|
+
async transferComplete(options = {}) {
|
|
1120
|
+
const { taskId } = options;
|
|
1121
|
+
|
|
1122
|
+
this.sdk.validateParams(
|
|
1123
|
+
{ taskId },
|
|
1124
|
+
{ taskId: { type: 'string', required: true } },
|
|
1125
|
+
);
|
|
1126
|
+
|
|
1127
|
+
const params = { body: { taskId } };
|
|
1128
|
+
|
|
1129
|
+
return await internalRequest(
|
|
1130
|
+
this.sdk,
|
|
1131
|
+
'/taskRouter/tasks/transfer/complete',
|
|
1132
|
+
'PUT',
|
|
1133
|
+
params,
|
|
1134
|
+
);
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
/**
|
|
1138
|
+
* Cancel an attended transfer: complete/hang up the new task, re-point
|
|
1139
|
+
* channels back to the old task, unhold the caller, and clear the old
|
|
1140
|
+
* task's transfer state.
|
|
1141
|
+
*
|
|
1142
|
+
* @param {Object} options - Parameters
|
|
1143
|
+
* @param {string} options.taskId - The old task ID (required)
|
|
1144
|
+
* @returns {Promise<Object>} { taskId }
|
|
1145
|
+
*/
|
|
1146
|
+
async transferCancel(options = {}) {
|
|
1147
|
+
const { taskId } = options;
|
|
1148
|
+
|
|
1149
|
+
this.sdk.validateParams(
|
|
1150
|
+
{ taskId },
|
|
1151
|
+
{ taskId: { type: 'string', required: true } },
|
|
1152
|
+
);
|
|
1153
|
+
|
|
1154
|
+
const params = { body: { taskId } };
|
|
1155
|
+
|
|
1156
|
+
return await internalRequest(
|
|
1157
|
+
this.sdk,
|
|
1158
|
+
'/taskRouter/tasks/transfer/cancel',
|
|
1159
|
+
'PUT',
|
|
1160
|
+
params,
|
|
1161
|
+
);
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1057
1164
|
/**
|
|
1058
1165
|
* Get the voice transcript for a task, keyed by the media-manager
|
|
1059
1166
|
* bridgeId (not sipCallId) so it works across requeue/transfer.
|