@webex/contact-center 3.9.0-next.9 → 3.10.0-multi-llms.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.
- package/dist/cc.js +193 -47
- package/dist/cc.js.map +1 -1
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/logger-proxy.js +24 -1
- package/dist/logger-proxy.js.map +1 -1
- package/dist/metrics/behavioral-events.js +89 -0
- package/dist/metrics/behavioral-events.js.map +1 -1
- package/dist/metrics/constants.js +30 -2
- package/dist/metrics/constants.js.map +1 -1
- package/dist/services/AddressBook.js +271 -0
- package/dist/services/AddressBook.js.map +1 -0
- package/dist/services/EntryPoint.js +227 -0
- package/dist/services/EntryPoint.js.map +1 -0
- package/dist/services/Queue.js +261 -0
- package/dist/services/Queue.js.map +1 -0
- package/dist/services/config/constants.js +36 -2
- package/dist/services/config/constants.js.map +1 -1
- package/dist/services/config/index.js +29 -21
- package/dist/services/config/index.js.map +1 -1
- package/dist/services/config/types.js +33 -1
- package/dist/services/config/types.js.map +1 -1
- package/dist/services/core/Utils.js +91 -31
- package/dist/services/core/Utils.js.map +1 -1
- package/dist/services/core/constants.js +17 -1
- package/dist/services/core/constants.js.map +1 -1
- package/dist/services/task/TaskManager.js +150 -7
- package/dist/services/task/TaskManager.js.map +1 -1
- package/dist/services/task/TaskUtils.js +104 -0
- package/dist/services/task/TaskUtils.js.map +1 -0
- package/dist/services/task/constants.js +26 -1
- package/dist/services/task/constants.js.map +1 -1
- package/dist/services/task/contact.js +86 -0
- package/dist/services/task/contact.js.map +1 -1
- package/dist/services/task/index.js +302 -39
- package/dist/services/task/index.js.map +1 -1
- package/dist/services/task/types.js +12 -0
- package/dist/services/task/types.js.map +1 -1
- package/dist/types/cc.d.ts +121 -35
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/index.d.ts +4 -3
- package/dist/types/metrics/constants.d.ts +24 -1
- package/dist/types/services/AddressBook.d.ts +74 -0
- package/dist/types/services/EntryPoint.d.ts +67 -0
- package/dist/types/services/Queue.d.ts +76 -0
- package/dist/types/services/config/constants.d.ts +35 -1
- package/dist/types/services/config/index.d.ts +6 -9
- package/dist/types/services/config/types.d.ts +79 -58
- package/dist/types/services/core/Utils.d.ts +33 -5
- package/dist/types/services/core/constants.d.ts +14 -0
- package/dist/types/services/task/TaskUtils.d.ts +42 -0
- package/dist/types/services/task/constants.d.ts +23 -0
- package/dist/types/services/task/contact.d.ts +10 -0
- package/dist/types/services/task/index.d.ts +84 -3
- package/dist/types/services/task/types.d.ts +245 -21
- package/dist/types/types.d.ts +162 -0
- package/dist/types/utils/PageCache.d.ts +173 -0
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -1
- package/dist/utils/PageCache.js +192 -0
- package/dist/utils/PageCache.js.map +1 -0
- package/dist/webex.js +1 -1
- package/package.json +10 -9
- package/src/cc.ts +217 -52
- package/src/constants.ts +1 -0
- package/src/index.ts +17 -2
- package/src/logger-proxy.ts +24 -1
- package/src/metrics/behavioral-events.ts +94 -0
- package/src/metrics/constants.ts +34 -1
- package/src/services/AddressBook.ts +291 -0
- package/src/services/EntryPoint.ts +241 -0
- package/src/services/Queue.ts +277 -0
- package/src/services/config/constants.ts +42 -2
- package/src/services/config/index.ts +30 -30
- package/src/services/config/types.ts +59 -58
- package/src/services/core/Utils.ts +101 -41
- package/src/services/core/constants.ts +16 -0
- package/src/services/task/TaskManager.ts +181 -9
- package/src/services/task/TaskUtils.ts +113 -0
- package/src/services/task/constants.ts +25 -0
- package/src/services/task/contact.ts +80 -0
- package/src/services/task/index.ts +364 -54
- package/src/services/task/types.ts +264 -20
- package/src/types.ts +180 -0
- package/src/utils/PageCache.ts +252 -0
- package/test/unit/spec/cc.ts +282 -85
- package/test/unit/spec/metrics/behavioral-events.ts +42 -0
- package/test/unit/spec/services/AddressBook.ts +332 -0
- package/test/unit/spec/services/EntryPoint.ts +259 -0
- package/test/unit/spec/services/Queue.ts +323 -0
- package/test/unit/spec/services/config/index.ts +279 -65
- package/test/unit/spec/services/core/Utils.ts +262 -31
- package/test/unit/spec/services/task/TaskManager.ts +752 -1
- package/test/unit/spec/services/task/TaskUtils.ts +131 -0
- package/test/unit/spec/services/task/contact.ts +31 -1
- package/test/unit/spec/services/task/index.ts +675 -69
- package/umd/contact-center.min.js +2 -2
- package/umd/contact-center.min.js.map +1 -1
|
@@ -120,7 +120,7 @@ class Task extends _events.default {
|
|
|
120
120
|
* @param data - Initial task data
|
|
121
121
|
* @param wrapupData - Wrap-up configuration data
|
|
122
122
|
*/
|
|
123
|
-
constructor(contact, webCallingService, data, wrapupData) {
|
|
123
|
+
constructor(contact, webCallingService, data, wrapupData, agentId) {
|
|
124
124
|
super();
|
|
125
125
|
this.contact = contact;
|
|
126
126
|
this.data = data;
|
|
@@ -130,6 +130,7 @@ class Task extends _events.default {
|
|
|
130
130
|
this.metricsManager = _MetricsManager.default.getInstance();
|
|
131
131
|
this.registerWebCallListeners();
|
|
132
132
|
this.setupAutoWrapupTimer();
|
|
133
|
+
this.agentId = agentId;
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
/**
|
|
@@ -244,11 +245,17 @@ class Task extends _events.default {
|
|
|
244
245
|
* @private
|
|
245
246
|
*/
|
|
246
247
|
reconcileData(oldData, newData) {
|
|
248
|
+
// Remove keys from oldData that are not in newData
|
|
249
|
+
Object.keys(oldData).forEach(key => {
|
|
250
|
+
if (!(key in newData) && !_constants2.KEYS_TO_NOT_DELETE.includes(key)) {
|
|
251
|
+
delete oldData[key];
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
// Merge or update keys from newData
|
|
247
256
|
Object.keys(newData).forEach(key => {
|
|
248
|
-
if (newData[key] && typeof newData[key] === 'object' && !Array.isArray(newData[key])) {
|
|
249
|
-
oldData[key]
|
|
250
|
-
...oldData[key]
|
|
251
|
-
}, newData[key]);
|
|
257
|
+
if (newData[key] && typeof newData[key] === 'object' && !Array.isArray(newData[key]) && oldData[key] && typeof oldData[key] === 'object' && !Array.isArray(oldData[key])) {
|
|
258
|
+
this.reconcileData(oldData[key], newData[key]);
|
|
252
259
|
} else {
|
|
253
260
|
oldData[key] = newData[key];
|
|
254
261
|
}
|
|
@@ -439,6 +446,7 @@ class Task extends _events.default {
|
|
|
439
446
|
* Puts the current task/interaction on hold.
|
|
440
447
|
* Emits task:hold event when successful. For voice tasks, this mutes the audio.
|
|
441
448
|
*
|
|
449
|
+
* @param mediaResourceId - Optional media resource ID to use for the hold operation. If not provided, uses the task's current mediaResourceId
|
|
442
450
|
* @returns Promise<TaskResponse>
|
|
443
451
|
* @throws Error if hold operation fails
|
|
444
452
|
* @example
|
|
@@ -459,9 +467,17 @@ class Task extends _events.default {
|
|
|
459
467
|
* console.error('Failed to place task on hold:', error);
|
|
460
468
|
* // Handle error (e.g., show error message, reset UI state)
|
|
461
469
|
* }
|
|
470
|
+
*
|
|
471
|
+
* // Place task on hold with custom mediaResourceId
|
|
472
|
+
* try {
|
|
473
|
+
* await task.hold('custom-media-resource-id');
|
|
474
|
+
* console.log('Successfully placed task on hold with custom mediaResourceId');
|
|
475
|
+
* } catch (error) {
|
|
476
|
+
* console.error('Failed to place task on hold:', error);
|
|
477
|
+
* }
|
|
462
478
|
* ```
|
|
463
479
|
*/
|
|
464
|
-
async hold() {
|
|
480
|
+
async hold(mediaResourceId) {
|
|
465
481
|
try {
|
|
466
482
|
_loggerProxy.default.info(`Holding task`, {
|
|
467
483
|
module: _constants.TASK_FILE,
|
|
@@ -469,16 +485,17 @@ class Task extends _events.default {
|
|
|
469
485
|
interactionId: this.data.interactionId
|
|
470
486
|
});
|
|
471
487
|
this.metricsManager.timeEvent([_constants3.METRIC_EVENT_NAMES.TASK_HOLD_SUCCESS, _constants3.METRIC_EVENT_NAMES.TASK_HOLD_FAILED]);
|
|
488
|
+
const effectiveMediaResourceId = mediaResourceId ?? this.data.mediaResourceId;
|
|
472
489
|
const response = await this.contact.hold({
|
|
473
490
|
interactionId: this.data.interactionId,
|
|
474
491
|
data: {
|
|
475
|
-
mediaResourceId:
|
|
492
|
+
mediaResourceId: effectiveMediaResourceId
|
|
476
493
|
}
|
|
477
494
|
});
|
|
478
495
|
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_HOLD_SUCCESS, {
|
|
479
496
|
..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(response),
|
|
480
497
|
taskId: this.data.interactionId,
|
|
481
|
-
mediaResourceId:
|
|
498
|
+
mediaResourceId: effectiveMediaResourceId
|
|
482
499
|
}, ['operational', 'behavioral']);
|
|
483
500
|
_loggerProxy.default.log(`Task placed on hold successfully`, {
|
|
484
501
|
module: _constants.TASK_FILE,
|
|
@@ -496,9 +513,10 @@ class Task extends _events.default {
|
|
|
496
513
|
errorData: err.data?.errorData,
|
|
497
514
|
reasonCode: err.data?.reasonCode
|
|
498
515
|
};
|
|
516
|
+
const effectiveMediaResourceId = mediaResourceId ?? this.data.mediaResourceId;
|
|
499
517
|
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_HOLD_FAILED, {
|
|
500
518
|
taskId: this.data.interactionId,
|
|
501
|
-
mediaResourceId:
|
|
519
|
+
mediaResourceId: effectiveMediaResourceId,
|
|
502
520
|
error: error.toString(),
|
|
503
521
|
...taskErrorProps,
|
|
504
522
|
..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(error.details || {})
|
|
@@ -511,6 +529,7 @@ class Task extends _events.default {
|
|
|
511
529
|
* Resumes the task/interaction that was previously put on hold.
|
|
512
530
|
* Emits task:resume event when successful. For voice tasks, this restores the audio.
|
|
513
531
|
*
|
|
532
|
+
* @param mediaResourceId - Optional media resource ID to use for the resume operation. If not provided, uses the task's current mediaResourceId from interaction media
|
|
514
533
|
* @returns Promise<TaskResponse>
|
|
515
534
|
* @throws Error if resume operation fails
|
|
516
535
|
* @example
|
|
@@ -531,9 +550,17 @@ class Task extends _events.default {
|
|
|
531
550
|
* console.error('Failed to resume task:', error);
|
|
532
551
|
* // Handle error (e.g., show error message)
|
|
533
552
|
* }
|
|
553
|
+
*
|
|
554
|
+
* // Resume task from hold with custom mediaResourceId
|
|
555
|
+
* try {
|
|
556
|
+
* await task.resume('custom-media-resource-id');
|
|
557
|
+
* console.log('Successfully resumed task from hold with custom mediaResourceId');
|
|
558
|
+
* } catch (error) {
|
|
559
|
+
* console.error('Failed to resume task:', error);
|
|
560
|
+
* }
|
|
534
561
|
* ```
|
|
535
562
|
*/
|
|
536
|
-
async resume() {
|
|
563
|
+
async resume(mediaResourceId) {
|
|
537
564
|
try {
|
|
538
565
|
_loggerProxy.default.info(`Resuming task`, {
|
|
539
566
|
module: _constants.TASK_FILE,
|
|
@@ -543,20 +570,19 @@ class Task extends _events.default {
|
|
|
543
570
|
const {
|
|
544
571
|
mainInteractionId
|
|
545
572
|
} = this.data.interaction;
|
|
546
|
-
const
|
|
547
|
-
|
|
548
|
-
} = this.data.interaction.media[mainInteractionId];
|
|
573
|
+
const defaultMediaResourceId = this.data.interaction.media[mainInteractionId]?.mediaResourceId;
|
|
574
|
+
const effectiveMediaResourceId = mediaResourceId ?? defaultMediaResourceId;
|
|
549
575
|
this.metricsManager.timeEvent([_constants3.METRIC_EVENT_NAMES.TASK_RESUME_SUCCESS, _constants3.METRIC_EVENT_NAMES.TASK_RESUME_FAILED]);
|
|
550
576
|
const response = await this.contact.unHold({
|
|
551
577
|
interactionId: this.data.interactionId,
|
|
552
578
|
data: {
|
|
553
|
-
mediaResourceId
|
|
579
|
+
mediaResourceId: effectiveMediaResourceId
|
|
554
580
|
}
|
|
555
581
|
});
|
|
556
582
|
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_RESUME_SUCCESS, {
|
|
557
583
|
taskId: this.data.interactionId,
|
|
558
584
|
mainInteractionId,
|
|
559
|
-
mediaResourceId,
|
|
585
|
+
mediaResourceId: effectiveMediaResourceId,
|
|
560
586
|
..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(response)
|
|
561
587
|
}, ['operational', 'behavioral']);
|
|
562
588
|
_loggerProxy.default.log(`Task resumed successfully`, {
|
|
@@ -569,6 +595,8 @@ class Task extends _events.default {
|
|
|
569
595
|
} catch (error) {
|
|
570
596
|
const err = (0, _Utils.generateTaskErrorObject)(error, _constants2.METHODS.RESUME, _constants.TASK_FILE);
|
|
571
597
|
const mainInteractionId = this.data.interaction?.mainInteractionId;
|
|
598
|
+
const defaultMediaResourceId = mainInteractionId ? this.data.interaction.media[mainInteractionId]?.mediaResourceId : '';
|
|
599
|
+
const effectiveMediaResourceId = mediaResourceId ?? defaultMediaResourceId;
|
|
572
600
|
const taskErrorProps = {
|
|
573
601
|
trackingId: err.data?.trackingId,
|
|
574
602
|
errorMessage: err.data?.message,
|
|
@@ -579,7 +607,7 @@ class Task extends _events.default {
|
|
|
579
607
|
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_RESUME_FAILED, {
|
|
580
608
|
taskId: this.data.interactionId,
|
|
581
609
|
mainInteractionId,
|
|
582
|
-
mediaResourceId:
|
|
610
|
+
mediaResourceId: effectiveMediaResourceId,
|
|
583
611
|
...taskErrorProps,
|
|
584
612
|
..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(error.details || {})
|
|
585
613
|
}, ['operational', 'behavioral']);
|
|
@@ -1195,27 +1223,27 @@ class Task extends _events.default {
|
|
|
1195
1223
|
* ```
|
|
1196
1224
|
*/
|
|
1197
1225
|
async consultTransfer(consultTransferPayload) {
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
const destAgentId = (0, _Utils.getDestinationAgentId)(this.data.interaction?.participants, this.data.agentId);
|
|
1226
|
+
// Get the destination agent ID using custom logic from participants data
|
|
1227
|
+
const destAgentId = (0, _Utils.calculateDestAgentId)(this.data.interaction, this.agentId);
|
|
1201
1228
|
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
// Obtain payload based on desktop logic using TaskData
|
|
1212
|
-
const finalDestinationType = (0, _Utils.deriveConsultTransferDestinationType)(this.data);
|
|
1229
|
+
// Resolve the target id (queue consult transfers go to the accepted agent)
|
|
1230
|
+
if (!destAgentId) {
|
|
1231
|
+
throw new Error('No agent has accepted this queue consult yet');
|
|
1232
|
+
}
|
|
1233
|
+
_loggerProxy.default.info(`Initiating consult transfer to ${consultTransferPayload?.to || destAgentId}`, {
|
|
1234
|
+
module: _constants.TASK_FILE,
|
|
1235
|
+
method: _constants2.METHODS.CONSULT_TRANSFER,
|
|
1236
|
+
interactionId: this.data.interactionId
|
|
1237
|
+
});
|
|
1213
1238
|
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1239
|
+
// Derive destination type from the participant's type property
|
|
1240
|
+
const destType = (0, _Utils.calculateDestType)(this.data.interaction, this.agentId);
|
|
1241
|
+
// By default we always use the computed destAgentId as the target id
|
|
1242
|
+
const consultTransferRequest = {
|
|
1243
|
+
to: destAgentId,
|
|
1244
|
+
destinationType: destType
|
|
1245
|
+
};
|
|
1246
|
+
try {
|
|
1219
1247
|
const result = await this.contact.consultTransfer({
|
|
1220
1248
|
interactionId: this.data.interactionId,
|
|
1221
1249
|
data: consultTransferRequest
|
|
@@ -1243,12 +1271,10 @@ class Task extends _events.default {
|
|
|
1243
1271
|
errorData: err.data?.errorData,
|
|
1244
1272
|
reasonCode: err.data?.reasonCode
|
|
1245
1273
|
};
|
|
1246
|
-
const failedDestinationType = (0, _Utils.deriveConsultTransferDestinationType)(this.data);
|
|
1247
|
-
const failedDestAgentId = (0, _Utils.getDestinationAgentId)(this.data.interaction?.participants, this.data.agentId);
|
|
1248
1274
|
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_TRANSFER_FAILED, {
|
|
1249
1275
|
taskId: this.data.interactionId,
|
|
1250
|
-
destination:
|
|
1251
|
-
destinationType:
|
|
1276
|
+
destination: destAgentId || '',
|
|
1277
|
+
destinationType: destType,
|
|
1252
1278
|
isConsultTransfer: true,
|
|
1253
1279
|
error: error.toString(),
|
|
1254
1280
|
...taskErrorProps,
|
|
@@ -1257,6 +1283,243 @@ class Task extends _events.default {
|
|
|
1257
1283
|
throw err;
|
|
1258
1284
|
}
|
|
1259
1285
|
}
|
|
1286
|
+
|
|
1287
|
+
/**
|
|
1288
|
+
* Starts a consultation conference by merging the consultation call with the main call
|
|
1289
|
+
*
|
|
1290
|
+
* Creates a three-way conference between the agent, customer, and consulted party
|
|
1291
|
+
* Extracts required consultation data from the current task data
|
|
1292
|
+
* On success, emits a `task:conferenceStarted` event
|
|
1293
|
+
*
|
|
1294
|
+
* @returns Promise<TaskResponse> - Response from the consultation conference API
|
|
1295
|
+
* @throws Error if the operation fails or if consultation data is invalid
|
|
1296
|
+
*
|
|
1297
|
+
* @example
|
|
1298
|
+
* ```typescript
|
|
1299
|
+
* try {
|
|
1300
|
+
* await task.consultConference();
|
|
1301
|
+
* console.log('Conference started successfully');
|
|
1302
|
+
* } catch (error) {
|
|
1303
|
+
* console.error('Failed to start conference:', error);
|
|
1304
|
+
* }
|
|
1305
|
+
* ```
|
|
1306
|
+
*/
|
|
1307
|
+
async consultConference() {
|
|
1308
|
+
// Get the destination agent ID dynamically from participants
|
|
1309
|
+
// This handles multi-party conference scenarios, CBT (Capacity Based Team), and EP-DN cases
|
|
1310
|
+
const destAgentId = (0, _Utils.calculateDestAgentId)(this.data.interaction, this.agentId);
|
|
1311
|
+
|
|
1312
|
+
// Validate that we have a destination agent (for queue consult scenarios)
|
|
1313
|
+
if (!destAgentId) {
|
|
1314
|
+
throw new Error('No agent has accepted this queue consult yet');
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
// Get the destination agent ID for fetching destination type
|
|
1318
|
+
// This helps determine the correct participant type for CBT (Capacity Based Team) and EP-DN scenarios
|
|
1319
|
+
const destAgentType = (0, _Utils.calculateDestType)(this.data.interaction, this.agentId);
|
|
1320
|
+
|
|
1321
|
+
// Extract consultation conference data from task data (used in both try and catch)
|
|
1322
|
+
const consultationData = {
|
|
1323
|
+
agentId: this.agentId,
|
|
1324
|
+
to: destAgentId,
|
|
1325
|
+
destinationType: destAgentType || this.data.destinationType || 'agent'
|
|
1326
|
+
};
|
|
1327
|
+
try {
|
|
1328
|
+
_loggerProxy.default.info(`Initiating consult conference to ${destAgentId}`, {
|
|
1329
|
+
module: _constants.TASK_FILE,
|
|
1330
|
+
method: _constants2.METHODS.CONSULT_CONFERENCE,
|
|
1331
|
+
interactionId: this.data.interactionId
|
|
1332
|
+
});
|
|
1333
|
+
const response = await this.contact.consultConference({
|
|
1334
|
+
interactionId: this.data.interactionId,
|
|
1335
|
+
data: consultationData
|
|
1336
|
+
});
|
|
1337
|
+
|
|
1338
|
+
// Track success metrics (following consultTransfer pattern)
|
|
1339
|
+
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_CONFERENCE_START_SUCCESS, {
|
|
1340
|
+
taskId: this.data.interactionId,
|
|
1341
|
+
destination: consultationData.to,
|
|
1342
|
+
destinationType: consultationData.destinationType,
|
|
1343
|
+
agentId: consultationData.agentId,
|
|
1344
|
+
..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(response)
|
|
1345
|
+
}, ['operational', 'behavioral', 'business']);
|
|
1346
|
+
_loggerProxy.default.log(`Consult conference started successfully`, {
|
|
1347
|
+
module: _constants.TASK_FILE,
|
|
1348
|
+
method: _constants2.METHODS.CONSULT_CONFERENCE,
|
|
1349
|
+
interactionId: this.data.interactionId
|
|
1350
|
+
});
|
|
1351
|
+
return response;
|
|
1352
|
+
} catch (error) {
|
|
1353
|
+
const err = (0, _Utils.generateTaskErrorObject)(error, _constants2.METHODS.CONSULT_CONFERENCE, _constants.TASK_FILE);
|
|
1354
|
+
const taskErrorProps = {
|
|
1355
|
+
trackingId: err.data?.trackingId,
|
|
1356
|
+
errorMessage: err.data?.message,
|
|
1357
|
+
errorType: err.data?.errorType,
|
|
1358
|
+
errorData: err.data?.errorData,
|
|
1359
|
+
reasonCode: err.data?.reasonCode
|
|
1360
|
+
};
|
|
1361
|
+
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_CONFERENCE_START_FAILED, {
|
|
1362
|
+
taskId: this.data.interactionId,
|
|
1363
|
+
destination: consultationData.to,
|
|
1364
|
+
destinationType: consultationData.destinationType,
|
|
1365
|
+
agentId: consultationData.agentId,
|
|
1366
|
+
error: error.toString(),
|
|
1367
|
+
...taskErrorProps,
|
|
1368
|
+
..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(error.details || {})
|
|
1369
|
+
}, ['operational', 'behavioral', 'business']);
|
|
1370
|
+
_loggerProxy.default.error(`Failed to start consult conference`, {
|
|
1371
|
+
module: _constants.TASK_FILE,
|
|
1372
|
+
method: _constants2.METHODS.CONSULT_CONFERENCE,
|
|
1373
|
+
interactionId: this.data.interactionId
|
|
1374
|
+
});
|
|
1375
|
+
throw err;
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
/**
|
|
1380
|
+
* Exits the current conference by removing the agent from the conference call
|
|
1381
|
+
*
|
|
1382
|
+
* Exits the agent from the conference, leaving the customer and consulted party connected
|
|
1383
|
+
* On success, emits a `task:conferenceEnded` event
|
|
1384
|
+
*
|
|
1385
|
+
* @returns Promise<TaskResponse> - Response from the conference exit API
|
|
1386
|
+
* @throws Error if the operation fails or if no active conference exists
|
|
1387
|
+
*
|
|
1388
|
+
* @example
|
|
1389
|
+
* ```typescript
|
|
1390
|
+
* try {
|
|
1391
|
+
* await task.exitConference();
|
|
1392
|
+
* console.log('Successfully exited conference');
|
|
1393
|
+
* } catch (error) {
|
|
1394
|
+
* console.error('Failed to exit conference:', error);
|
|
1395
|
+
* }
|
|
1396
|
+
* ```
|
|
1397
|
+
*/
|
|
1398
|
+
async exitConference() {
|
|
1399
|
+
try {
|
|
1400
|
+
_loggerProxy.default.info(`Exiting consult conference`, {
|
|
1401
|
+
module: _constants.TASK_FILE,
|
|
1402
|
+
method: _constants2.METHODS.EXIT_CONFERENCE,
|
|
1403
|
+
interactionId: this.data.interactionId
|
|
1404
|
+
});
|
|
1405
|
+
|
|
1406
|
+
// Validate that interaction ID exists
|
|
1407
|
+
if (!this.data.interactionId) {
|
|
1408
|
+
throw new Error('Invalid interaction ID');
|
|
1409
|
+
}
|
|
1410
|
+
const response = await this.contact.exitConference({
|
|
1411
|
+
interactionId: this.data.interactionId
|
|
1412
|
+
});
|
|
1413
|
+
|
|
1414
|
+
// Track success metrics (following consultTransfer pattern)
|
|
1415
|
+
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_CONFERENCE_END_SUCCESS, {
|
|
1416
|
+
taskId: this.data.interactionId,
|
|
1417
|
+
..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(response)
|
|
1418
|
+
}, ['operational', 'behavioral', 'business']);
|
|
1419
|
+
_loggerProxy.default.log(`Consult conference exited successfully`, {
|
|
1420
|
+
module: _constants.TASK_FILE,
|
|
1421
|
+
method: _constants2.METHODS.EXIT_CONFERENCE,
|
|
1422
|
+
interactionId: this.data.interactionId
|
|
1423
|
+
});
|
|
1424
|
+
return response;
|
|
1425
|
+
} catch (error) {
|
|
1426
|
+
const err = (0, _Utils.generateTaskErrorObject)(error, _constants2.METHODS.EXIT_CONFERENCE, _constants.TASK_FILE);
|
|
1427
|
+
const taskErrorProps = {
|
|
1428
|
+
trackingId: err.data?.trackingId,
|
|
1429
|
+
errorMessage: err.data?.message,
|
|
1430
|
+
errorType: err.data?.errorType,
|
|
1431
|
+
errorData: err.data?.errorData,
|
|
1432
|
+
reasonCode: err.data?.reasonCode
|
|
1433
|
+
};
|
|
1434
|
+
|
|
1435
|
+
// Track failure metrics (following consultTransfer pattern)
|
|
1436
|
+
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_CONFERENCE_END_FAILED, {
|
|
1437
|
+
taskId: this.data.interactionId,
|
|
1438
|
+
error: error.toString(),
|
|
1439
|
+
...taskErrorProps,
|
|
1440
|
+
..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(error.details || {})
|
|
1441
|
+
}, ['operational', 'behavioral', 'business']);
|
|
1442
|
+
_loggerProxy.default.error(`Failed to exit consult conference`, {
|
|
1443
|
+
module: _constants.TASK_FILE,
|
|
1444
|
+
method: _constants2.METHODS.EXIT_CONFERENCE,
|
|
1445
|
+
interactionId: this.data.interactionId
|
|
1446
|
+
});
|
|
1447
|
+
throw err;
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
/**
|
|
1452
|
+
* Transfers the current conference to another agent
|
|
1453
|
+
*
|
|
1454
|
+
* Moves the entire conference (including all participants) to a new agent,
|
|
1455
|
+
* while the current agent exits and goes to wrapup
|
|
1456
|
+
* On success, the current agent receives `task:conferenceEnded` event
|
|
1457
|
+
*
|
|
1458
|
+
* @returns Promise<TaskResponse> - Response from the conference transfer API
|
|
1459
|
+
* @throws Error if the operation fails or if no active conference exists
|
|
1460
|
+
*
|
|
1461
|
+
* @example
|
|
1462
|
+
* ```typescript
|
|
1463
|
+
* try {
|
|
1464
|
+
* await task.transferConference();
|
|
1465
|
+
* console.log('Conference transferred successfully');
|
|
1466
|
+
* } catch (error) {
|
|
1467
|
+
* console.error('Failed to transfer conference:', error);
|
|
1468
|
+
* }
|
|
1469
|
+
* ```
|
|
1470
|
+
*/
|
|
1471
|
+
async transferConference() {
|
|
1472
|
+
try {
|
|
1473
|
+
_loggerProxy.default.info(`Transferring conference`, {
|
|
1474
|
+
module: _constants.TASK_FILE,
|
|
1475
|
+
method: _constants2.METHODS.TRANSFER_CONFERENCE,
|
|
1476
|
+
interactionId: this.data.interactionId
|
|
1477
|
+
});
|
|
1478
|
+
|
|
1479
|
+
// Validate that interaction ID exists
|
|
1480
|
+
if (!this.data.interactionId) {
|
|
1481
|
+
throw new Error('Invalid interaction ID');
|
|
1482
|
+
}
|
|
1483
|
+
const response = await this.contact.conferenceTransfer({
|
|
1484
|
+
interactionId: this.data.interactionId
|
|
1485
|
+
});
|
|
1486
|
+
|
|
1487
|
+
// Track success metrics (following consultTransfer pattern)
|
|
1488
|
+
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_CONFERENCE_TRANSFER_SUCCESS, {
|
|
1489
|
+
taskId: this.data.interactionId,
|
|
1490
|
+
..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(response)
|
|
1491
|
+
}, ['operational', 'behavioral', 'business']);
|
|
1492
|
+
_loggerProxy.default.log(`Conference transferred successfully`, {
|
|
1493
|
+
module: _constants.TASK_FILE,
|
|
1494
|
+
method: _constants2.METHODS.TRANSFER_CONFERENCE,
|
|
1495
|
+
interactionId: this.data.interactionId
|
|
1496
|
+
});
|
|
1497
|
+
return response;
|
|
1498
|
+
} catch (error) {
|
|
1499
|
+
const err = (0, _Utils.generateTaskErrorObject)(error, _constants2.METHODS.TRANSFER_CONFERENCE, _constants.TASK_FILE);
|
|
1500
|
+
const taskErrorProps = {
|
|
1501
|
+
trackingId: err.data?.trackingId,
|
|
1502
|
+
errorMessage: err.data?.message,
|
|
1503
|
+
errorType: err.data?.errorType,
|
|
1504
|
+
errorData: err.data?.errorData,
|
|
1505
|
+
reasonCode: err.data?.reasonCode
|
|
1506
|
+
};
|
|
1507
|
+
|
|
1508
|
+
// Track failure metrics (following consultTransfer pattern)
|
|
1509
|
+
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_CONFERENCE_TRANSFER_FAILED, {
|
|
1510
|
+
taskId: this.data.interactionId,
|
|
1511
|
+
error: error.toString(),
|
|
1512
|
+
...taskErrorProps,
|
|
1513
|
+
..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(error.details || {})
|
|
1514
|
+
}, ['operational', 'behavioral', 'business']);
|
|
1515
|
+
_loggerProxy.default.error(`Failed to transfer conference`, {
|
|
1516
|
+
module: _constants.TASK_FILE,
|
|
1517
|
+
method: _constants2.METHODS.TRANSFER_CONFERENCE,
|
|
1518
|
+
interactionId: this.data.interactionId
|
|
1519
|
+
});
|
|
1520
|
+
throw err;
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1260
1523
|
}
|
|
1261
1524
|
exports.default = Task;
|
|
1262
1525
|
//# sourceMappingURL=index.js.map
|