@webex/contact-center 3.11.0 → 3.12.0-mobius-socket.1

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.
Files changed (126) hide show
  1. package/dist/cc.js +121 -28
  2. package/dist/cc.js.map +1 -1
  3. package/dist/constants.js +5 -1
  4. package/dist/constants.js.map +1 -1
  5. package/dist/index.js +7 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/metrics/behavioral-events.js +13 -0
  8. package/dist/metrics/behavioral-events.js.map +1 -1
  9. package/dist/metrics/constants.js +9 -1
  10. package/dist/metrics/constants.js.map +1 -1
  11. package/dist/services/ApiAiAssistant.js +173 -0
  12. package/dist/services/ApiAiAssistant.js.map +1 -0
  13. package/dist/services/agent/types.js.map +1 -1
  14. package/dist/services/config/Util.js +6 -2
  15. package/dist/services/config/Util.js.map +1 -1
  16. package/dist/services/config/constants.js +12 -0
  17. package/dist/services/config/constants.js.map +1 -1
  18. package/dist/services/config/index.js +41 -2
  19. package/dist/services/config/index.js.map +1 -1
  20. package/dist/services/config/types.js +19 -1
  21. package/dist/services/config/types.js.map +1 -1
  22. package/dist/services/constants.js +27 -1
  23. package/dist/services/constants.js.map +1 -1
  24. package/dist/services/core/Err.js.map +1 -1
  25. package/dist/services/core/Utils.js +28 -6
  26. package/dist/services/core/Utils.js.map +1 -1
  27. package/dist/services/core/aqm-reqs.js +92 -17
  28. package/dist/services/core/aqm-reqs.js.map +1 -1
  29. package/dist/services/core/websocket/WebSocketManager.js +20 -5
  30. package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
  31. package/dist/services/core/websocket/connection-service.js +3 -1
  32. package/dist/services/core/websocket/connection-service.js.map +1 -1
  33. package/dist/services/index.js +6 -0
  34. package/dist/services/index.js.map +1 -1
  35. package/dist/services/task/TaskManager.js +117 -24
  36. package/dist/services/task/TaskManager.js.map +1 -1
  37. package/dist/services/task/TaskUtils.js +16 -3
  38. package/dist/services/task/TaskUtils.js.map +1 -1
  39. package/dist/services/task/constants.js +15 -1
  40. package/dist/services/task/constants.js.map +1 -1
  41. package/dist/services/task/dialer.js +51 -0
  42. package/dist/services/task/dialer.js.map +1 -1
  43. package/dist/services/task/types.js +15 -0
  44. package/dist/services/task/types.js.map +1 -1
  45. package/dist/types/cc.d.ts +801 -0
  46. package/dist/types/config.d.ts +66 -0
  47. package/dist/types/constants.d.ts +50 -0
  48. package/dist/types/index.d.ts +184 -0
  49. package/dist/types/logger-proxy.d.ts +71 -0
  50. package/dist/types/metrics/MetricsManager.d.ts +223 -0
  51. package/dist/types/metrics/behavioral-events.d.ts +29 -0
  52. package/dist/types/metrics/constants.d.ts +161 -0
  53. package/dist/types/services/AddressBook.d.ts +74 -0
  54. package/dist/types/services/ApiAiAssistant.d.ts +31 -0
  55. package/dist/types/services/EntryPoint.d.ts +67 -0
  56. package/dist/types/services/Queue.d.ts +76 -0
  57. package/dist/types/services/WebCallingService.d.ts +1 -0
  58. package/dist/types/services/agent/index.d.ts +46 -0
  59. package/dist/types/services/agent/types.d.ts +413 -0
  60. package/dist/types/services/config/Util.d.ts +20 -0
  61. package/dist/types/services/config/constants.d.ts +249 -0
  62. package/dist/types/services/config/index.d.ts +177 -0
  63. package/dist/types/services/config/types.d.ts +1207 -0
  64. package/dist/types/services/constants.d.ts +110 -0
  65. package/dist/types/services/core/Err.d.ts +121 -0
  66. package/dist/types/services/core/GlobalTypes.d.ts +58 -0
  67. package/dist/types/services/core/Utils.d.ts +101 -0
  68. package/dist/types/services/core/WebexRequest.d.ts +22 -0
  69. package/dist/types/services/core/aqm-reqs.d.ts +65 -0
  70. package/dist/types/services/core/constants.d.ts +99 -0
  71. package/dist/types/services/core/types.d.ts +47 -0
  72. package/dist/types/services/core/websocket/WebSocketManager.d.ts +35 -0
  73. package/dist/types/services/core/websocket/connection-service.d.ts +27 -0
  74. package/dist/types/services/core/websocket/keepalive.worker.d.ts +2 -0
  75. package/dist/types/services/core/websocket/types.d.ts +37 -0
  76. package/dist/types/services/index.d.ts +54 -0
  77. package/dist/types/services/task/AutoWrapup.d.ts +40 -0
  78. package/dist/types/services/task/TaskManager.d.ts +1 -0
  79. package/dist/types/services/task/TaskUtils.d.ts +92 -0
  80. package/dist/types/services/task/constants.d.ts +84 -0
  81. package/dist/types/services/task/contact.d.ts +69 -0
  82. package/dist/types/services/task/dialer.d.ts +43 -0
  83. package/dist/types/services/task/index.d.ts +650 -0
  84. package/dist/types/services/task/types.d.ts +1319 -0
  85. package/dist/types/types.d.ts +643 -0
  86. package/dist/types/utils/PageCache.d.ts +173 -0
  87. package/dist/types/webex-config.d.ts +53 -0
  88. package/dist/types/webex.d.ts +7 -0
  89. package/dist/types.js +14 -1
  90. package/dist/types.js.map +1 -1
  91. package/dist/webex.js +1 -1
  92. package/package.json +9 -9
  93. package/src/cc.ts +157 -30
  94. package/src/constants.ts +4 -0
  95. package/src/index.ts +1 -0
  96. package/src/metrics/behavioral-events.ts +14 -0
  97. package/src/metrics/constants.ts +11 -0
  98. package/src/services/ApiAiAssistant.ts +217 -0
  99. package/src/services/agent/types.ts +1 -1
  100. package/src/services/config/Util.ts +8 -0
  101. package/src/services/config/constants.ts +12 -0
  102. package/src/services/config/index.ts +45 -1
  103. package/src/services/config/types.ts +67 -0
  104. package/src/services/constants.ts +29 -0
  105. package/src/services/core/Err.ts +1 -0
  106. package/src/services/core/Utils.ts +32 -5
  107. package/src/services/core/aqm-reqs.ts +100 -22
  108. package/src/services/core/websocket/WebSocketManager.ts +21 -6
  109. package/src/services/core/websocket/connection-service.ts +5 -1
  110. package/src/services/index.ts +4 -0
  111. package/src/services/task/TaskManager.ts +174 -27
  112. package/src/services/task/TaskUtils.ts +12 -0
  113. package/src/services/task/constants.ts +16 -0
  114. package/src/services/task/dialer.ts +56 -1
  115. package/src/services/task/types.ts +24 -0
  116. package/src/types.ts +40 -1
  117. package/test/unit/spec/cc.ts +163 -23
  118. package/test/unit/spec/services/ApiAiAssistant.ts +115 -0
  119. package/test/unit/spec/services/config/index.ts +56 -0
  120. package/test/unit/spec/services/core/Utils.ts +63 -1
  121. package/test/unit/spec/services/core/websocket/WebSocketManager.ts +82 -12
  122. package/test/unit/spec/services/core/websocket/connection-service.ts +3 -1
  123. package/test/unit/spec/services/task/TaskManager.ts +1119 -251
  124. package/test/unit/spec/services/task/dialer.ts +198 -112
  125. package/umd/contact-center.min.js +2 -2
  126. package/umd/contact-center.min.js.map +1 -1
@@ -0,0 +1,650 @@
1
+ /// <reference types="node" />
2
+ import EventEmitter from 'events';
3
+ import { CallId } from '@webex/calling/dist/types/common/types';
4
+ import routingContact from './contact';
5
+ import { ITask, TaskResponse, TaskData, TaskId, WrapupPayLoad, ResumeRecordingPayload, ConsultPayload, ConsultEndPayload, TransferPayLoad, ConsultTransferPayLoad } from './types';
6
+ import WebCallingService from '../WebCallingService';
7
+ import AutoWrapup from './AutoWrapup';
8
+ import { WrapupData } from '../config/types';
9
+ /**
10
+ * Task class represents a contact center task/interaction that can be managed by an agent.
11
+ * This class provides all the necessary methods to manage tasks in a contact center environment,
12
+ * handling various call control operations and task lifecycle management.
13
+ *
14
+ * - Task Lifecycle Management:
15
+ * - {@link accept} - Accept incoming task
16
+ * - {@link decline} - Decline incoming task
17
+ * - {@link end} - End active task
18
+ * - Media Controls:
19
+ * - {@link toggleMute} - Mute/unmute microphone for voice tasks
20
+ * - {@link hold} - Place task on hold
21
+ * - {@link resume} - Resume held task
22
+ * - Recording Controls:
23
+ * - {@link pauseRecording} - Pause task recording
24
+ * - {@link resumeRecording} - Resume paused recording
25
+ * - Task Transfer & Consultation:
26
+ * - {@link consult} - Initiate consultation with another agent/queue
27
+ * - {@link endConsult} - End ongoing consultation
28
+ * - {@link transfer} - Transfer task to another agent/queue
29
+ * - {@link consultTransfer} - Transfer after consultation
30
+ * - Task Completion:
31
+ * - {@link wrapup} - Complete task wrap-up
32
+ *
33
+ * Key events emitted by Task instances (see {@link TASK_EVENTS} for details):
34
+ *
35
+ * - Task Lifecycle:
36
+ * - task:incoming — New task is being offered
37
+ * - task:assigned — Task assigned to agent
38
+ * - task:unassigned — Task unassigned from agent
39
+ * - task:end — Task has ended
40
+ * - task:wrapup — Task entered wrap-up state
41
+ * - task:wrappedup — Task wrap-up completed
42
+ * - task:rejected — Task was rejected/unanswered
43
+ * - task:hydrate — Task data populated
44
+ *
45
+ * - Media & Controls:
46
+ * - task:media — Voice call media track received
47
+ * - task:hold — Task placed on hold
48
+ * - task:unhold — Task resumed from hold
49
+ *
50
+ * - Consultation & Transfer:
51
+ * - task:consultCreated — Consultation initiated
52
+ * - task:consulting — Consultation in progress
53
+ * - task:consultAccepted — Consultation accepted
54
+ * - task:consultEnd — Consultation ended
55
+ * - task:consultQueueCancelled — Queue consultation cancelled
56
+ * - task:consultQueueFailed — Queue consultation failed
57
+ * - task:offerConsult — Consultation offered
58
+ * - task:offerContact — New contact offered
59
+ *
60
+ * - Recording:
61
+ * - task:recordingPaused — Recording paused
62
+ * - task:recordingPauseFailed — Recording pause failed
63
+ * - task:recordingResumed — Recording resumed
64
+ * - task:recordingResumeFailed — Recording resume failed
65
+ *
66
+ * @implements {ITask}
67
+ * @example
68
+ * ```typescript
69
+ * // 1. Initialize task
70
+ * const task = new Task(contact, webCallingService, taskData);
71
+ *
72
+ * // 2. Set up event listeners
73
+ * task.on('task:media', (track) => {
74
+ * // Handle voice call media
75
+ * const audioElement = document.getElementById('remote-audio');
76
+ * audioElement.srcObject = new MediaStream([track]);
77
+ * });
78
+ *
79
+ * task.on('task:hold', () => {
80
+ * console.log('Task is on hold');
81
+ * // Update UI to show hold state
82
+ * });
83
+ *
84
+ * task.on('task:end', () => {
85
+ * console.log('Task ended');
86
+ * if (task.data.wrapUpRequired) {
87
+ * // Show wrap-up form
88
+ * }
89
+ * });
90
+ *
91
+ * // 3. Example task operations
92
+ * await task.accept(); // Accept incoming task
93
+ * await task.hold(); // Place on hold
94
+ * await task.resume(); // Resume from hold
95
+ * await task.end(); // End task
96
+ *
97
+ * // 4. Handle wrap-up if required
98
+ * await task.wrapup({
99
+ * auxCodeId: 'RESOLVED',
100
+ * wrapUpReason: 'Customer issue resolved'
101
+ * });
102
+ * ```
103
+ */
104
+ export default class Task extends EventEmitter implements ITask {
105
+ private contact;
106
+ private localAudioStream;
107
+ private webCallingService;
108
+ data: TaskData;
109
+ private metricsManager;
110
+ webCallMap: Record<TaskId, CallId>;
111
+ private wrapupData;
112
+ autoWrapup?: AutoWrapup;
113
+ private agentId;
114
+ /**
115
+ * Creates a new Task instance which provides the following features:
116
+ * @param contact - The routing contact service instance
117
+ * @param webCallingService - The web calling service instance
118
+ * @param data - Initial task data
119
+ * @param wrapupData - Wrap-up configuration data
120
+ */
121
+ constructor(contact: ReturnType<typeof routingContact>, webCallingService: WebCallingService, data: TaskData, wrapupData: WrapupData, agentId: string);
122
+ /**
123
+ * Sets up the automatic wrap-up timer if wrap-up is required
124
+ * @private
125
+ */
126
+ private setupAutoWrapupTimer;
127
+ /**
128
+ * Cancels the automatic wrap-up timer if it's running
129
+ * @public - Public so it can be called externally when needed
130
+ * Note: This is supported only in single session mode. Not supported in multi-session mode.
131
+ */
132
+ cancelAutoWrapupTimer(): void;
133
+ /**
134
+ * @ignore
135
+ * @private
136
+ */
137
+ private handleRemoteMedia;
138
+ /**
139
+ * @ignore
140
+ * @private
141
+ */
142
+ private registerWebCallListeners;
143
+ /**
144
+ * @ignore
145
+ */
146
+ unregisterWebCallListeners(): void;
147
+ /**
148
+ * Updates the task data with new information
149
+ * @param updatedData - New task data to merge with existing data
150
+ * @param shouldOverwrite - If true, completely replace data instead of merging
151
+ * @returns The updated task instance
152
+ * @example
153
+ * ```typescript
154
+ * task.updateTaskData(newData);
155
+ * task.updateTaskData(newData, true); // completely replace data
156
+ * ```
157
+ */
158
+ updateTaskData: (updatedData: TaskData, shouldOverwrite?: boolean) => this;
159
+ /**
160
+ * Recursively merges old data with new data
161
+ * @private
162
+ */
163
+ private reconcileData;
164
+ /**
165
+ * Agent accepts the incoming task.
166
+ * After accepting, the task will emit task:assigned event and for voice calls,
167
+ * a task:media event with the audio stream.
168
+ *
169
+ * @returns Promise<TaskResponse>
170
+ * @throws Error if accepting task fails or media requirements not met
171
+ * @example
172
+ * ```typescript
173
+ * // Set up event handlers before accepting
174
+ * task.on(TASK_EVENTS.TASK_ASSIGNED, () => {
175
+ * console.log('Task assigned, ID:', task.data.interactionId);
176
+ * // Update UI to show active task
177
+ * });
178
+ *
179
+ * // For voice calls, handle media
180
+ * task.on(TASK_EVENTS.TASK_MEDIA, (track) => {
181
+ * const audioElement = document.getElementById('remote-audio');
182
+ * audioElement.srcObject = new MediaStream([track]);
183
+ * });
184
+ *
185
+ * // Accept the task
186
+ * try {
187
+ * await task.accept();
188
+ * console.log('Successfully accepted task');
189
+ * } catch (error) {
190
+ * console.error('Failed to accept task:', error);
191
+ * // Handle error (e.g., show error message to agent)
192
+ * }
193
+ * ```
194
+ */
195
+ accept(): Promise<TaskResponse>;
196
+ /**
197
+ * Agent can mute/unmute their microphone during a WebRTC task.
198
+ * This method toggles between muted and unmuted states for the local audio stream.
199
+ *
200
+ * @returns Promise<void> - Resolves when mute/unmute operation completes
201
+ * @throws Error if toggling mute state fails or audio stream is not available
202
+ * @example
203
+ * ```typescript
204
+ * // Toggle mute state
205
+ * task.toggleMute()
206
+ * .then(() => console.log('Mute state toggled successfully'))
207
+ * .catch(error => console.error('Failed to toggle mute:', error));
208
+ * ```
209
+ */
210
+ toggleMute(): Promise<void>;
211
+ /**
212
+ * Declines the incoming task. This will reject the task and notify the routing system.
213
+ * For voice calls, this is equivalent to declining the incoming call.
214
+ *
215
+ * @returns Promise<TaskResponse>
216
+ * @throws Error if the decline operation fails
217
+ * @example
218
+ * ```typescript
219
+ * // Decline an incoming task
220
+ * task.decline()
221
+ * .then(() => console.log('Task declined successfully'))
222
+ * .catch(error => console.error('Failed to decline task:', error));
223
+ * ```
224
+ */
225
+ decline(): Promise<TaskResponse>;
226
+ /**
227
+ * Puts the current task/interaction on hold.
228
+ * Emits task:hold event when successful. For voice tasks, this mutes the audio.
229
+ *
230
+ * @param mediaResourceId - Optional media resource ID to use for the hold operation. If not provided, uses the task's current mediaResourceId
231
+ * @returns Promise<TaskResponse>
232
+ * @throws Error if hold operation fails
233
+ * @example
234
+ * ```typescript
235
+ * // Set up hold event handler
236
+ * task.on(TASK_EVENTS.TASK_HOLD, () => {
237
+ * console.log('Task is now on hold');
238
+ * // Update UI to show hold state (e.g., enable resume button, show hold indicator)
239
+ * document.getElementById('resume-btn').disabled = false;
240
+ * document.getElementById('hold-indicator').style.display = 'block';
241
+ * });
242
+ *
243
+ * // Place task on hold
244
+ * try {
245
+ * await task.hold();
246
+ * console.log('Successfully placed task on hold');
247
+ * } catch (error) {
248
+ * console.error('Failed to place task on hold:', error);
249
+ * // Handle error (e.g., show error message, reset UI state)
250
+ * }
251
+ *
252
+ * // Place task on hold with custom mediaResourceId
253
+ * try {
254
+ * await task.hold('custom-media-resource-id');
255
+ * console.log('Successfully placed task on hold with custom mediaResourceId');
256
+ * } catch (error) {
257
+ * console.error('Failed to place task on hold:', error);
258
+ * }
259
+ * ```
260
+ */
261
+ hold(mediaResourceId?: string): Promise<TaskResponse>;
262
+ /**
263
+ * Resumes the task/interaction that was previously put on hold.
264
+ * Emits task:resume event when successful. For voice tasks, this restores the audio.
265
+ *
266
+ * @param mediaResourceId - Optional media resource ID to use for the resume operation. If not provided, uses the task's current mediaResourceId from interaction media
267
+ * @returns Promise<TaskResponse>
268
+ * @throws Error if resume operation fails
269
+ * @example
270
+ * ```typescript
271
+ * // Set up resume event handler
272
+ * task.on(TASK_EVENTS.TASK_RESUME, () => {
273
+ * console.log('Task resumed from hold');
274
+ * // Update UI to show active state
275
+ * document.getElementById('hold-btn').disabled = false;
276
+ * document.getElementById('hold-indicator').style.display = 'none';
277
+ * });
278
+ *
279
+ * // Resume task from hold
280
+ * try {
281
+ * await task.resume();
282
+ * console.log('Successfully resumed task from hold');
283
+ * } catch (error) {
284
+ * console.error('Failed to resume task:', error);
285
+ * // Handle error (e.g., show error message)
286
+ * }
287
+ *
288
+ * // Resume task from hold with custom mediaResourceId
289
+ * try {
290
+ * await task.resume('custom-media-resource-id');
291
+ * console.log('Successfully resumed task from hold with custom mediaResourceId');
292
+ * } catch (error) {
293
+ * console.error('Failed to resume task:', error);
294
+ * }
295
+ * ```
296
+ */
297
+ resume(mediaResourceId?: string): Promise<TaskResponse>;
298
+ /**
299
+ * Ends the task/interaction with the customer.
300
+ * Emits task:end event when successful. If task requires wrap-up,
301
+ * this will be indicated in the task:end event data.
302
+ *
303
+ * @returns Promise<TaskResponse>
304
+ * @throws Error if ending task fails
305
+ * @example
306
+ * ```typescript
307
+ * // Set up task end event handler
308
+ * task.on(TASK_EVENTS.TASK_END, (data) => {
309
+ * console.log('Task ended:', task.data.interactionId);
310
+ *
311
+ * if (data.wrapUpRequired) {
312
+ * // Show wrap-up form
313
+ * showWrapupForm();
314
+ * } else {
315
+ * // Clean up and prepare for next task
316
+ * cleanupTask();
317
+ * }
318
+ * });
319
+ *
320
+ * // End the task
321
+ * try {
322
+ * await task.end();
323
+ * console.log('Task end request successful');
324
+ * } catch (error) {
325
+ * console.error('Failed to end task:', error);
326
+ * // Handle error (e.g., show error message, retry option)
327
+ * }
328
+ *
329
+ * function showWrapupForm() {
330
+ * // Show wrap-up UI with required codes
331
+ * document.getElementById('wrapup-form').style.display = 'block';
332
+ * }
333
+ *
334
+ * function cleanupTask() {
335
+ * // Reset UI state
336
+ * document.getElementById('active-task').style.display = 'none';
337
+ * document.getElementById('controls').style.display = 'none';
338
+ * }
339
+ * ```
340
+ */
341
+ end(): Promise<TaskResponse>;
342
+ /**
343
+ * Wraps up the task/interaction with the customer.
344
+ * This is called after task:end event if wrapUpRequired is true.
345
+ * Emits task:wrappedup event when successful.
346
+ *
347
+ * @param wrapupPayload - WrapupPayLoad containing:
348
+ * - auxCodeId: Required ID for the wrap-up code
349
+ * - wrapUpReason: Required description of wrap-up reason
350
+ * @returns Promise<TaskResponse>
351
+ * @throws Error if task data is unavailable, auxCodeId is missing, or wrapUpReason is missing
352
+ * @example
353
+ * ```typescript
354
+ * // Set up wrap-up events
355
+ * task.on(TASK_EVENTS.TASK_WRAPUP, () => {
356
+ * console.log('Task ready for wrap-up');
357
+ * // Show wrap-up form
358
+ * document.getElementById('wrapup-form').style.display = 'block';
359
+ * });
360
+ *
361
+ * task.on(TASK_EVENTS.TASK_WRAPPEDUP, () => {
362
+ * console.log('Task wrap-up completed');
363
+ * // Clean up UI
364
+ * document.getElementById('wrapup-form').style.display = 'none';
365
+ * });
366
+ *
367
+ * // Submit wrap-up
368
+ * try {
369
+ * const wrapupPayload = {
370
+ * auxCodeId: selectedCode, // e.g., 'ISSUE_RESOLVED'
371
+ * wrapUpReason: 'Customer issue resolved successfully'
372
+ * };
373
+ * await task.wrapup(wrapupPayload);
374
+ * console.log('Successfully submitted wrap-up');
375
+ * } catch (error) {
376
+ * console.error('Failed to submit wrap-up:', error);
377
+ * // Handle validation errors
378
+ * if (error.message.includes('required')) {
379
+ * // Show validation error to agent
380
+ * }
381
+ * }
382
+ * ```
383
+ */
384
+ wrapup(wrapupPayload: WrapupPayLoad): Promise<TaskResponse>;
385
+ /**
386
+ * Pauses the recording for the current voice task.
387
+ * Emits task:recordingPaused event when successful.
388
+ *
389
+ * @returns Promise<TaskResponse>
390
+ * @throws Error if pause recording fails
391
+ * @example
392
+ * ```typescript
393
+ * // Set up recording events
394
+ * task.on(TASK_EVENTS.TASK_RECORDING_PAUSED, () => {
395
+ * console.log('Recording paused');
396
+ * // Update UI to show recording paused state
397
+ * document.getElementById('recording-status').textContent = 'Recording Paused';
398
+ * document.getElementById('pause-recording-btn').style.display = 'none';
399
+ * document.getElementById('resume-recording-btn').style.display = 'block';
400
+ * });
401
+ *
402
+ * task.on(TASK_EVENTS.TASK_RECORDING_PAUSE_FAILED, (error) => {
403
+ * console.error('Failed to pause recording:', error);
404
+ * // Show error to agent
405
+ * });
406
+ *
407
+ * // Pause recording
408
+ * try {
409
+ * await task.pauseRecording();
410
+ * console.log('Pause recording request sent');
411
+ * } catch (error) {
412
+ * console.error('Error sending pause recording request:', error);
413
+ * // Handle error
414
+ * }
415
+ * ```
416
+ */
417
+ pauseRecording(): Promise<TaskResponse>;
418
+ /**
419
+ * Resumes the recording for the voice task that was previously paused.
420
+ * Emits task:recordingResumed event when successful.
421
+ *
422
+ * @param resumeRecordingPayload - Configuration for resuming recording:
423
+ * - autoResumed: Indicates if resume was automatic (defaults to false)
424
+ * @returns Promise<TaskResponse>
425
+ * @throws Error if resume recording fails
426
+ * @example
427
+ * ```typescript
428
+ * // Set up recording resume events
429
+ * task.on(TASK_EVENTS.TASK_RECORDING_RESUMED, () => {
430
+ * console.log('Recording resumed');
431
+ * // Update UI to show active recording state
432
+ * document.getElementById('recording-status').textContent = 'Recording Active';
433
+ * document.getElementById('pause-recording-btn').style.display = 'block';
434
+ * document.getElementById('resume-recording-btn').style.display = 'none';
435
+ * });
436
+ *
437
+ * task.on(TASK_EVENTS.TASK_RECORDING_RESUME_FAILED, (error) => {
438
+ * console.error('Failed to resume recording:', error);
439
+ * // Show error to agent
440
+ * });
441
+ *
442
+ * // Resume recording
443
+ * try {
444
+ * const resumePayload = {
445
+ * autoResumed: false // Set to true if triggered by system
446
+ * };
447
+ * await task.resumeRecording(resumePayload);
448
+ * console.log('Resume recording request sent');
449
+ * } catch (error) {
450
+ * console.error('Error sending resume recording request:', error);
451
+ * // Handle error
452
+ * }
453
+ * ```
454
+ */
455
+ resumeRecording(resumeRecordingPayload: ResumeRecordingPayload): Promise<TaskResponse>;
456
+ /**
457
+ * Consults another agent or queue on an ongoing task for further assistance.
458
+ * During consultation, the original customer is typically placed on hold while
459
+ * the agent seeks guidance from another agent or queue.
460
+ *
461
+ * @param consultPayload - Configuration for the consultation containing:
462
+ * - to: ID of the agent or queue to consult with
463
+ * - destinationType: Type of destination (AGENT, QUEUE, etc.)
464
+ * - holdParticipants: Whether to hold other participants (defaults to true)
465
+ * @returns Promise<TaskResponse> - Resolves with consultation result
466
+ * @throws Error if consultation fails or invalid parameters provided
467
+ * @example
468
+ * ```typescript
469
+ * // Consult with another agent
470
+ * const consultPayload = {
471
+ * to: 'agentId123',
472
+ * destinationType: DESTINATION_TYPE.AGENT,
473
+ * holdParticipants: true
474
+ * };
475
+ * task.consult(consultPayload)
476
+ * .then(response => console.log('Consultation started successfully'))
477
+ * .catch(error => console.error('Failed to start consultation:', error));
478
+ *
479
+ * // Consult with a queue
480
+ * const queueConsultPayload = {
481
+ * to: 'salesQueue123',
482
+ * destinationType: DESTINATION_TYPE.QUEUE
483
+ * };
484
+ * task.consult(queueConsultPayload)
485
+ * .then(response => console.log('Queue consultation started'))
486
+ * .catch(error => console.error('Failed to start queue consultation:', error));
487
+ * ```
488
+ */
489
+ consult(consultPayload: ConsultPayload): Promise<TaskResponse>;
490
+ /**
491
+ * Ends an ongoing consultation session for the task.
492
+ * This terminates the consultation while maintaining the original customer connection.
493
+ *
494
+ * @param consultEndPayload - Configuration for ending the consultation containing:
495
+ * - isConsult: Must be true to indicate this is a consultation end
496
+ * - taskId: ID of the task being consulted on
497
+ * - queueId: (Optional) Queue ID if this was a queue consultation
498
+ * - isSecondaryEpDnAgent: (Optional) Indicates if this involves a secondary entry point
499
+ * @returns Promise<TaskResponse> - Resolves when consultation is ended
500
+ * @throws Error if ending consultation fails or invalid parameters provided
501
+ * @example
502
+ * ```typescript
503
+ * // End a direct agent consultation
504
+ * const consultEndPayload = {
505
+ * isConsult: true,
506
+ * taskId: 'task123'
507
+ * };
508
+ * task.endConsult(consultEndPayload)
509
+ * .then(response => console.log('Consultation ended successfully'))
510
+ * .catch(error => console.error('Failed to end consultation:', error));
511
+ *
512
+ * // End a queue consultation
513
+ * const queueConsultEndPayload = {
514
+ * isConsult: true,
515
+ * taskId: 'task123',
516
+ * queueId: 'queue123'
517
+ * };
518
+ * task.endConsult(queueConsultEndPayload)
519
+ * .then(response => console.log('Queue consultation ended'))
520
+ * .catch(error => console.error('Failed to end queue consultation:', error));
521
+ * ```
522
+ */
523
+ endConsult(consultEndPayload: ConsultEndPayload): Promise<TaskResponse>;
524
+ /**
525
+ * Transfer the task to an agent directly or to a queue.
526
+ * This is a blind transfer that immediately redirects the task to the specified destination.
527
+ *
528
+ * @param transferPayload - Transfer configuration containing:
529
+ * - to: ID of the agent or queue to transfer to
530
+ * - destinationType: Type of destination (AGENT, QUEUE, etc.)
531
+ * @returns Promise<TaskResponse> - Resolves when transfer is completed
532
+ * @throws Error if transfer fails or invalid parameters provided
533
+ * @example
534
+ * ```typescript
535
+ * // Transfer to a queue
536
+ * const queueTransferPayload = {
537
+ * to: 'salesQueue123',
538
+ * destinationType: DESTINATION_TYPE.QUEUE
539
+ * };
540
+ * task.transfer(queueTransferPayload)
541
+ * .then(response => console.log('Task transferred to queue successfully'))
542
+ * .catch(error => console.error('Failed to transfer to queue:', error));
543
+ *
544
+ * // Transfer to an agent
545
+ * const agentTransferPayload = {
546
+ * to: 'agentId123',
547
+ * destinationType: DESTINATION_TYPE.AGENT
548
+ * };
549
+ * task.transfer(agentTransferPayload)
550
+ * .then(response => console.log('Task transferred to agent successfully'))
551
+ * .catch(error => console.error('Failed to transfer to agent:', error));
552
+ * ```
553
+ */
554
+ transfer(transferPayload: TransferPayLoad): Promise<TaskResponse>;
555
+ /**
556
+ * Transfer the task to the party that was consulted.
557
+ * This completes a consultative transfer where the agent first consulted with the target
558
+ * before transferring the task. For queue consultations, the transfer is automatically
559
+ * directed to the agent who accepted the consultation.
560
+ *
561
+ * @param consultTransferPayload - Configuration for the consultation transfer containing:
562
+ * - to: ID of the agent or queue to transfer to
563
+ * - destinationType: Type of destination (AGENT, QUEUE, etc. from CONSULT_TRANSFER_DESTINATION_TYPE)
564
+ * @returns Promise<TaskResponse> - Resolves when consultation transfer is completed
565
+ * @throws Error if transfer fails, no agent has accepted a queue consultation, or other validation errors
566
+ * @example
567
+ * ```typescript
568
+ * // Complete consultation transfer to an agent
569
+ * const agentConsultTransfer = {
570
+ * to: 'agentId123',
571
+ * destinationType: CONSULT_TRANSFER_DESTINATION_TYPE.AGENT
572
+ * };
573
+ * task.consultTransfer(agentConsultTransfer)
574
+ * .then(response => console.log('Consultation transfer to agent completed'))
575
+ * .catch(error => console.error('Failed to complete agent consultation transfer:', error));
576
+ *
577
+ * // Complete consultation transfer to a queue agent
578
+ * const queueConsultTransfer = {
579
+ * to: 'queue123',
580
+ * destinationType: CONSULT_TRANSFER_DESTINATION_TYPE.QUEUE
581
+ * };
582
+ * task.consultTransfer(queueConsultTransfer)
583
+ * .then(response => console.log('Consultation transfer to queue agent completed'))
584
+ * .catch(error => console.error('Failed to complete queue consultation transfer:', error));
585
+ * ```
586
+ */
587
+ consultTransfer(consultTransferPayload?: ConsultTransferPayLoad): Promise<TaskResponse>;
588
+ /**
589
+ * Starts a consultation conference by merging the consultation call with the main call
590
+ *
591
+ * Creates a three-way conference between the agent, customer, and consulted party
592
+ * Extracts required consultation data from the current task data
593
+ * On success, emits a `task:conferenceStarted` event
594
+ *
595
+ * @returns Promise<TaskResponse> - Response from the consultation conference API
596
+ * @throws Error if the operation fails or if consultation data is invalid
597
+ *
598
+ * @example
599
+ * ```typescript
600
+ * try {
601
+ * await task.consultConference();
602
+ * console.log('Conference started successfully');
603
+ * } catch (error) {
604
+ * console.error('Failed to start conference:', error);
605
+ * }
606
+ * ```
607
+ */
608
+ consultConference(): Promise<TaskResponse>;
609
+ /**
610
+ * Exits the current conference by removing the agent from the conference call
611
+ *
612
+ * Exits the agent from the conference, leaving the customer and consulted party connected
613
+ * On success, emits a `task:conferenceEnded` event
614
+ *
615
+ * @returns Promise<TaskResponse> - Response from the conference exit API
616
+ * @throws Error if the operation fails or if no active conference exists
617
+ *
618
+ * @example
619
+ * ```typescript
620
+ * try {
621
+ * await task.exitConference();
622
+ * console.log('Successfully exited conference');
623
+ * } catch (error) {
624
+ * console.error('Failed to exit conference:', error);
625
+ * }
626
+ * ```
627
+ */
628
+ exitConference(): Promise<TaskResponse>;
629
+ /**
630
+ * Transfers the current conference to another agent
631
+ *
632
+ * Moves the entire conference (including all participants) to a new agent,
633
+ * while the current agent exits and goes to wrapup
634
+ * On success, the current agent receives `task:conferenceEnded` event
635
+ *
636
+ * @returns Promise<TaskResponse> - Response from the conference transfer API
637
+ * @throws Error if the operation fails or if no active conference exists
638
+ *
639
+ * @example
640
+ * ```typescript
641
+ * try {
642
+ * await task.transferConference();
643
+ * console.log('Conference transferred successfully');
644
+ * } catch (error) {
645
+ * console.error('Failed to transfer conference:', error);
646
+ * }
647
+ * ```
648
+ */
649
+ transferConference(): Promise<TaskResponse>;
650
+ }