@unboundcx/sdk 2.8.6 → 2.8.8
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 +48 -1
- package/base.js +43 -12
- package/index.js +27 -3
- package/package.json +5 -2
- package/proto/transcription.proto +207 -0
- package/services/ai/SttStream.js +311 -0
- package/services/ai/playbooks.js +958 -0
- package/services/ai.js +1006 -45
- package/services/engagementMetrics.js +6 -2
- package/services/externalOAuth.js +45 -0
- package/services/fax.js +249 -0
- package/services/knowledgeBase.js +229 -0
- package/services/messaging/EmailTemplatesService.js +31 -11
- package/services/messaging/TenDlcCampaignManagementService.js +187 -105
- package/services/messaging/TollFreeCampaignsService.js +263 -110
- package/services/notes.js +27 -2
- package/services/objects.js +92 -3
- package/services/phoneNumbers.js +88 -3
- package/services/portals.js +89 -0
- package/services/sipEndpoints.js +105 -33
- package/services/storage.js +310 -6
- package/services/taskRouter/MetricsService.js +111 -0
- package/services/taskRouter/TaskRouterService.js +12 -0
- package/services/taskRouter/TaskService.js +846 -0
- package/services/taskRouter/WorkerService.js +394 -0
- package/services/taskRouter.js +6 -0
- package/services/video.js +145 -5
- package/services/voice.js +124 -67
- package/services/workflows.js +167 -7
package/services/voice.js
CHANGED
|
@@ -3,72 +3,151 @@ export class VoiceService {
|
|
|
3
3
|
this.sdk = sdk;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
async
|
|
7
|
-
to,
|
|
8
|
-
from,
|
|
9
|
-
callerIdName,
|
|
10
|
-
callerIdNumber,
|
|
11
|
-
timeout,
|
|
12
|
-
confirmAnswer,
|
|
13
|
-
app,
|
|
14
|
-
variables,
|
|
15
|
-
engagementSessionId,
|
|
16
|
-
voiceChannelId,
|
|
17
|
-
serverId,
|
|
18
|
-
}) {
|
|
6
|
+
async record({ cdrId, callId, action = 'start', direction = 'sendrecv' }) {
|
|
19
7
|
this.sdk.validateParams(
|
|
20
|
-
{},
|
|
8
|
+
{ callId, cdrId, action, direction },
|
|
21
9
|
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
timeout: { type: 'number', required: false },
|
|
27
|
-
confirmAnswer: { type: 'boolean', required: false },
|
|
28
|
-
app: { type: 'object', required: false },
|
|
29
|
-
variables: { type: 'object', required: false },
|
|
30
|
-
engagementSessionId: { type: 'string', required: false },
|
|
31
|
-
voiceChannelId: { type: 'string', required: false },
|
|
32
|
-
serverId: { type: 'string', required: false },
|
|
10
|
+
cdrId: { type: 'string', required: false },
|
|
11
|
+
callId: { type: 'string', required: false },
|
|
12
|
+
action: { type: 'string', required: false },
|
|
13
|
+
direction: { type: 'string', required: false },
|
|
33
14
|
},
|
|
34
15
|
);
|
|
35
16
|
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
17
|
+
const params = {
|
|
18
|
+
body: { callId, cdrId, action, direction },
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const result = await this.sdk._fetch(`/voice/record/`, 'POST', params);
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async call({ to, from, destination, app, timeout, customHeaders }) {
|
|
26
|
+
this.sdk.validateParams(
|
|
27
|
+
{ to, from, destination, app, timeout, customHeaders },
|
|
28
|
+
{
|
|
29
|
+
to: { type: 'string', required: true },
|
|
30
|
+
from: { type: 'string', required: true },
|
|
31
|
+
destination: { type: 'string', required: false },
|
|
32
|
+
app: { type: 'object', required: false },
|
|
33
|
+
timeout: { type: 'number', required: false },
|
|
34
|
+
customHeaders: { type: 'object', required: false },
|
|
35
|
+
},
|
|
36
|
+
);
|
|
48
37
|
|
|
49
38
|
const params = {
|
|
50
|
-
body:
|
|
39
|
+
body: {
|
|
40
|
+
to,
|
|
41
|
+
from,
|
|
42
|
+
destination,
|
|
43
|
+
app,
|
|
44
|
+
timeout,
|
|
45
|
+
customHeaders,
|
|
46
|
+
},
|
|
51
47
|
};
|
|
52
48
|
|
|
53
|
-
const result = await this.sdk._fetch('/voice/
|
|
49
|
+
const result = await this.sdk._fetch('/voice/', 'POST', params);
|
|
54
50
|
return result;
|
|
55
51
|
}
|
|
56
52
|
|
|
57
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Replace the voice application on an active call
|
|
55
|
+
* Dynamically updates the voice app running on a call, allowing you to change the call flow in real-time.
|
|
56
|
+
* This can be used to play new audio, gather input, or execute any other voice commands while the call is active.
|
|
57
|
+
*
|
|
58
|
+
* @param {Object} options - Parameters
|
|
59
|
+
* @param {string} options.callId - The call ID to replace the app for (required)
|
|
60
|
+
* @param {Object} options.app - The voice app object containing commands to execute (required)
|
|
61
|
+
* @param {string} options.app.version - Voice app version (e.g., '2.0')
|
|
62
|
+
* @param {string} options.app.name - Voice app name identifier
|
|
63
|
+
* @param {Array} options.app.commands - Array of command objects to execute
|
|
64
|
+
* @returns {Promise<Object>} Object containing the operation status and metadata
|
|
65
|
+
* @returns {boolean} result.status - Whether the replacement was successful
|
|
66
|
+
* @returns {Object} result.meta - Metadata including the payload sent to media manager
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* // Replace call app to play audio and hangup
|
|
70
|
+
* const result = await sdk.voice.replaceCallApp({
|
|
71
|
+
* callId: 'call123',
|
|
72
|
+
* app: {
|
|
73
|
+
* version: '2.0',
|
|
74
|
+
* name: 'dynamic-app',
|
|
75
|
+
* commands: [
|
|
76
|
+
* { command: 'play', file: 'example.wav' },
|
|
77
|
+
* { command: 'hangup' }
|
|
78
|
+
* ]
|
|
79
|
+
* }
|
|
80
|
+
* });
|
|
81
|
+
* console.log(result.status); // true
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* // Replace call app to gather input
|
|
85
|
+
* const result = await sdk.voice.replaceCallApp({
|
|
86
|
+
* callId: 'call456',
|
|
87
|
+
* app: {
|
|
88
|
+
* version: '2.0',
|
|
89
|
+
* name: 'gather-app',
|
|
90
|
+
* commands: [
|
|
91
|
+
* { command: 'play', file: 'prompt.wav' },
|
|
92
|
+
* { command: 'gather', numDigits: 1, timeout: 5 }
|
|
93
|
+
* ]
|
|
94
|
+
* }
|
|
95
|
+
* });
|
|
96
|
+
*/
|
|
97
|
+
async replaceCallApp({ callId, app }) {
|
|
58
98
|
this.sdk.validateParams(
|
|
59
|
-
{
|
|
99
|
+
{ callId, app },
|
|
60
100
|
{
|
|
61
|
-
|
|
101
|
+
callId: { type: 'string', required: true },
|
|
102
|
+
app: { type: 'object', required: true },
|
|
62
103
|
},
|
|
63
104
|
);
|
|
64
105
|
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
106
|
+
const params = {
|
|
107
|
+
body: {
|
|
108
|
+
callId,
|
|
109
|
+
app,
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const result = await this.sdk._fetch('/voice/replace', 'PUT', params);
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* HangUp active call
|
|
119
|
+
* Ends a currently active SIP phone call
|
|
120
|
+
*
|
|
121
|
+
* @param {string} callId - The call ID to hangup (required)
|
|
122
|
+
* @returns {Promise<Object>} Object containing the operation status and metadata
|
|
123
|
+
* @returns {boolean} result.status - Whether the replacement was successful
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* // hangup call
|
|
127
|
+
* const result = await sdk.voice.hangup(callId);
|
|
128
|
+
* console.log(result.status); // true
|
|
129
|
+
*
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
async hangup(callId) {
|
|
133
|
+
this.sdk.validateParams(
|
|
134
|
+
{ callId },
|
|
135
|
+
{
|
|
136
|
+
callId: { type: 'string', required: true },
|
|
137
|
+
},
|
|
68
138
|
);
|
|
139
|
+
const params = {
|
|
140
|
+
body: {
|
|
141
|
+
callId,
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const result = await this.sdk._fetch(`/voice/hangup`, 'PUT', params);
|
|
69
146
|
return result;
|
|
70
147
|
}
|
|
71
148
|
|
|
149
|
+
/* legacy methods, to be updated and replaced */
|
|
150
|
+
|
|
72
151
|
async hold(channels) {
|
|
73
152
|
this.sdk.validateParams(
|
|
74
153
|
{ channels },
|
|
@@ -132,28 +211,6 @@ export class VoiceService {
|
|
|
132
211
|
return result;
|
|
133
212
|
}
|
|
134
213
|
|
|
135
|
-
async record(voiceChannelId, action = 'start', direction = 'both') {
|
|
136
|
-
this.sdk.validateParams(
|
|
137
|
-
{ voiceChannelId },
|
|
138
|
-
{
|
|
139
|
-
voiceChannelId: { type: 'string', required: true },
|
|
140
|
-
action: { type: 'string', required: false },
|
|
141
|
-
direction: { type: 'string', required: false },
|
|
142
|
-
},
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
const params = {
|
|
146
|
-
body: { action, direction },
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
const result = await this.sdk._fetch(
|
|
150
|
-
`/voice/calls/record/${voiceChannelId}`,
|
|
151
|
-
'POST',
|
|
152
|
-
params,
|
|
153
|
-
);
|
|
154
|
-
return result;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
214
|
async stopRecording(voiceChannelId, direction = 'both') {
|
|
158
215
|
return this.record(voiceChannelId, 'stop', direction);
|
|
159
216
|
}
|
package/services/workflows.js
CHANGED
|
@@ -21,6 +21,91 @@ export class WorkflowsService {
|
|
|
21
21
|
const result = await this.sdk._fetch('/workflows/settings', 'GET', params);
|
|
22
22
|
return result;
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
async listModules() {
|
|
26
|
+
const params = {
|
|
27
|
+
query: {},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const result = await this.sdk._fetch('/workflows/modules', 'GET', params);
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async listFormulaFunctions() {
|
|
35
|
+
const result = await this.sdk._fetch(
|
|
36
|
+
'/workflows/formula-functions',
|
|
37
|
+
'GET',
|
|
38
|
+
);
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async getAvailableHolidaySets() {
|
|
43
|
+
const result = await this.sdk._fetch(
|
|
44
|
+
'/workflows/holiday-sets',
|
|
45
|
+
'GET',
|
|
46
|
+
);
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async simulateWebhook(webhookSettings) {
|
|
51
|
+
this.sdk.validateParams(
|
|
52
|
+
{ webhookSettings },
|
|
53
|
+
{
|
|
54
|
+
webhookSettings: { type: 'object', required: true },
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const params = {
|
|
59
|
+
body: { webhookSettings },
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const result = await this.sdk._fetch(
|
|
63
|
+
'/workflows/webhook/simulate',
|
|
64
|
+
'POST',
|
|
65
|
+
params,
|
|
66
|
+
);
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async simulateLookup(lookupSettings) {
|
|
71
|
+
this.sdk.validateParams(
|
|
72
|
+
{ lookupSettings },
|
|
73
|
+
{
|
|
74
|
+
lookupSettings: { type: 'object', required: true },
|
|
75
|
+
},
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const params = {
|
|
79
|
+
body: { lookupSettings },
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const result = await this.sdk._fetch(
|
|
83
|
+
'/workflows/lookup/simulate',
|
|
84
|
+
'POST',
|
|
85
|
+
params,
|
|
86
|
+
);
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async simulateTimeControl(timeControlSettings, testDateTime = null) {
|
|
91
|
+
this.sdk.validateParams(
|
|
92
|
+
{ timeControlSettings },
|
|
93
|
+
{
|
|
94
|
+
timeControlSettings: { type: 'object', required: true },
|
|
95
|
+
},
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const params = {
|
|
99
|
+
body: { timeControlSettings, testDateTime },
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const result = await this.sdk._fetch(
|
|
103
|
+
'/workflows/timeControl/simulate',
|
|
104
|
+
'POST',
|
|
105
|
+
params,
|
|
106
|
+
);
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
24
109
|
}
|
|
25
110
|
|
|
26
111
|
export class WorkflowItemsService {
|
|
@@ -288,12 +373,12 @@ export class WorkflowSessionsService {
|
|
|
288
373
|
this.sdk = sdk;
|
|
289
374
|
}
|
|
290
375
|
|
|
291
|
-
async create(
|
|
376
|
+
async create(workflowVersionId, sessionData) {
|
|
292
377
|
this.sdk.validateParams(
|
|
293
|
-
{
|
|
378
|
+
{ workflowVersionId, sessionData },
|
|
294
379
|
{
|
|
295
|
-
|
|
296
|
-
sessionData: { type: 'object', required:
|
|
380
|
+
workflowVersionId: { type: 'string', required: true },
|
|
381
|
+
sessionData: { type: 'object', required: false },
|
|
297
382
|
},
|
|
298
383
|
);
|
|
299
384
|
|
|
@@ -302,7 +387,7 @@ export class WorkflowSessionsService {
|
|
|
302
387
|
};
|
|
303
388
|
|
|
304
389
|
const result = await this.sdk._fetch(
|
|
305
|
-
`/workflows/${
|
|
390
|
+
`/workflows/session/${workflowVersionId}`,
|
|
306
391
|
'POST',
|
|
307
392
|
params,
|
|
308
393
|
);
|
|
@@ -329,7 +414,7 @@ export class WorkflowSessionsService {
|
|
|
329
414
|
{ sessionId, updateData },
|
|
330
415
|
{
|
|
331
416
|
sessionId: { type: 'string', required: true },
|
|
332
|
-
updateData: { type: 'object', required:
|
|
417
|
+
updateData: { type: 'object', required: false },
|
|
333
418
|
},
|
|
334
419
|
);
|
|
335
420
|
|
|
@@ -338,7 +423,25 @@ export class WorkflowSessionsService {
|
|
|
338
423
|
};
|
|
339
424
|
|
|
340
425
|
const result = await this.sdk._fetch(
|
|
341
|
-
`/workflows/
|
|
426
|
+
`/workflows/session/${sessionId}`,
|
|
427
|
+
'PUT',
|
|
428
|
+
params,
|
|
429
|
+
);
|
|
430
|
+
return result;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
async complete(sessionId) {
|
|
434
|
+
this.sdk.validateParams(
|
|
435
|
+
{ sessionId },
|
|
436
|
+
{
|
|
437
|
+
sessionId: { type: 'string', required: true },
|
|
438
|
+
},
|
|
439
|
+
);
|
|
440
|
+
|
|
441
|
+
const params = {};
|
|
442
|
+
|
|
443
|
+
const result = await this.sdk._fetch(
|
|
444
|
+
`/workflows/session/${sessionId}/complete`,
|
|
342
445
|
'PUT',
|
|
343
446
|
params,
|
|
344
447
|
);
|
|
@@ -359,4 +462,61 @@ export class WorkflowSessionsService {
|
|
|
359
462
|
);
|
|
360
463
|
return result;
|
|
361
464
|
}
|
|
465
|
+
|
|
466
|
+
async logTranscript(sessionId, transcriptData) {
|
|
467
|
+
this.sdk.validateParams(
|
|
468
|
+
{ sessionId },
|
|
469
|
+
{
|
|
470
|
+
sessionId: { type: 'string', required: true },
|
|
471
|
+
},
|
|
472
|
+
);
|
|
473
|
+
|
|
474
|
+
const params = {
|
|
475
|
+
body: transcriptData,
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
const result = await this.sdk._fetch(
|
|
479
|
+
`/workflows/session/${sessionId}/transcript`,
|
|
480
|
+
'POST',
|
|
481
|
+
params,
|
|
482
|
+
);
|
|
483
|
+
return result;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
async replay(sessionId) {
|
|
487
|
+
this.sdk.validateParams(
|
|
488
|
+
{ sessionId },
|
|
489
|
+
{
|
|
490
|
+
sessionId: { type: 'string', required: true },
|
|
491
|
+
},
|
|
492
|
+
);
|
|
493
|
+
|
|
494
|
+
const result = await this.sdk._fetch(
|
|
495
|
+
`/workflows/session/${sessionId}/replay`,
|
|
496
|
+
'GET',
|
|
497
|
+
);
|
|
498
|
+
return result;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
async analytics(workflowVersionId, { startDate, endDate } = {}) {
|
|
502
|
+
this.sdk.validateParams(
|
|
503
|
+
{ workflowVersionId, startDate, endDate },
|
|
504
|
+
{
|
|
505
|
+
workflowVersionId: { type: 'string', required: true },
|
|
506
|
+
startDate: { type: 'string', required: true },
|
|
507
|
+
endDate: { type: 'string', required: true },
|
|
508
|
+
},
|
|
509
|
+
);
|
|
510
|
+
|
|
511
|
+
const params = {
|
|
512
|
+
query: { startDate, endDate },
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
const result = await this.sdk._fetch(
|
|
516
|
+
`/workflows/${workflowVersionId}/analytics`,
|
|
517
|
+
'GET',
|
|
518
|
+
params,
|
|
519
|
+
);
|
|
520
|
+
return result;
|
|
521
|
+
}
|
|
362
522
|
}
|