@unboundcx/sdk 4.13.62 → 4.13.66
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/ai/battleCards.js +27 -0
- package/services/fax.js +27 -0
- package/services/knowledgeBase.js +178 -2
- package/services/taskRouter/WorkerService.js +78 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.66",
|
|
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",
|
|
@@ -366,6 +366,33 @@ export class BattleCardsService {
|
|
|
366
366
|
* queueId: 'queue_123'
|
|
367
367
|
* });
|
|
368
368
|
*/
|
|
369
|
+
/**
|
|
370
|
+
* Search (or list) battle cards assigned to a queue's packs.
|
|
371
|
+
* Empty query returns the full pack list; a query ranks title/trigger/body.
|
|
372
|
+
*
|
|
373
|
+
* @param {Object} options
|
|
374
|
+
* @param {string} options.queueId
|
|
375
|
+
* @param {string} [options.query]
|
|
376
|
+
* @param {string} [options.q]
|
|
377
|
+
* @returns {Promise<Object>} { results, query }
|
|
378
|
+
*/
|
|
379
|
+
async searchQueueCards({ queueId, query, q } = {}) {
|
|
380
|
+
this.sdk.validateParams(
|
|
381
|
+
{ queueId },
|
|
382
|
+
{
|
|
383
|
+
queueId: { type: 'string', required: true },
|
|
384
|
+
},
|
|
385
|
+
);
|
|
386
|
+
|
|
387
|
+
const result = await internalRequest(
|
|
388
|
+
this.sdk,
|
|
389
|
+
`/ai/battleCards/queues/${queueId}/cards`,
|
|
390
|
+
'GET',
|
|
391
|
+
{ query: { q: query || q || '' } },
|
|
392
|
+
);
|
|
393
|
+
return result;
|
|
394
|
+
}
|
|
395
|
+
|
|
369
396
|
async listQueuePacks({ queueId }) {
|
|
370
397
|
this.sdk.validateParams(
|
|
371
398
|
{ queueId },
|
package/services/fax.js
CHANGED
|
@@ -263,4 +263,31 @@ export class FaxService {
|
|
|
263
263
|
|
|
264
264
|
return await internalRequest(this.sdk, '/fax/status', 'POST', params);
|
|
265
265
|
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Retry a failed outbound fax. Resets the same fax document row (status
|
|
269
|
+
* back to 'pending', clears isError/errorMessage/sipCallId, bumps
|
|
270
|
+
* sendAttempts) and re-dispatches it through the same media-manager path
|
|
271
|
+
* as sdk.fax.send() -- only valid for outbound documents currently in
|
|
272
|
+
* status 'failed'.
|
|
273
|
+
*
|
|
274
|
+
* @param {string} id - The fax document ID to retry (required)
|
|
275
|
+
* @returns {Promise<Object>} Retry result
|
|
276
|
+
* @returns {string} result.id - The fax document ID
|
|
277
|
+
* @returns {string} result.status - 'sending' on success, 'failed' on NATS error
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* const result = await sdk.fax.retry('158abc123...');
|
|
281
|
+
* console.log(result.status); // 'sending'
|
|
282
|
+
*/
|
|
283
|
+
async retry(id) {
|
|
284
|
+
this.sdk.validateParams(
|
|
285
|
+
{ id },
|
|
286
|
+
{
|
|
287
|
+
id: { type: 'string', required: true },
|
|
288
|
+
},
|
|
289
|
+
);
|
|
290
|
+
|
|
291
|
+
return await internalRequest(this.sdk, `/fax/${id}/retry`, 'POST', {});
|
|
292
|
+
}
|
|
266
293
|
}
|
|
@@ -21,7 +21,15 @@ export class KnowledgeBaseService {
|
|
|
21
21
|
* Each result's source now also includes isPublic, knowledgeBaseId, knowledgeBaseName.
|
|
22
22
|
* @returns {Promise<Object>} Search results with source attribution
|
|
23
23
|
*/
|
|
24
|
-
async search({
|
|
24
|
+
async search({
|
|
25
|
+
query,
|
|
26
|
+
knowledgeBaseId,
|
|
27
|
+
limit,
|
|
28
|
+
filters,
|
|
29
|
+
rerank,
|
|
30
|
+
visibility,
|
|
31
|
+
taskId,
|
|
32
|
+
}) {
|
|
25
33
|
this.sdk.validateParams(
|
|
26
34
|
{ query },
|
|
27
35
|
{
|
|
@@ -30,7 +38,15 @@ export class KnowledgeBaseService {
|
|
|
30
38
|
);
|
|
31
39
|
|
|
32
40
|
const params = {
|
|
33
|
-
body: {
|
|
41
|
+
body: {
|
|
42
|
+
query,
|
|
43
|
+
knowledgeBaseId,
|
|
44
|
+
limit,
|
|
45
|
+
filters,
|
|
46
|
+
rerank,
|
|
47
|
+
visibility,
|
|
48
|
+
taskId,
|
|
49
|
+
},
|
|
34
50
|
};
|
|
35
51
|
|
|
36
52
|
const result = await internalRequest(this.sdk,
|
|
@@ -41,6 +57,34 @@ export class KnowledgeBaseService {
|
|
|
41
57
|
return result;
|
|
42
58
|
}
|
|
43
59
|
|
|
60
|
+
async listQueueKnowledgeBases({ queueId }) {
|
|
61
|
+
this.sdk.validateParams(
|
|
62
|
+
{ queueId },
|
|
63
|
+
{ queueId: { type: 'string', required: true } },
|
|
64
|
+
);
|
|
65
|
+
return internalRequest(
|
|
66
|
+
this.sdk,
|
|
67
|
+
`/knowledgeBase/queues/${queueId}/knowledgeBases`,
|
|
68
|
+
'GET',
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async setQueueKnowledgeBases({ queueId, knowledgeBaseIds }) {
|
|
73
|
+
this.sdk.validateParams(
|
|
74
|
+
{ queueId, knowledgeBaseIds },
|
|
75
|
+
{
|
|
76
|
+
queueId: { type: 'string', required: true },
|
|
77
|
+
knowledgeBaseIds: { type: 'array', required: true },
|
|
78
|
+
},
|
|
79
|
+
);
|
|
80
|
+
return internalRequest(
|
|
81
|
+
this.sdk,
|
|
82
|
+
`/knowledgeBase/queues/${queueId}/knowledgeBases`,
|
|
83
|
+
'PUT',
|
|
84
|
+
{ body: { knowledgeBaseIds } },
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
44
88
|
/**
|
|
45
89
|
* Discover pages available at a URL
|
|
46
90
|
* Checks for sitemaps (auto-discovery + direct sitemap URLs) and returns
|
|
@@ -173,6 +217,81 @@ export class KnowledgeBaseService {
|
|
|
173
217
|
return result;
|
|
174
218
|
}
|
|
175
219
|
|
|
220
|
+
/**
|
|
221
|
+
* List version snapshots for a KB article, newest first
|
|
222
|
+
*
|
|
223
|
+
* @param {Object} params
|
|
224
|
+
* @param {string} params.id - Article ID
|
|
225
|
+
* @returns {Promise<Object>} { results: [{ id, version, createdAt, createdBy, contentLength, preview }] }
|
|
226
|
+
*/
|
|
227
|
+
async listArticleVersions({ id }) {
|
|
228
|
+
this.sdk.validateParams(
|
|
229
|
+
{ id },
|
|
230
|
+
{
|
|
231
|
+
id: { type: 'string', required: true },
|
|
232
|
+
},
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
const result = await internalRequest(
|
|
236
|
+
this.sdk,
|
|
237
|
+
`/knowledgeBase/articles/${id}/versions`,
|
|
238
|
+
'GET',
|
|
239
|
+
);
|
|
240
|
+
return result;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Get one full version snapshot (with content) for a KB article
|
|
245
|
+
*
|
|
246
|
+
* @param {Object} params
|
|
247
|
+
* @param {string} params.id - Article ID
|
|
248
|
+
* @param {string} params.versionId - Version snapshot ID
|
|
249
|
+
* @returns {Promise<Object>} Full version row including content
|
|
250
|
+
*/
|
|
251
|
+
async getArticleVersion({ id, versionId }) {
|
|
252
|
+
this.sdk.validateParams(
|
|
253
|
+
{ id, versionId },
|
|
254
|
+
{
|
|
255
|
+
id: { type: 'string', required: true },
|
|
256
|
+
versionId: { type: 'string', required: true },
|
|
257
|
+
},
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
const result = await internalRequest(
|
|
261
|
+
this.sdk,
|
|
262
|
+
`/knowledgeBase/articles/${id}/versions/${versionId}`,
|
|
263
|
+
'GET',
|
|
264
|
+
);
|
|
265
|
+
return result;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Restore a KB article's content to a prior version snapshot.
|
|
270
|
+
* Snapshots the article's current content as a new version before
|
|
271
|
+
* overwriting it, then reprocesses if the article is published.
|
|
272
|
+
*
|
|
273
|
+
* @param {Object} params
|
|
274
|
+
* @param {string} params.id - Article ID
|
|
275
|
+
* @param {string} params.versionId - Version snapshot ID to restore
|
|
276
|
+
* @returns {Promise<Object>} Updated article record
|
|
277
|
+
*/
|
|
278
|
+
async restoreArticleVersion({ id, versionId }) {
|
|
279
|
+
this.sdk.validateParams(
|
|
280
|
+
{ id, versionId },
|
|
281
|
+
{
|
|
282
|
+
id: { type: 'string', required: true },
|
|
283
|
+
versionId: { type: 'string', required: true },
|
|
284
|
+
},
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
const result = await internalRequest(
|
|
288
|
+
this.sdk,
|
|
289
|
+
`/knowledgeBase/articles/${id}/versions/${versionId}/restore`,
|
|
290
|
+
'POST',
|
|
291
|
+
);
|
|
292
|
+
return result;
|
|
293
|
+
}
|
|
294
|
+
|
|
176
295
|
/**
|
|
177
296
|
* Get analytics for a knowledge base
|
|
178
297
|
*
|
|
@@ -181,6 +300,12 @@ export class KnowledgeBaseService {
|
|
|
181
300
|
* @param {Object} [params.filters] - Optional date range, source type filters
|
|
182
301
|
* @returns {Promise<Object>} Analytics data
|
|
183
302
|
*/
|
|
303
|
+
async getAccountAnalytics(filters = {}) {
|
|
304
|
+
return internalRequest(this.sdk, '/knowledgeBase/analytics', 'GET', {
|
|
305
|
+
query: filters,
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
|
|
184
309
|
async getAnalytics({ knowledgeBaseId, ...filters }) {
|
|
185
310
|
this.sdk.validateParams(
|
|
186
311
|
{ knowledgeBaseId },
|
|
@@ -229,4 +354,55 @@ export class KnowledgeBaseService {
|
|
|
229
354
|
);
|
|
230
355
|
return result;
|
|
231
356
|
}
|
|
357
|
+
|
|
358
|
+
async listTaskPins({ taskId }) {
|
|
359
|
+
this.sdk.validateParams(
|
|
360
|
+
{ taskId },
|
|
361
|
+
{ taskId: { type: 'string', required: true } },
|
|
362
|
+
);
|
|
363
|
+
return internalRequest(
|
|
364
|
+
this.sdk,
|
|
365
|
+
`/knowledgeBase/tasks/${taskId}/pins`,
|
|
366
|
+
'GET',
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
async pinTaskSource({
|
|
371
|
+
taskId,
|
|
372
|
+
sourceId,
|
|
373
|
+
sourceType,
|
|
374
|
+
knowledgeBaseId,
|
|
375
|
+
title,
|
|
376
|
+
}) {
|
|
377
|
+
this.sdk.validateParams(
|
|
378
|
+
{ taskId, sourceId },
|
|
379
|
+
{
|
|
380
|
+
taskId: { type: 'string', required: true },
|
|
381
|
+
sourceId: { type: 'string', required: true },
|
|
382
|
+
},
|
|
383
|
+
);
|
|
384
|
+
return internalRequest(
|
|
385
|
+
this.sdk,
|
|
386
|
+
`/knowledgeBase/tasks/${taskId}/pins`,
|
|
387
|
+
'POST',
|
|
388
|
+
{
|
|
389
|
+
body: { sourceId, sourceType, knowledgeBaseId, title },
|
|
390
|
+
},
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
async unpinTaskSource({ taskId, pinId }) {
|
|
395
|
+
this.sdk.validateParams(
|
|
396
|
+
{ taskId, pinId },
|
|
397
|
+
{
|
|
398
|
+
taskId: { type: 'string', required: true },
|
|
399
|
+
pinId: { type: 'string', required: true },
|
|
400
|
+
},
|
|
401
|
+
);
|
|
402
|
+
return internalRequest(
|
|
403
|
+
this.sdk,
|
|
404
|
+
`/knowledgeBase/tasks/${taskId}/pins/${pinId}`,
|
|
405
|
+
'DELETE',
|
|
406
|
+
);
|
|
407
|
+
}
|
|
232
408
|
}
|
|
@@ -195,6 +195,84 @@ export class WorkerService {
|
|
|
195
195
|
return result;
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
+
/**
|
|
199
|
+
* Set the authenticated user's own worker paused state
|
|
200
|
+
* Pauses (or unpauses) the caller's own worker so it stays logged into its queues
|
|
201
|
+
* but stops receiving new task offers. Requires Contact Center access.
|
|
202
|
+
*
|
|
203
|
+
* @param {Object} options - Parameters
|
|
204
|
+
* @param {boolean} options.paused - Whether the worker should be paused
|
|
205
|
+
* @returns {Promise<Object>} The updated worker
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* // Pause the authenticated user's own worker
|
|
209
|
+
* const worker = await sdk.taskRouter.worker.setPaused({ paused: true });
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* // Unpause
|
|
213
|
+
* const worker = await sdk.taskRouter.worker.setPaused({ paused: false });
|
|
214
|
+
*/
|
|
215
|
+
async setPaused(options = {}) {
|
|
216
|
+
const { paused } = options;
|
|
217
|
+
|
|
218
|
+
this.sdk.validateParams(
|
|
219
|
+
{ paused },
|
|
220
|
+
{
|
|
221
|
+
paused: { type: 'boolean', required: true },
|
|
222
|
+
},
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
const params = {
|
|
226
|
+
body: { paused },
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const result = await internalRequest(this.sdk,
|
|
230
|
+
'/taskRouter/workers/me/paused',
|
|
231
|
+
'PUT',
|
|
232
|
+
params,
|
|
233
|
+
);
|
|
234
|
+
return result;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Set another worker's paused state
|
|
239
|
+
* Pauses (or unpauses) a specific worker by workerId. The caller must be a queue
|
|
240
|
+
* manager for at least one queue that worker is logged into or assigned to.
|
|
241
|
+
*
|
|
242
|
+
* @param {Object} options - Parameters
|
|
243
|
+
* @param {string} options.workerId - The worker ID to update (required)
|
|
244
|
+
* @param {boolean} options.paused - Whether the worker should be paused
|
|
245
|
+
* @returns {Promise<Object>} The updated worker
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* const worker = await sdk.taskRouter.worker.setWorkerPaused({
|
|
249
|
+
* workerId: '0860002026012400000006665842155429980',
|
|
250
|
+
* paused: true,
|
|
251
|
+
* });
|
|
252
|
+
*/
|
|
253
|
+
async setWorkerPaused(options = {}) {
|
|
254
|
+
const { workerId, paused } = options;
|
|
255
|
+
|
|
256
|
+
this.sdk.validateParams(
|
|
257
|
+
{ workerId, paused },
|
|
258
|
+
{
|
|
259
|
+
workerId: { type: 'string', required: true },
|
|
260
|
+
paused: { type: 'boolean', required: true },
|
|
261
|
+
},
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
const params = {
|
|
265
|
+
body: { paused },
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
const result = await internalRequest(this.sdk,
|
|
269
|
+
`/taskRouter/workers/${workerId}/paused`,
|
|
270
|
+
'PUT',
|
|
271
|
+
params,
|
|
272
|
+
);
|
|
273
|
+
return result;
|
|
274
|
+
}
|
|
275
|
+
|
|
198
276
|
/**
|
|
199
277
|
* Automatically login all auto-login queues for a worker
|
|
200
278
|
* When a worker goes available, this logs them into all queues marked with autoLogin = true.
|