@unboundcx/sdk 4.13.146-security.0 → 4.13.146-security.2
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/README.md +0 -7
- package/index.js +31 -1
- package/lib/journeyLayout.js +132 -0
- package/package.json +5 -2
- package/services/journeys/JourneyDraftService.js +92 -0
- package/services/journeys/JourneyGoalsService.js +57 -0
- package/services/journeys/JourneyMembersService.js +246 -0
- package/services/journeys/JourneyTypesService.js +59 -0
- package/services/journeys/JourneyWorklistService.js +74 -0
- package/services/journeys/JourneysService.js +392 -0
- package/services/layouts.js +13 -4
- package/services/licenses.js +21 -0
- package/services/messageTemplates.js +109 -2
- package/services/messaging/EmailTemplatesService.js +10 -2
- package/services/messaging/SmsService.js +0 -3
- package/services/messaging.js +0 -2
- package/services/objects.js +12 -39
- package/services/operatorPanels.js +226 -0
- package/services/parking.js +121 -0
- package/services/permissions.js +21 -0
- package/services/phoneNumbers/carrier.js +60 -0
- package/services/phoneNumbers/cnam.js +42 -0
- package/services/phoneNumbers/index.js +27 -0
- package/services/phoneNumbers/order.js +88 -0
- package/services/phoneNumbers/porting-activity.js +289 -0
- package/services/phoneNumbers/porting-orders.js +318 -0
- package/services/phoneNumbers/search.js +181 -0
- package/services/phoneNumbers/update.js +94 -0
- package/services/phoneNumbers.js +2 -1037
- package/services/recents.js +16 -0
- package/services/schedules/SchedulesService.js +232 -0
- package/services/schedules/TimeOffService.js +131 -0
- package/services/skills.js +207 -0
- package/services/taskRouter/MetricsService.js +3 -0
- package/services/taskRouter/QueueService.js +343 -0
- package/services/taskRouter/TaskRouterService.js +2 -0
- package/services/taskRouter/TaskService.js +70 -10
- package/services/voice.js +47 -25
- package/services/voicemailDrops.js +268 -0
- package/services/workflowTemplates/WorkflowTemplatesService.js +68 -0
- package/services/messaging/SmsTemplatesService.js +0 -125
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import { internalRequest } from '../../base.js';
|
|
2
|
+
|
|
3
|
+
// queues.overflowRules / queues.pendingCounts (queue-capacity-overflow-plan.md
|
|
4
|
+
// v4, P4 contract D). Kept as its own file per CLAUDE.md's 400-line guideline
|
|
5
|
+
// rather than folding into TaskService.js.
|
|
6
|
+
export class QueueService {
|
|
7
|
+
constructor(sdk) {
|
|
8
|
+
this.sdk = sdk;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Get the queue's overflow rules (queueOverflowRules table). When the
|
|
13
|
+
* queue has no normalized rows yet, the API synthesizes editable rules
|
|
14
|
+
* from the legacy waitPolicy/closedPolicy columns instead of returning
|
|
15
|
+
* an empty array.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} queueId - The queue ID (required)
|
|
18
|
+
* @returns {Promise<Object>} result
|
|
19
|
+
* @returns {Object[]} result.overflowRules - Rows for the queue (one per queueId x channel x trigger)
|
|
20
|
+
* @returns {boolean} result.synthesized - True when the rules were derived from legacy waitPolicy/closedPolicy, not read from queueOverflowRules
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const { overflowRules } = await sdk.taskRouter.queues.getOverflowRules('queue123');
|
|
24
|
+
*/
|
|
25
|
+
async getOverflowRules(queueId) {
|
|
26
|
+
this.sdk.validateParams(
|
|
27
|
+
{ queueId },
|
|
28
|
+
{ queueId: { type: 'string', required: true } },
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
return await internalRequest(
|
|
32
|
+
this.sdk,
|
|
33
|
+
`/taskRouter/queues/${queueId}/overflowRules`,
|
|
34
|
+
'GET',
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Replace the full set of overflow rules for a queue.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} queueId - The queue ID (required)
|
|
42
|
+
* @param {Object[]} rules - The complete set of overflow rules to store for this queue (replaces any existing rows)
|
|
43
|
+
* @param {string} rules[].channel - 'phoneCall' | 'chat' | 'email' | 'sms' | 'fax' | 'other' | 'whatsApp' | 'rcs'
|
|
44
|
+
* @param {string} rules[].trigger - 'maxWait' | 'noAgents' | 'capacity' | 'closed'
|
|
45
|
+
* @param {string} rules[].action - 'none' | 'complete' | 'leaveMessage' | 'callback' | 'routeToQueue' | 'rebalance' | 'routeToWorkflow' | 'routeToDestination'
|
|
46
|
+
* @param {Object} [rules[].options] - Action-specific options (e.g. maxWaitSeconds, targetWorkflowId, destination)
|
|
47
|
+
* @param {string[]} [rules[].candidateQueueIds] - Candidate queue ids for routeToQueue/rebalance actions
|
|
48
|
+
* @returns {Promise<Object>} result
|
|
49
|
+
* @returns {Object[]} result.overflowRules - The stored rules, as written
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* await sdk.taskRouter.queues.setOverflowRules('queue123', [
|
|
53
|
+
* { channel: 'phoneCall', trigger: 'maxWait', action: 'routeToWorkflow', options: { targetWorkflowId: 'wf1' } },
|
|
54
|
+
* ]);
|
|
55
|
+
*/
|
|
56
|
+
async setOverflowRules(queueId, rules) {
|
|
57
|
+
this.sdk.validateParams(
|
|
58
|
+
{ queueId, rules },
|
|
59
|
+
{
|
|
60
|
+
queueId: { type: 'string', required: true },
|
|
61
|
+
rules: { type: 'array', required: true },
|
|
62
|
+
},
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
return await internalRequest(
|
|
66
|
+
this.sdk,
|
|
67
|
+
`/taskRouter/queues/${queueId}/overflowRules`,
|
|
68
|
+
'PUT',
|
|
69
|
+
{ body: { overflowRules: rules } },
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Get the queue's current pending counts per channel. Thin proxy onto
|
|
75
|
+
* task-router's authoritative, committed counts (not a SQL COUNT(*)).
|
|
76
|
+
*
|
|
77
|
+
* @param {string} queueId - The queue ID (required)
|
|
78
|
+
* @returns {Promise<Object>} result
|
|
79
|
+
* @returns {string} result.queueId
|
|
80
|
+
* @returns {Object} result.counts - Keyed by channel, e.g. `{ phoneCall: { pending, asyncWait, voicemail } }`
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* const { counts } = await sdk.taskRouter.queues.getPendingCounts('queue123');
|
|
84
|
+
* const waitingCalls = counts.phoneCall?.pending ?? 0;
|
|
85
|
+
*/
|
|
86
|
+
async getPendingCounts(queueId) {
|
|
87
|
+
this.sdk.validateParams(
|
|
88
|
+
{ queueId },
|
|
89
|
+
{ queueId: { type: 'string', required: true } },
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
return await internalRequest(
|
|
93
|
+
this.sdk,
|
|
94
|
+
`/taskRouter/queues/${queueId}/pendingCounts`,
|
|
95
|
+
'GET',
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Get a queue's per-channel skill-tier routing steps
|
|
101
|
+
* (skill-proficiency-tiers-plan.md D2/§3.3). Step 0 (Expert only, full
|
|
102
|
+
* requirements) is implicit and never included in the returned list.
|
|
103
|
+
*
|
|
104
|
+
* @param {string} queueId - The queue ID (required)
|
|
105
|
+
* @returns {Promise<Object>} result
|
|
106
|
+
* @returns {string} result.queueId
|
|
107
|
+
* @returns {Object} result.routingSteps - Keyed by channel ('phoneCall'|'chat'|'email'|'sms'),
|
|
108
|
+
* e.g. `{ phoneCall: { steps: [{afterSec, allowedTiers, ignoreOptionalSkills, dropRequiredSkillIds}], learningNeverAutoRoute } }`
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* const { routingSteps } = await sdk.taskRouter.queues.getRoutingSteps('queue123');
|
|
112
|
+
*/
|
|
113
|
+
async getRoutingSteps(queueId) {
|
|
114
|
+
this.sdk.validateParams(
|
|
115
|
+
{ queueId },
|
|
116
|
+
{ queueId: { type: 'string', required: true } },
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
return await internalRequest(
|
|
120
|
+
this.sdk,
|
|
121
|
+
`/taskRouter/queues/${queueId}/routingSteps`,
|
|
122
|
+
'GET',
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Replace a queue's per-channel skill-tier routing steps. `afterSec`
|
|
128
|
+
* must be strictly increasing within each channel's `steps` list; the
|
|
129
|
+
* API validates this and rejects out-of-order steps.
|
|
130
|
+
*
|
|
131
|
+
* @param {string} queueId - The queue ID (required)
|
|
132
|
+
* @param {Object} routingSteps - Keyed by channel ('phoneCall'|'chat'|'email'|'sms')
|
|
133
|
+
* @param {Object[]} routingSteps[channel].steps - `[{afterSec, allowedTiers, ignoreOptionalSkills, dropRequiredSkillIds}]`
|
|
134
|
+
* @param {boolean} [routingSteps[channel].learningNeverAutoRoute] - Coach-only: never auto-route Learning-tier workers on this channel
|
|
135
|
+
* @returns {Promise<Object>} result
|
|
136
|
+
* @returns {string} result.queueId
|
|
137
|
+
* @returns {Object} result.routingSteps - The stored steps, as written (normalized)
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* await sdk.taskRouter.queues.setRoutingSteps('queue123', {
|
|
141
|
+
* phoneCall: {
|
|
142
|
+
* steps: [
|
|
143
|
+
* { afterSec: 30, allowedTiers: ['expert', 'proficient'], ignoreOptionalSkills: false, dropRequiredSkillIds: [] },
|
|
144
|
+
* { afterSec: 90, allowedTiers: ['expert', 'proficient', 'learning'], ignoreOptionalSkills: true, dropRequiredSkillIds: [] },
|
|
145
|
+
* ],
|
|
146
|
+
* learningNeverAutoRoute: false,
|
|
147
|
+
* },
|
|
148
|
+
* });
|
|
149
|
+
*/
|
|
150
|
+
async setRoutingSteps(queueId, routingSteps) {
|
|
151
|
+
this.sdk.validateParams(
|
|
152
|
+
{ queueId, routingSteps },
|
|
153
|
+
{
|
|
154
|
+
queueId: { type: 'string', required: true },
|
|
155
|
+
routingSteps: { type: 'object', required: true },
|
|
156
|
+
},
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
return await internalRequest(
|
|
160
|
+
this.sdk,
|
|
161
|
+
`/taskRouter/queues/${queueId}/routingSteps`,
|
|
162
|
+
'PUT',
|
|
163
|
+
{ body: { routingSteps } },
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* List a queue's alert rules (queueAlertRules table). Each rule fires
|
|
169
|
+
* when its trigger metric crosses `threshold` by `comparator` and
|
|
170
|
+
* stays there for `sustainSeconds` (proactive-alerts-plan.md §13/D1-D7).
|
|
171
|
+
*
|
|
172
|
+
* @param {string} queueId - The queue ID (required)
|
|
173
|
+
* @returns {Promise<Object>} result
|
|
174
|
+
* @returns {Object[]} result.alertRules - Rules for the queue
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* const { alertRules } = await sdk.taskRouter.queues.alerts.list('queue123');
|
|
178
|
+
*/
|
|
179
|
+
async alertsList(queueId) {
|
|
180
|
+
this.sdk.validateParams(
|
|
181
|
+
{ queueId },
|
|
182
|
+
{ queueId: { type: 'string', required: true } },
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
return await internalRequest(
|
|
186
|
+
this.sdk,
|
|
187
|
+
`/taskRouter/queues/${queueId}/alertRules`,
|
|
188
|
+
'GET',
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Create a new alert rule on a queue.
|
|
194
|
+
*
|
|
195
|
+
* @param {string} queueId - The queue ID (required)
|
|
196
|
+
* @param {Object} rule - The rule to create
|
|
197
|
+
* @param {string} rule.channel - 'phoneCall' | 'chat' | 'email' | 'sms' | 'fax' | 'other' | 'whatsApp' | 'rcs' | 'all'
|
|
198
|
+
* @param {string} rule.trigger - 'pendingTasks' | 'longestWait' | 'serviceLevel' | 'availableAgents' | 'abandonmentRate' | 'abandonCount' | 'occupancy' | 'overflowMaxWait' | 'overflowNoAgents' | 'overflowCapacity' | 'overflowClosed'
|
|
199
|
+
* @param {string} [rule.comparator] - 'gte' | 'lte' (defaults per trigger: serviceLevel/availableAgents -> lte, else gte)
|
|
200
|
+
* @param {number} rule.threshold
|
|
201
|
+
* @param {number} [rule.hysteresisValue]
|
|
202
|
+
* @param {number} [rule.windowMinutes] - Required 1-60 iff trigger is 'abandonCount'
|
|
203
|
+
* @param {number} [rule.sustainSeconds]
|
|
204
|
+
* @param {number} [rule.cooldownSeconds]
|
|
205
|
+
* @param {number} [rule.dailyCap]
|
|
206
|
+
* @param {string} [rule.scheduleId]
|
|
207
|
+
* @param {boolean} [rule.sendRecovery]
|
|
208
|
+
* @param {number} [rule.escalateAfterSeconds]
|
|
209
|
+
* @param {Object[]} rule.actions - `[{type:'email'|'sms'|'notification', userIds:[], teamIds:[]} | {type:'chat', channelId?, userIds?} | {type:'workflow', workflowId}]`
|
|
210
|
+
* @param {Object[]} [rule.escalateActions] - Same shape as `actions`
|
|
211
|
+
* @param {boolean} [rule.isEnabled]
|
|
212
|
+
* @returns {Promise<Object>} result
|
|
213
|
+
* @returns {Object} result.alertRule - The created rule
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* await sdk.taskRouter.queues.alerts.create('queue123', {
|
|
217
|
+
* channel: 'phoneCall',
|
|
218
|
+
* trigger: 'longestWait',
|
|
219
|
+
* threshold: 60,
|
|
220
|
+
* sustainSeconds: 60,
|
|
221
|
+
* actions: [{ type: 'notification', userIds: ['user1'], teamIds: [] }],
|
|
222
|
+
* });
|
|
223
|
+
*/
|
|
224
|
+
async alertsCreate(queueId, rule) {
|
|
225
|
+
this.sdk.validateParams(
|
|
226
|
+
{ queueId, rule },
|
|
227
|
+
{
|
|
228
|
+
queueId: { type: 'string', required: true },
|
|
229
|
+
rule: { type: 'object', required: true },
|
|
230
|
+
},
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
return await internalRequest(
|
|
234
|
+
this.sdk,
|
|
235
|
+
`/taskRouter/queues/${queueId}/alertRules`,
|
|
236
|
+
'POST',
|
|
237
|
+
{ body: rule },
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Patch an existing alert rule.
|
|
243
|
+
*
|
|
244
|
+
* @param {string} queueId - The queue ID (required)
|
|
245
|
+
* @param {string} ruleId - The alert rule ID (required)
|
|
246
|
+
* @param {Object} patch - Partial fields to update (same shape as `create`'s `rule`)
|
|
247
|
+
* @returns {Promise<Object>} result
|
|
248
|
+
* @returns {Object} result.alertRule - The updated rule
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* await sdk.taskRouter.queues.alerts.update('queue123', 'rule1', { threshold: 90 });
|
|
252
|
+
*/
|
|
253
|
+
async alertsUpdate(queueId, ruleId, patch) {
|
|
254
|
+
this.sdk.validateParams(
|
|
255
|
+
{ queueId, ruleId, patch },
|
|
256
|
+
{
|
|
257
|
+
queueId: { type: 'string', required: true },
|
|
258
|
+
ruleId: { type: 'string', required: true },
|
|
259
|
+
patch: { type: 'object', required: true },
|
|
260
|
+
},
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
return await internalRequest(
|
|
264
|
+
this.sdk,
|
|
265
|
+
`/taskRouter/queues/${queueId}/alertRules/${ruleId}`,
|
|
266
|
+
'PATCH',
|
|
267
|
+
{ body: patch },
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Delete an alert rule.
|
|
273
|
+
*
|
|
274
|
+
* @param {string} queueId - The queue ID (required)
|
|
275
|
+
* @param {string} ruleId - The alert rule ID (required)
|
|
276
|
+
* @returns {Promise<Object>} result
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* await sdk.taskRouter.queues.alerts.remove('queue123', 'rule1');
|
|
280
|
+
*/
|
|
281
|
+
async alertsRemove(queueId, ruleId) {
|
|
282
|
+
this.sdk.validateParams(
|
|
283
|
+
{ queueId, ruleId },
|
|
284
|
+
{
|
|
285
|
+
queueId: { type: 'string', required: true },
|
|
286
|
+
ruleId: { type: 'string', required: true },
|
|
287
|
+
},
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
return await internalRequest(
|
|
291
|
+
this.sdk,
|
|
292
|
+
`/taskRouter/queues/${queueId}/alertRules/${ruleId}`,
|
|
293
|
+
'DELETE',
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* List a queue's alert event history (queueAlertEvents table): fired,
|
|
299
|
+
* escalated, cleared, and suppressed events.
|
|
300
|
+
*
|
|
301
|
+
* @param {string} queueId - The queue ID (required)
|
|
302
|
+
* @param {Object} [options]
|
|
303
|
+
* @param {number} [options.limit] - Max rows to return (default 50)
|
|
304
|
+
* @param {string} [options.before] - ISO timestamp cursor; only events before this time
|
|
305
|
+
* @returns {Promise<Object>} result
|
|
306
|
+
* @returns {Object[]} result.alertEvents
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* const { alertEvents } = await sdk.taskRouter.queues.alerts.history('queue123', { limit: 20 });
|
|
310
|
+
*/
|
|
311
|
+
async alertsHistory(queueId, { limit, before } = {}) {
|
|
312
|
+
this.sdk.validateParams(
|
|
313
|
+
{ queueId },
|
|
314
|
+
{ queueId: { type: 'string', required: true } },
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
const query = {};
|
|
318
|
+
if (limit !== undefined) query.limit = limit;
|
|
319
|
+
if (before !== undefined) query.before = before;
|
|
320
|
+
|
|
321
|
+
return await internalRequest(
|
|
322
|
+
this.sdk,
|
|
323
|
+
`/taskRouter/queues/${queueId}/alertEvents`,
|
|
324
|
+
'GET',
|
|
325
|
+
{ query },
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// Exposes alert-rule methods as `sdk.taskRouter.queues.alerts.*` while
|
|
331
|
+
// keeping them implemented as plain methods on QueueService above (so they
|
|
332
|
+
// share `this.sdk`/validateParams without a second internalRequest wiring).
|
|
333
|
+
Object.defineProperty(QueueService.prototype, 'alerts', {
|
|
334
|
+
get() {
|
|
335
|
+
return {
|
|
336
|
+
list: (queueId) => this.alertsList(queueId),
|
|
337
|
+
create: (queueId, rule) => this.alertsCreate(queueId, rule),
|
|
338
|
+
update: (queueId, ruleId, patch) => this.alertsUpdate(queueId, ruleId, patch),
|
|
339
|
+
remove: (queueId, ruleId) => this.alertsRemove(queueId, ruleId),
|
|
340
|
+
history: (queueId, options) => this.alertsHistory(queueId, options),
|
|
341
|
+
};
|
|
342
|
+
},
|
|
343
|
+
});
|
|
@@ -5,6 +5,7 @@ import { CCService } from './CCService.js';
|
|
|
5
5
|
import { OfferService } from './OfferService.js';
|
|
6
6
|
import { ParticipantService } from './ParticipantService.js';
|
|
7
7
|
import { CcBotsService } from './CcBotsService.js';
|
|
8
|
+
import { QueueService } from './QueueService.js';
|
|
8
9
|
|
|
9
10
|
export class TaskRouterService {
|
|
10
11
|
constructor(sdk) {
|
|
@@ -16,5 +17,6 @@ export class TaskRouterService {
|
|
|
16
17
|
this.offer = new OfferService(sdk);
|
|
17
18
|
this.participants = new ParticipantService(sdk);
|
|
18
19
|
this.ccBots = new CcBotsService(sdk);
|
|
20
|
+
this.queues = new QueueService(sdk);
|
|
19
21
|
}
|
|
20
22
|
}
|
|
@@ -741,6 +741,10 @@ export class TaskService {
|
|
|
741
741
|
*
|
|
742
742
|
* @param {Object} options - Parameters
|
|
743
743
|
* @param {string} options.taskId - The task ID to move to wrap-up (required)
|
|
744
|
+
* @param {boolean} [options.skipSipHangup] - Skip hanging up the worker's SIP leg (e.g. a voicemail
|
|
745
|
+
* drop already released the leg; see voicemail-drop-plan.md §4.2.4)
|
|
746
|
+
* @param {string} [options.dispositionId] - Disposition to pre-fill/stamp for this wrap-up
|
|
747
|
+
* @param {Object} [options.metadata] - Extra context to carry into wrap-up (e.g. voicemail drop id/duration)
|
|
744
748
|
* @returns {Promise<Object>} Object containing the task ID and new status
|
|
745
749
|
* @returns {string} result.taskId - The task ID that was modified
|
|
746
750
|
* @returns {string} result.status - The new status ('wrapUp')
|
|
@@ -754,24 +758,37 @@ export class TaskService {
|
|
|
754
758
|
* // Move a held task to wrap-up
|
|
755
759
|
* const result = await sdk.taskRouter.task.wrapUp({ taskId: 'task456' });
|
|
756
760
|
* console.log(result.taskId); // "task456"
|
|
761
|
+
*
|
|
762
|
+
* @example
|
|
763
|
+
* // Voicemail drop: leg already released, pre-fill disposition
|
|
764
|
+
* const result = await sdk.taskRouter.task.wrapUp({
|
|
765
|
+
* taskId: 'task789',
|
|
766
|
+
* skipSipHangup: true,
|
|
767
|
+
* dispositionId: 'disp_leftVoicemail',
|
|
768
|
+
* metadata: { voicemailDropId: 'vmd_123', durationMs: 23000 },
|
|
769
|
+
* });
|
|
757
770
|
*/
|
|
758
771
|
async wrapUp(options = {}) {
|
|
759
|
-
const { taskId } = options;
|
|
772
|
+
const { taskId, skipSipHangup, dispositionId, metadata } = options;
|
|
760
773
|
|
|
761
774
|
this.sdk.validateParams(
|
|
762
|
-
{ taskId },
|
|
775
|
+
{ taskId, skipSipHangup, dispositionId, metadata },
|
|
763
776
|
{
|
|
764
777
|
taskId: { type: 'string', required: true },
|
|
778
|
+
skipSipHangup: { type: 'boolean', required: false },
|
|
779
|
+
dispositionId: { type: 'string', required: false },
|
|
780
|
+
metadata: { type: 'object', required: false },
|
|
765
781
|
},
|
|
766
782
|
);
|
|
767
783
|
|
|
768
|
-
const
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
};
|
|
784
|
+
const body = { taskId };
|
|
785
|
+
if (skipSipHangup !== undefined) body.skipSipHangup = skipSipHangup;
|
|
786
|
+
if (dispositionId !== undefined) body.dispositionId = dispositionId;
|
|
787
|
+
if (metadata !== undefined) body.metadata = metadata;
|
|
773
788
|
|
|
774
|
-
const
|
|
789
|
+
const params = { body };
|
|
790
|
+
|
|
791
|
+
const result = await internalRequest(this.sdk,
|
|
775
792
|
'/taskRouter/tasks/wrapUp',
|
|
776
793
|
'PUT',
|
|
777
794
|
params,
|
|
@@ -1129,6 +1146,7 @@ export class TaskService {
|
|
|
1129
1146
|
* @param {string} options.taskId
|
|
1130
1147
|
* @param {string} [options.html]
|
|
1131
1148
|
* @param {string} [options.text]
|
|
1149
|
+
* @param {string} [options.subject] - explicit subject (journey touch tasks / first email on a task); thread replies omit it and inherit
|
|
1132
1150
|
* @param {string|string[]} [options.extraTo]
|
|
1133
1151
|
* @param {string|string[]} [options.extraCc]
|
|
1134
1152
|
* @param {string|string[]} [options.extraBcc]
|
|
@@ -1141,6 +1159,7 @@ export class TaskService {
|
|
|
1141
1159
|
taskId,
|
|
1142
1160
|
html,
|
|
1143
1161
|
text,
|
|
1162
|
+
subject,
|
|
1144
1163
|
extraTo,
|
|
1145
1164
|
extraCc,
|
|
1146
1165
|
extraBcc,
|
|
@@ -1157,6 +1176,7 @@ export class TaskService {
|
|
|
1157
1176
|
const body = {};
|
|
1158
1177
|
if (html !== undefined) body.html = html;
|
|
1159
1178
|
if (text !== undefined) body.text = text;
|
|
1179
|
+
if (subject !== undefined) body.subject = subject;
|
|
1160
1180
|
if (extraTo !== undefined) body.extraTo = extraTo;
|
|
1161
1181
|
if (extraCc !== undefined) body.extraCc = extraCc;
|
|
1162
1182
|
if (extraBcc !== undefined) body.extraBcc = extraBcc;
|
|
@@ -1249,6 +1269,7 @@ export class TaskService {
|
|
|
1249
1269
|
* @param {string} [options.note] - Optional note for the receiving agent
|
|
1250
1270
|
* @param {string} [options.reasonCode] - Transfer reason code — e.g. 'wrong_department', 'customer_requested', 'out_of_scope', 'policy_never_bot', 'language', 'other'. Required when the caller's worker is a bot.
|
|
1251
1271
|
* @param {string} [options.reason] - One-sentence transfer reason. Required when the caller's worker is a bot.
|
|
1272
|
+
* @param {number} [options.priorityAdjust] - Amount to add to (or, negative, subtract from) the task's priority on the new task created in the target queue.
|
|
1252
1273
|
* @returns {Promise<Object>} { taskId, newTaskId }
|
|
1253
1274
|
*
|
|
1254
1275
|
* @example
|
|
@@ -1261,16 +1282,18 @@ export class TaskService {
|
|
|
1261
1282
|
* });
|
|
1262
1283
|
*/
|
|
1263
1284
|
async transfer(options = {}) {
|
|
1264
|
-
const { taskId, target, note, reasonCode, reason } =
|
|
1285
|
+
const { taskId, target, note, reasonCode, reason, priorityAdjust } =
|
|
1286
|
+
options;
|
|
1265
1287
|
|
|
1266
1288
|
this.sdk.validateParams(
|
|
1267
|
-
{ taskId, target, note, reasonCode, reason },
|
|
1289
|
+
{ taskId, target, note, reasonCode, reason, priorityAdjust },
|
|
1268
1290
|
{
|
|
1269
1291
|
taskId: { type: 'string', required: true },
|
|
1270
1292
|
target: { type: 'object', required: true },
|
|
1271
1293
|
note: { type: 'string', required: false },
|
|
1272
1294
|
reasonCode: { type: 'string', required: false },
|
|
1273
1295
|
reason: { type: 'string', required: false },
|
|
1296
|
+
priorityAdjust: { type: 'number', required: false },
|
|
1274
1297
|
},
|
|
1275
1298
|
);
|
|
1276
1299
|
|
|
@@ -1278,6 +1301,8 @@ export class TaskService {
|
|
|
1278
1301
|
if (note !== undefined) params.body.note = note;
|
|
1279
1302
|
if (reasonCode !== undefined) params.body.reasonCode = reasonCode;
|
|
1280
1303
|
if (reason !== undefined) params.body.reason = reason;
|
|
1304
|
+
if (priorityAdjust !== undefined)
|
|
1305
|
+
params.body.priorityAdjust = priorityAdjust;
|
|
1281
1306
|
|
|
1282
1307
|
return await internalRequest(
|
|
1283
1308
|
this.sdk,
|
|
@@ -1287,6 +1312,41 @@ export class TaskService {
|
|
|
1287
1312
|
);
|
|
1288
1313
|
}
|
|
1289
1314
|
|
|
1315
|
+
/**
|
|
1316
|
+
* Advisory preview of where a transfer would land right now — calls the
|
|
1317
|
+
* same resolver the real transfer uses, so a UI can show "sent to Queue
|
|
1318
|
+
* Y" before the transfer completes. Never guaranteed to land there under
|
|
1319
|
+
* load; the real transfer re-resolves at claim time.
|
|
1320
|
+
*
|
|
1321
|
+
* @param {string} taskId - The task ID to preview a transfer destination for (required)
|
|
1322
|
+
* @param {Object} options - Parameters
|
|
1323
|
+
* @param {string} options.queueId - Candidate destination queue ID (required)
|
|
1324
|
+
* @returns {Promise<Object>} Resolved destination, shaped by the same logic `transfer` itself uses for this queue/task type.
|
|
1325
|
+
*
|
|
1326
|
+
* @example
|
|
1327
|
+
* const preview = await sdk.taskRouter.task.resolveTransferDestination('task123', {
|
|
1328
|
+
* queueId: 'billingQueue1',
|
|
1329
|
+
* });
|
|
1330
|
+
*/
|
|
1331
|
+
async resolveTransferDestination(taskId, options = {}) {
|
|
1332
|
+
const { queueId } = options;
|
|
1333
|
+
|
|
1334
|
+
this.sdk.validateParams(
|
|
1335
|
+
{ taskId, queueId },
|
|
1336
|
+
{
|
|
1337
|
+
taskId: { type: 'string', required: true },
|
|
1338
|
+
queueId: { type: 'string', required: true },
|
|
1339
|
+
},
|
|
1340
|
+
);
|
|
1341
|
+
|
|
1342
|
+
return await internalRequest(
|
|
1343
|
+
this.sdk,
|
|
1344
|
+
`/taskRouter/tasks/${taskId}/resolveTransferDestination`,
|
|
1345
|
+
'POST',
|
|
1346
|
+
{ body: { queueId } },
|
|
1347
|
+
);
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1290
1350
|
/**
|
|
1291
1351
|
* Get the voice transcript for a task, keyed by the media-manager
|
|
1292
1352
|
* bridgeId (not sipCallId) so it works across requeue/transfer.
|
package/services/voice.js
CHANGED
|
@@ -353,40 +353,62 @@ export class VoiceService {
|
|
|
353
353
|
return this.transcribe(voiceChannelId, 'stop', direction);
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
356
|
+
/**
|
|
357
|
+
* Server-side blind transfer of a live call (call-transfer-api-plan.md
|
|
358
|
+
* §2.2/§2.7).
|
|
359
|
+
*
|
|
360
|
+
* @param {Object} params
|
|
361
|
+
* @param {string} params.callId
|
|
362
|
+
* @param {string} params.to - extension, E.164, or a routable service id
|
|
363
|
+
* @returns {Promise<{correlationId: string}>}
|
|
364
|
+
*/
|
|
365
|
+
async transferCall({ callId, to }) {
|
|
364
366
|
this.sdk.validateParams(
|
|
365
|
-
{
|
|
367
|
+
{ callId, to },
|
|
366
368
|
{
|
|
367
|
-
|
|
368
|
-
to: { type: 'string', required:
|
|
369
|
-
callerIdName: { type: 'string', required: false },
|
|
370
|
-
callerIdNumber: { type: 'string', required: false },
|
|
371
|
-
timeout: { type: 'number', required: false },
|
|
372
|
-
voiceApp: { type: 'object', required: false },
|
|
369
|
+
callId: { type: 'string', required: true },
|
|
370
|
+
to: { type: 'string', required: true },
|
|
373
371
|
},
|
|
374
372
|
);
|
|
375
373
|
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
374
|
+
const result = await internalRequest(
|
|
375
|
+
this.sdk,
|
|
376
|
+
`/voice/calls/${callId}/transfer`,
|
|
377
|
+
'POST',
|
|
378
|
+
{ body: { to } },
|
|
379
|
+
);
|
|
380
|
+
return result;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Drop a pre-recorded/TTS voicemail message on an active outbound call and
|
|
385
|
+
* release the leg immediately (voicemail-drop-plan.md §4.2, §5).
|
|
386
|
+
*
|
|
387
|
+
* @param {Object} options
|
|
388
|
+
* @param {string} options.callId - The call ID to drop the message on (required)
|
|
389
|
+
* @param {string} options.dropId - The voicemail drop message id to play (required)
|
|
390
|
+
* @returns {Promise<Object>} result.status
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* const result = await sdk.voice.voicemailDrop({ callId: 'call123', dropId: 'vmd_456' });
|
|
394
|
+
*/
|
|
395
|
+
async voicemailDrop({ callId, dropId }) {
|
|
396
|
+
this.sdk.validateParams(
|
|
397
|
+
{ callId, dropId },
|
|
398
|
+
{
|
|
399
|
+
callId: { type: 'string', required: true },
|
|
400
|
+
dropId: { type: 'string', required: true },
|
|
401
|
+
},
|
|
402
|
+
);
|
|
382
403
|
|
|
383
404
|
const params = {
|
|
384
|
-
body:
|
|
405
|
+
body: { dropId },
|
|
385
406
|
};
|
|
386
407
|
|
|
387
|
-
const result = await internalRequest(
|
|
388
|
-
|
|
389
|
-
|
|
408
|
+
const result = await internalRequest(
|
|
409
|
+
this.sdk,
|
|
410
|
+
`/voice/calls/${callId}/voicemailDrop`,
|
|
411
|
+
'PUT',
|
|
390
412
|
params,
|
|
391
413
|
);
|
|
392
414
|
return result;
|