@webex/contact-center 3.8.1 → 3.9.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 +196 -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 +13 -1
- 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/MetricsManager.js +1 -1
- package/dist/metrics/MetricsManager.js.map +1 -1
- package/dist/metrics/behavioral-events.js +88 -0
- package/dist/metrics/behavioral-events.js.map +1 -1
- package/dist/metrics/constants.js +32 -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/GlobalTypes.js.map +1 -1
- package/dist/services/core/Utils.js +162 -2
- package/dist/services/core/Utils.js.map +1 -1
- package/dist/services/core/aqm-reqs.js +0 -4
- package/dist/services/core/aqm-reqs.js.map +1 -1
- package/dist/services/core/websocket/WebSocketManager.js +0 -4
- package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
- package/dist/services/task/TaskManager.js +74 -2
- package/dist/services/task/TaskManager.js.map +1 -1
- package/dist/services/task/constants.js +7 -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 +384 -72
- package/dist/services/task/index.js.map +1 -1
- package/dist/services/task/types.js +14 -0
- package/dist/services/task/types.js.map +1 -1
- package/dist/types/cc.d.ts +115 -35
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/index.d.ts +8 -3
- package/dist/types/metrics/constants.d.ts +25 -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/GlobalTypes.d.ts +25 -0
- package/dist/types/services/core/Utils.d.ts +40 -1
- package/dist/types/services/task/constants.d.ts +6 -0
- package/dist/types/services/task/contact.d.ts +10 -0
- package/dist/types/services/task/index.d.ts +44 -2
- package/dist/types/services/task/types.d.ts +125 -1
- 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 +11 -10
- package/src/cc.ts +221 -52
- package/src/constants.ts +1 -0
- package/src/index.ts +19 -3
- package/src/logger-proxy.ts +24 -1
- package/src/metrics/MetricsManager.ts +1 -1
- package/src/metrics/behavioral-events.ts +92 -0
- package/src/metrics/constants.ts +37 -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/GlobalTypes.ts +27 -0
- package/src/services/core/Utils.ts +199 -1
- package/src/services/core/aqm-reqs.ts +0 -5
- package/src/services/core/websocket/WebSocketManager.ts +0 -4
- package/src/services/task/TaskManager.ts +79 -3
- package/src/services/task/constants.ts +6 -0
- package/src/services/task/contact.ts +80 -0
- package/src/services/task/index.ts +457 -57
- package/src/services/task/types.ts +135 -0
- package/src/types.ts +180 -0
- package/src/utils/PageCache.ts +252 -0
- package/test/unit/spec/cc.ts +77 -84
- package/test/unit/spec/metrics/MetricsManager.ts +0 -1
- package/test/unit/spec/metrics/behavioral-events.ts +56 -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 +50 -0
- package/test/unit/spec/services/core/aqm-reqs.ts +1 -3
- package/test/unit/spec/services/core/websocket/WebSocketManager.ts +0 -4
- package/test/unit/spec/services/task/TaskManager.ts +145 -1
- package/test/unit/spec/services/task/contact.ts +31 -1
- package/test/unit/spec/services/task/index.ts +410 -123
- 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
|
/**
|
|
@@ -331,15 +332,21 @@ class Task extends _events.default {
|
|
|
331
332
|
}
|
|
332
333
|
return Promise.resolve(); // TODO: reject for extension as part of refactor
|
|
333
334
|
} catch (error) {
|
|
334
|
-
const
|
|
335
|
-
|
|
336
|
-
|
|
335
|
+
const err = (0, _Utils.generateTaskErrorObject)(error, _constants2.METHODS.ACCEPT, _constants.TASK_FILE);
|
|
336
|
+
const taskErrorProps = {
|
|
337
|
+
trackingId: err.data?.trackingId,
|
|
338
|
+
errorMessage: err.data?.message,
|
|
339
|
+
errorType: err.data?.errorType,
|
|
340
|
+
errorData: err.data?.errorData,
|
|
341
|
+
reasonCode: err.data?.reasonCode
|
|
342
|
+
};
|
|
337
343
|
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_ACCEPT_FAILED, {
|
|
338
344
|
taskId: this.data.interactionId,
|
|
339
345
|
error: error.toString(),
|
|
346
|
+
...taskErrorProps,
|
|
340
347
|
..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(error.details)
|
|
341
348
|
}, ['operational', 'behavioral', 'business']);
|
|
342
|
-
throw
|
|
349
|
+
throw err;
|
|
343
350
|
}
|
|
344
351
|
}
|
|
345
352
|
|
|
@@ -372,10 +379,8 @@ class Task extends _events.default {
|
|
|
372
379
|
});
|
|
373
380
|
return Promise.resolve();
|
|
374
381
|
} catch (error) {
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
} = (0, _Utils.getErrorDetails)(error, _constants2.METHODS.TOGGLE_MUTE, _constants.TASK_FILE);
|
|
378
|
-
throw detailedError;
|
|
382
|
+
const err = (0, _Utils.generateTaskErrorObject)(error, _constants2.METHODS.TOGGLE_MUTE, _constants.TASK_FILE);
|
|
383
|
+
throw err;
|
|
379
384
|
}
|
|
380
385
|
}
|
|
381
386
|
|
|
@@ -413,15 +418,21 @@ class Task extends _events.default {
|
|
|
413
418
|
});
|
|
414
419
|
return Promise.resolve();
|
|
415
420
|
} catch (error) {
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
|
|
421
|
+
const err = (0, _Utils.generateTaskErrorObject)(error, _constants2.METHODS.DECLINE, _constants.TASK_FILE);
|
|
422
|
+
const taskErrorProps = {
|
|
423
|
+
trackingId: err.data?.trackingId,
|
|
424
|
+
errorMessage: err.data?.message,
|
|
425
|
+
errorType: err.data?.errorType,
|
|
426
|
+
errorData: err.data?.errorData,
|
|
427
|
+
reasonCode: err.data?.reasonCode
|
|
428
|
+
};
|
|
419
429
|
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_DECLINE_FAILED, {
|
|
420
430
|
taskId: this.data.interactionId,
|
|
421
431
|
error: error.toString(),
|
|
432
|
+
...taskErrorProps,
|
|
422
433
|
..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(error.details || {})
|
|
423
434
|
}, ['operational', 'behavioral']);
|
|
424
|
-
throw
|
|
435
|
+
throw err;
|
|
425
436
|
}
|
|
426
437
|
}
|
|
427
438
|
|
|
@@ -478,16 +489,22 @@ class Task extends _events.default {
|
|
|
478
489
|
});
|
|
479
490
|
return response;
|
|
480
491
|
} catch (error) {
|
|
481
|
-
const
|
|
482
|
-
|
|
483
|
-
|
|
492
|
+
const err = (0, _Utils.generateTaskErrorObject)(error, _constants2.METHODS.HOLD, _constants.TASK_FILE);
|
|
493
|
+
const taskErrorProps = {
|
|
494
|
+
trackingId: err.data?.trackingId,
|
|
495
|
+
errorMessage: err.data?.message,
|
|
496
|
+
errorType: err.data?.errorType,
|
|
497
|
+
errorData: err.data?.errorData,
|
|
498
|
+
reasonCode: err.data?.reasonCode
|
|
499
|
+
};
|
|
484
500
|
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_HOLD_FAILED, {
|
|
485
501
|
taskId: this.data.interactionId,
|
|
486
502
|
mediaResourceId: this.data.mediaResourceId,
|
|
487
503
|
error: error.toString(),
|
|
504
|
+
...taskErrorProps,
|
|
488
505
|
..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(error.details || {})
|
|
489
506
|
}, ['operational', 'behavioral']);
|
|
490
|
-
throw
|
|
507
|
+
throw err;
|
|
491
508
|
}
|
|
492
509
|
}
|
|
493
510
|
|
|
@@ -551,17 +568,23 @@ class Task extends _events.default {
|
|
|
551
568
|
});
|
|
552
569
|
return response;
|
|
553
570
|
} catch (error) {
|
|
554
|
-
const
|
|
555
|
-
error: detailedError
|
|
556
|
-
} = (0, _Utils.getErrorDetails)(error, _constants2.METHODS.RESUME, _constants.TASK_FILE);
|
|
571
|
+
const err = (0, _Utils.generateTaskErrorObject)(error, _constants2.METHODS.RESUME, _constants.TASK_FILE);
|
|
557
572
|
const mainInteractionId = this.data.interaction?.mainInteractionId;
|
|
573
|
+
const taskErrorProps = {
|
|
574
|
+
trackingId: err.data?.trackingId,
|
|
575
|
+
errorMessage: err.data?.message,
|
|
576
|
+
errorType: err.data?.errorType,
|
|
577
|
+
errorData: err.data?.errorData,
|
|
578
|
+
reasonCode: err.data?.reasonCode
|
|
579
|
+
};
|
|
558
580
|
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_RESUME_FAILED, {
|
|
559
581
|
taskId: this.data.interactionId,
|
|
560
582
|
mainInteractionId,
|
|
561
583
|
mediaResourceId: mainInteractionId ? this.data.interaction.media[mainInteractionId].mediaResourceId : '',
|
|
584
|
+
...taskErrorProps,
|
|
562
585
|
..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(error.details || {})
|
|
563
586
|
}, ['operational', 'behavioral']);
|
|
564
|
-
throw
|
|
587
|
+
throw err;
|
|
565
588
|
}
|
|
566
589
|
}
|
|
567
590
|
|
|
@@ -631,14 +654,20 @@ class Task extends _events.default {
|
|
|
631
654
|
});
|
|
632
655
|
return response;
|
|
633
656
|
} catch (error) {
|
|
634
|
-
const
|
|
635
|
-
|
|
636
|
-
|
|
657
|
+
const err = (0, _Utils.generateTaskErrorObject)(error, _constants2.METHODS.END, _constants.TASK_FILE);
|
|
658
|
+
const taskErrorProps = {
|
|
659
|
+
trackingId: err.data?.trackingId,
|
|
660
|
+
errorMessage: err.data?.message,
|
|
661
|
+
errorType: err.data?.errorType,
|
|
662
|
+
errorData: err.data?.errorData,
|
|
663
|
+
reasonCode: err.data?.reasonCode
|
|
664
|
+
};
|
|
637
665
|
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_END_FAILED, {
|
|
638
666
|
taskId: this.data.interactionId,
|
|
667
|
+
...taskErrorProps,
|
|
639
668
|
..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(error.details || {})
|
|
640
669
|
}, ['operational', 'behavioral', 'business']);
|
|
641
|
-
throw
|
|
670
|
+
throw err;
|
|
642
671
|
}
|
|
643
672
|
}
|
|
644
673
|
|
|
@@ -720,16 +749,22 @@ class Task extends _events.default {
|
|
|
720
749
|
});
|
|
721
750
|
return response;
|
|
722
751
|
} catch (error) {
|
|
723
|
-
const
|
|
724
|
-
|
|
725
|
-
|
|
752
|
+
const err = (0, _Utils.generateTaskErrorObject)(error, _constants2.METHODS.WRAPUP, _constants.TASK_FILE);
|
|
753
|
+
const taskErrorProps = {
|
|
754
|
+
trackingId: err.data?.trackingId,
|
|
755
|
+
errorMessage: err.data?.message,
|
|
756
|
+
errorType: err.data?.errorType,
|
|
757
|
+
errorData: err.data?.errorData,
|
|
758
|
+
reasonCode: err.data?.reasonCode
|
|
759
|
+
};
|
|
726
760
|
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_WRAPUP_FAILED, {
|
|
727
761
|
taskId: this.data.interactionId,
|
|
728
762
|
wrapUpCode: wrapupPayload.auxCodeId,
|
|
729
763
|
wrapUpReason: wrapupPayload.wrapUpReason,
|
|
764
|
+
...taskErrorProps,
|
|
730
765
|
..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(error.details || {})
|
|
731
766
|
}, ['operational', 'behavioral', 'business']);
|
|
732
|
-
throw
|
|
767
|
+
throw err;
|
|
733
768
|
}
|
|
734
769
|
}
|
|
735
770
|
|
|
@@ -788,15 +823,21 @@ class Task extends _events.default {
|
|
|
788
823
|
});
|
|
789
824
|
return result;
|
|
790
825
|
} catch (error) {
|
|
791
|
-
const
|
|
792
|
-
|
|
793
|
-
|
|
826
|
+
const err = (0, _Utils.generateTaskErrorObject)(error, _constants2.METHODS.PAUSE_RECORDING, _constants.TASK_FILE);
|
|
827
|
+
const taskErrorProps = {
|
|
828
|
+
trackingId: err.data?.trackingId,
|
|
829
|
+
errorMessage: err.data?.message,
|
|
830
|
+
errorType: err.data?.errorType,
|
|
831
|
+
errorData: err.data?.errorData,
|
|
832
|
+
reasonCode: err.data?.reasonCode
|
|
833
|
+
};
|
|
794
834
|
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_PAUSE_RECORDING_FAILED, {
|
|
795
835
|
taskId: this.data.interactionId,
|
|
796
836
|
error: error.toString(),
|
|
837
|
+
...taskErrorProps,
|
|
797
838
|
..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(error.details || {})
|
|
798
839
|
}, ['operational', 'behavioral', 'business']);
|
|
799
|
-
throw
|
|
840
|
+
throw err;
|
|
800
841
|
}
|
|
801
842
|
}
|
|
802
843
|
|
|
@@ -864,15 +905,21 @@ class Task extends _events.default {
|
|
|
864
905
|
});
|
|
865
906
|
return result;
|
|
866
907
|
} catch (error) {
|
|
867
|
-
const
|
|
868
|
-
|
|
869
|
-
|
|
908
|
+
const err = (0, _Utils.generateTaskErrorObject)(error, _constants2.METHODS.RESUME_RECORDING, _constants.TASK_FILE);
|
|
909
|
+
const taskErrorProps = {
|
|
910
|
+
trackingId: err.data?.trackingId,
|
|
911
|
+
errorMessage: err.data?.message,
|
|
912
|
+
errorType: err.data?.errorType,
|
|
913
|
+
errorData: err.data?.errorData,
|
|
914
|
+
reasonCode: err.data?.reasonCode
|
|
915
|
+
};
|
|
870
916
|
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_RESUME_RECORDING_FAILED, {
|
|
871
917
|
taskId: this.data.interactionId,
|
|
872
918
|
error: error.toString(),
|
|
919
|
+
...taskErrorProps,
|
|
873
920
|
..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(error.details || {})
|
|
874
921
|
}, ['operational', 'behavioral', 'business']);
|
|
875
|
-
throw
|
|
922
|
+
throw err;
|
|
876
923
|
}
|
|
877
924
|
}
|
|
878
925
|
|
|
@@ -935,17 +982,23 @@ class Task extends _events.default {
|
|
|
935
982
|
});
|
|
936
983
|
return result;
|
|
937
984
|
} catch (error) {
|
|
938
|
-
const
|
|
939
|
-
|
|
940
|
-
|
|
985
|
+
const err = (0, _Utils.generateTaskErrorObject)(error, _constants2.METHODS.CONSULT, _constants.TASK_FILE);
|
|
986
|
+
const taskErrorProps = {
|
|
987
|
+
trackingId: err.data?.trackingId,
|
|
988
|
+
errorMessage: err.data?.message,
|
|
989
|
+
errorType: err.data?.errorType,
|
|
990
|
+
errorData: err.data?.errorData,
|
|
991
|
+
reasonCode: err.data?.reasonCode
|
|
992
|
+
};
|
|
941
993
|
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_CONSULT_START_FAILED, {
|
|
942
994
|
taskId: this.data.interactionId,
|
|
943
995
|
destination: consultPayload.to,
|
|
944
996
|
destinationType: consultPayload.destinationType,
|
|
945
997
|
error: error.toString(),
|
|
998
|
+
...taskErrorProps,
|
|
946
999
|
..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(error.details || {})
|
|
947
1000
|
}, ['operational', 'behavioral', 'business']);
|
|
948
|
-
throw
|
|
1001
|
+
throw err;
|
|
949
1002
|
}
|
|
950
1003
|
}
|
|
951
1004
|
|
|
@@ -1006,15 +1059,21 @@ class Task extends _events.default {
|
|
|
1006
1059
|
});
|
|
1007
1060
|
return result;
|
|
1008
1061
|
} catch (error) {
|
|
1009
|
-
const
|
|
1010
|
-
|
|
1011
|
-
|
|
1062
|
+
const err = (0, _Utils.generateTaskErrorObject)(error, _constants2.METHODS.END_CONSULT, _constants.TASK_FILE);
|
|
1063
|
+
const taskErrorProps = {
|
|
1064
|
+
trackingId: err.data?.trackingId,
|
|
1065
|
+
errorMessage: err.data?.message,
|
|
1066
|
+
errorType: err.data?.errorType,
|
|
1067
|
+
errorData: err.data?.errorData,
|
|
1068
|
+
reasonCode: err.data?.reasonCode
|
|
1069
|
+
};
|
|
1012
1070
|
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_CONSULT_END_FAILED, {
|
|
1013
1071
|
taskId: this.data.interactionId,
|
|
1014
1072
|
error: error.toString(),
|
|
1073
|
+
...taskErrorProps,
|
|
1015
1074
|
..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(error.details || {})
|
|
1016
1075
|
}, ['operational', 'behavioral', 'business']);
|
|
1017
|
-
throw
|
|
1076
|
+
throw err;
|
|
1018
1077
|
}
|
|
1019
1078
|
}
|
|
1020
1079
|
|
|
@@ -1083,18 +1142,24 @@ class Task extends _events.default {
|
|
|
1083
1142
|
});
|
|
1084
1143
|
return result;
|
|
1085
1144
|
} catch (error) {
|
|
1086
|
-
const
|
|
1087
|
-
|
|
1088
|
-
|
|
1145
|
+
const err = (0, _Utils.generateTaskErrorObject)(error, _constants2.METHODS.TRANSFER, _constants.TASK_FILE);
|
|
1146
|
+
const taskErrorProps = {
|
|
1147
|
+
trackingId: err.data?.trackingId,
|
|
1148
|
+
errorMessage: err.data?.message,
|
|
1149
|
+
errorType: err.data?.errorType,
|
|
1150
|
+
errorData: err.data?.errorData,
|
|
1151
|
+
reasonCode: err.data?.reasonCode
|
|
1152
|
+
};
|
|
1089
1153
|
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_TRANSFER_FAILED, {
|
|
1090
1154
|
taskId: this.data.interactionId,
|
|
1091
1155
|
destination: transferPayload.to,
|
|
1092
1156
|
destinationType: transferPayload.destinationType,
|
|
1093
1157
|
isConsultTransfer: false,
|
|
1094
1158
|
error: error.toString(),
|
|
1159
|
+
...taskErrorProps,
|
|
1095
1160
|
..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(error.details || {})
|
|
1096
1161
|
}, ['operational', 'behavioral', 'business']);
|
|
1097
|
-
throw
|
|
1162
|
+
throw err;
|
|
1098
1163
|
}
|
|
1099
1164
|
}
|
|
1100
1165
|
|
|
@@ -1132,36 +1197,38 @@ class Task extends _events.default {
|
|
|
1132
1197
|
*/
|
|
1133
1198
|
async consultTransfer(consultTransferPayload) {
|
|
1134
1199
|
try {
|
|
1135
|
-
|
|
1200
|
+
// Get the destination agent ID using custom logic from participants data
|
|
1201
|
+
const destAgentId = (0, _Utils.getDestinationAgentId)(this.data.interaction?.participants, this.data.agentId);
|
|
1202
|
+
|
|
1203
|
+
// Resolve the target id (queue consult transfers go to the accepted agent)
|
|
1204
|
+
if (!destAgentId) {
|
|
1205
|
+
throw new Error('No agent has accepted this queue consult yet');
|
|
1206
|
+
}
|
|
1207
|
+
_loggerProxy.default.info(`Initiating consult transfer to ${consultTransferPayload?.to || destAgentId}`, {
|
|
1136
1208
|
module: _constants.TASK_FILE,
|
|
1137
1209
|
method: _constants2.METHODS.CONSULT_TRANSFER,
|
|
1138
1210
|
interactionId: this.data.interactionId
|
|
1139
1211
|
});
|
|
1212
|
+
// Obtain payload based on desktop logic using TaskData
|
|
1213
|
+
const finalDestinationType = (0, _Utils.deriveConsultTransferDestinationType)(this.data);
|
|
1140
1214
|
|
|
1141
|
-
//
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
// Override the destination with the agent who accepted the queue consult
|
|
1148
|
-
consultTransferPayload = {
|
|
1149
|
-
to: this.data.destAgentId,
|
|
1150
|
-
destinationType: _types2.CONSULT_TRANSFER_DESTINATION_TYPE.AGENT
|
|
1151
|
-
};
|
|
1152
|
-
}
|
|
1215
|
+
// By default we always use the computed destAgentId as the target id
|
|
1216
|
+
const consultTransferRequest = {
|
|
1217
|
+
to: destAgentId,
|
|
1218
|
+
destinationType: finalDestinationType
|
|
1219
|
+
};
|
|
1153
1220
|
const result = await this.contact.consultTransfer({
|
|
1154
1221
|
interactionId: this.data.interactionId,
|
|
1155
|
-
data:
|
|
1222
|
+
data: consultTransferRequest
|
|
1156
1223
|
});
|
|
1157
1224
|
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_TRANSFER_SUCCESS, {
|
|
1158
1225
|
taskId: this.data.interactionId,
|
|
1159
|
-
destination:
|
|
1160
|
-
destinationType:
|
|
1226
|
+
destination: consultTransferRequest.to,
|
|
1227
|
+
destinationType: consultTransferRequest.destinationType,
|
|
1161
1228
|
isConsultTransfer: true,
|
|
1162
1229
|
..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(result)
|
|
1163
1230
|
}, ['operational', 'behavioral', 'business']);
|
|
1164
|
-
_loggerProxy.default.log(`Consult transfer completed successfully to ${consultTransferPayload
|
|
1231
|
+
_loggerProxy.default.log(`Consult transfer completed successfully to ${consultTransferPayload?.to || destAgentId}`, {
|
|
1165
1232
|
module: _constants.TASK_FILE,
|
|
1166
1233
|
method: _constants2.METHODS.CONSULT_TRANSFER,
|
|
1167
1234
|
trackingId: result.trackingId,
|
|
@@ -1169,20 +1236,265 @@ class Task extends _events.default {
|
|
|
1169
1236
|
});
|
|
1170
1237
|
return result;
|
|
1171
1238
|
} catch (error) {
|
|
1172
|
-
const
|
|
1173
|
-
|
|
1174
|
-
|
|
1239
|
+
const err = (0, _Utils.generateTaskErrorObject)(error, _constants2.METHODS.CONSULT_TRANSFER, _constants.TASK_FILE);
|
|
1240
|
+
const taskErrorProps = {
|
|
1241
|
+
trackingId: err.data?.trackingId,
|
|
1242
|
+
errorMessage: err.data?.message,
|
|
1243
|
+
errorType: err.data?.errorType,
|
|
1244
|
+
errorData: err.data?.errorData,
|
|
1245
|
+
reasonCode: err.data?.reasonCode
|
|
1246
|
+
};
|
|
1247
|
+
const failedDestinationType = (0, _Utils.deriveConsultTransferDestinationType)(this.data);
|
|
1248
|
+
const failedDestAgentId = (0, _Utils.getDestinationAgentId)(this.data.interaction?.participants, this.data.agentId);
|
|
1175
1249
|
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_TRANSFER_FAILED, {
|
|
1176
1250
|
taskId: this.data.interactionId,
|
|
1177
|
-
destination:
|
|
1178
|
-
destinationType:
|
|
1251
|
+
destination: failedDestAgentId || '',
|
|
1252
|
+
destinationType: failedDestinationType,
|
|
1179
1253
|
isConsultTransfer: true,
|
|
1180
1254
|
error: error.toString(),
|
|
1255
|
+
...taskErrorProps,
|
|
1256
|
+
..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(error.details || {})
|
|
1257
|
+
}, ['operational', 'behavioral', 'business']);
|
|
1258
|
+
throw err;
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
/**
|
|
1263
|
+
* Starts a consultation conference by merging the consultation call with the main call
|
|
1264
|
+
*
|
|
1265
|
+
* Creates a three-way conference between the agent, customer, and consulted party
|
|
1266
|
+
* Extracts required consultation data from the current task data
|
|
1267
|
+
* On success, emits a `task:conferenceStarted` event
|
|
1268
|
+
*
|
|
1269
|
+
* @returns Promise<TaskResponse> - Response from the consultation conference API
|
|
1270
|
+
* @throws Error if the operation fails or if consultation data is invalid
|
|
1271
|
+
*
|
|
1272
|
+
* @example
|
|
1273
|
+
* ```typescript
|
|
1274
|
+
* try {
|
|
1275
|
+
* await task.consultConference();
|
|
1276
|
+
* console.log('Conference started successfully');
|
|
1277
|
+
* } catch (error) {
|
|
1278
|
+
* console.error('Failed to start conference:', error);
|
|
1279
|
+
* }
|
|
1280
|
+
* ```
|
|
1281
|
+
*/
|
|
1282
|
+
async consultConference() {
|
|
1283
|
+
// Extract consultation conference data from task data (used in both try and catch)
|
|
1284
|
+
const consultationData = {
|
|
1285
|
+
agentId: this.agentId,
|
|
1286
|
+
destAgentId: this.data.destAgentId,
|
|
1287
|
+
destinationType: this.data.destinationType || 'agent'
|
|
1288
|
+
};
|
|
1289
|
+
try {
|
|
1290
|
+
_loggerProxy.default.info(`Initiating consult conference to ${consultationData.destAgentId}`, {
|
|
1291
|
+
module: _constants.TASK_FILE,
|
|
1292
|
+
method: _constants2.METHODS.CONSULT_CONFERENCE,
|
|
1293
|
+
interactionId: this.data.interactionId
|
|
1294
|
+
});
|
|
1295
|
+
const paramsDataForConferenceV2 = (0, _Utils.buildConsultConferenceParamData)(consultationData, this.data.interactionId);
|
|
1296
|
+
const response = await this.contact.consultConference({
|
|
1297
|
+
interactionId: paramsDataForConferenceV2.interactionId,
|
|
1298
|
+
data: paramsDataForConferenceV2.data
|
|
1299
|
+
});
|
|
1300
|
+
|
|
1301
|
+
// Track success metrics (following consultTransfer pattern)
|
|
1302
|
+
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_CONFERENCE_START_SUCCESS, {
|
|
1303
|
+
taskId: this.data.interactionId,
|
|
1304
|
+
destination: paramsDataForConferenceV2.data.to,
|
|
1305
|
+
destinationType: paramsDataForConferenceV2.data.destinationType,
|
|
1306
|
+
agentId: paramsDataForConferenceV2.data.agentId,
|
|
1307
|
+
..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(response)
|
|
1308
|
+
}, ['operational', 'behavioral', 'business']);
|
|
1309
|
+
_loggerProxy.default.log(`Consult conference started successfully`, {
|
|
1310
|
+
module: _constants.TASK_FILE,
|
|
1311
|
+
method: _constants2.METHODS.CONSULT_CONFERENCE,
|
|
1312
|
+
interactionId: this.data.interactionId
|
|
1313
|
+
});
|
|
1314
|
+
return response;
|
|
1315
|
+
} catch (error) {
|
|
1316
|
+
const err = (0, _Utils.generateTaskErrorObject)(error, _constants2.METHODS.CONSULT_CONFERENCE, _constants.TASK_FILE);
|
|
1317
|
+
const taskErrorProps = {
|
|
1318
|
+
trackingId: err.data?.trackingId,
|
|
1319
|
+
errorMessage: err.data?.message,
|
|
1320
|
+
errorType: err.data?.errorType,
|
|
1321
|
+
errorData: err.data?.errorData,
|
|
1322
|
+
reasonCode: err.data?.reasonCode
|
|
1323
|
+
};
|
|
1324
|
+
|
|
1325
|
+
// Track failure metrics (following consultTransfer pattern)
|
|
1326
|
+
// Build conference data for error tracking using extracted data
|
|
1327
|
+
const failedParamsData = (0, _Utils.buildConsultConferenceParamData)(consultationData, this.data.interactionId);
|
|
1328
|
+
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_CONFERENCE_START_FAILED, {
|
|
1329
|
+
taskId: this.data.interactionId,
|
|
1330
|
+
destination: failedParamsData.data.to,
|
|
1331
|
+
destinationType: failedParamsData.data.destinationType,
|
|
1332
|
+
agentId: failedParamsData.data.agentId,
|
|
1333
|
+
error: error.toString(),
|
|
1334
|
+
...taskErrorProps,
|
|
1335
|
+
..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(error.details || {})
|
|
1336
|
+
}, ['operational', 'behavioral', 'business']);
|
|
1337
|
+
_loggerProxy.default.error(`Failed to start consult conference`, {
|
|
1338
|
+
module: _constants.TASK_FILE,
|
|
1339
|
+
method: _constants2.METHODS.CONSULT_CONFERENCE,
|
|
1340
|
+
interactionId: this.data.interactionId
|
|
1341
|
+
});
|
|
1342
|
+
throw err;
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
/**
|
|
1347
|
+
* Exits the current conference by removing the agent from the conference call
|
|
1348
|
+
*
|
|
1349
|
+
* Exits the agent from the conference, leaving the customer and consulted party connected
|
|
1350
|
+
* On success, emits a `task:conferenceEnded` event
|
|
1351
|
+
*
|
|
1352
|
+
* @returns Promise<TaskResponse> - Response from the conference exit API
|
|
1353
|
+
* @throws Error if the operation fails or if no active conference exists
|
|
1354
|
+
*
|
|
1355
|
+
* @example
|
|
1356
|
+
* ```typescript
|
|
1357
|
+
* try {
|
|
1358
|
+
* await task.exitConference();
|
|
1359
|
+
* console.log('Successfully exited conference');
|
|
1360
|
+
* } catch (error) {
|
|
1361
|
+
* console.error('Failed to exit conference:', error);
|
|
1362
|
+
* }
|
|
1363
|
+
* ```
|
|
1364
|
+
*/
|
|
1365
|
+
async exitConference() {
|
|
1366
|
+
try {
|
|
1367
|
+
_loggerProxy.default.info(`Exiting consult conference`, {
|
|
1368
|
+
module: _constants.TASK_FILE,
|
|
1369
|
+
method: _constants2.METHODS.EXIT_CONFERENCE,
|
|
1370
|
+
interactionId: this.data.interactionId
|
|
1371
|
+
});
|
|
1372
|
+
|
|
1373
|
+
// Validate that interaction ID exists
|
|
1374
|
+
if (!this.data.interactionId) {
|
|
1375
|
+
throw new Error('Invalid interaction ID');
|
|
1376
|
+
}
|
|
1377
|
+
const response = await this.contact.exitConference({
|
|
1378
|
+
interactionId: this.data.interactionId
|
|
1379
|
+
});
|
|
1380
|
+
|
|
1381
|
+
// Track success metrics (following consultTransfer pattern)
|
|
1382
|
+
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_CONFERENCE_END_SUCCESS, {
|
|
1383
|
+
taskId: this.data.interactionId,
|
|
1384
|
+
..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(response)
|
|
1385
|
+
}, ['operational', 'behavioral', 'business']);
|
|
1386
|
+
_loggerProxy.default.log(`Consult conference exited successfully`, {
|
|
1387
|
+
module: _constants.TASK_FILE,
|
|
1388
|
+
method: _constants2.METHODS.EXIT_CONFERENCE,
|
|
1389
|
+
interactionId: this.data.interactionId
|
|
1390
|
+
});
|
|
1391
|
+
return response;
|
|
1392
|
+
} catch (error) {
|
|
1393
|
+
const err = (0, _Utils.generateTaskErrorObject)(error, _constants2.METHODS.EXIT_CONFERENCE, _constants.TASK_FILE);
|
|
1394
|
+
const taskErrorProps = {
|
|
1395
|
+
trackingId: err.data?.trackingId,
|
|
1396
|
+
errorMessage: err.data?.message,
|
|
1397
|
+
errorType: err.data?.errorType,
|
|
1398
|
+
errorData: err.data?.errorData,
|
|
1399
|
+
reasonCode: err.data?.reasonCode
|
|
1400
|
+
};
|
|
1401
|
+
|
|
1402
|
+
// Track failure metrics (following consultTransfer pattern)
|
|
1403
|
+
this.metricsManager.trackEvent(_constants3.METRIC_EVENT_NAMES.TASK_CONFERENCE_END_FAILED, {
|
|
1404
|
+
taskId: this.data.interactionId,
|
|
1405
|
+
error: error.toString(),
|
|
1406
|
+
...taskErrorProps,
|
|
1181
1407
|
..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(error.details || {})
|
|
1182
1408
|
}, ['operational', 'behavioral', 'business']);
|
|
1183
|
-
|
|
1409
|
+
_loggerProxy.default.error(`Failed to exit consult conference`, {
|
|
1410
|
+
module: _constants.TASK_FILE,
|
|
1411
|
+
method: _constants2.METHODS.EXIT_CONFERENCE,
|
|
1412
|
+
interactionId: this.data.interactionId
|
|
1413
|
+
});
|
|
1414
|
+
throw err;
|
|
1184
1415
|
}
|
|
1185
1416
|
}
|
|
1417
|
+
|
|
1418
|
+
// TODO: Uncomment this method in future PR for Multi-Party Conference support (>3 participants)
|
|
1419
|
+
// Conference transfer will be supported when implementing enhanced multi-party conference functionality
|
|
1420
|
+
/*
|
|
1421
|
+
/**
|
|
1422
|
+
* Transfers the current conference to another agent
|
|
1423
|
+
*
|
|
1424
|
+
* Moves the entire conference (including all participants) to a new agent,
|
|
1425
|
+
* while the current agent exits and goes to wrapup
|
|
1426
|
+
* On success, the current agent receives `task:conferenceEnded` event
|
|
1427
|
+
*
|
|
1428
|
+
* @returns Promise<TaskResponse> - Response from the conference transfer API
|
|
1429
|
+
* @throws Error if the operation fails or if no active conference exists
|
|
1430
|
+
*
|
|
1431
|
+
* @example
|
|
1432
|
+
* ```typescript
|
|
1433
|
+
* try {
|
|
1434
|
+
* await task.transferConference();
|
|
1435
|
+
* console.log('Conference transferred successfully');
|
|
1436
|
+
* } catch (error) {
|
|
1437
|
+
* console.error('Failed to transfer conference:', error);
|
|
1438
|
+
* }
|
|
1439
|
+
* ```
|
|
1440
|
+
*/
|
|
1441
|
+
/* public async transferConference(): Promise<TaskResponse> {
|
|
1442
|
+
try {
|
|
1443
|
+
LoggerProxy.info(`Transferring conference`, {
|
|
1444
|
+
module: TASK_FILE,
|
|
1445
|
+
method: METHODS.TRANSFER_CONFERENCE,
|
|
1446
|
+
interactionId: this.data.interactionId,
|
|
1447
|
+
});
|
|
1448
|
+
// Validate that interaction ID exists
|
|
1449
|
+
if (!this.data.interactionId) {
|
|
1450
|
+
throw new Error('Invalid interaction ID');
|
|
1451
|
+
}
|
|
1452
|
+
const response = await this.contact.conferenceTransfer({
|
|
1453
|
+
interactionId: this.data.interactionId,
|
|
1454
|
+
});
|
|
1455
|
+
// Track success metrics (following consultTransfer pattern)
|
|
1456
|
+
this.metricsManager.trackEvent(
|
|
1457
|
+
METRIC_EVENT_NAMES.TASK_CONFERENCE_TRANSFER_SUCCESS,
|
|
1458
|
+
{
|
|
1459
|
+
taskId: this.data.interactionId,
|
|
1460
|
+
...MetricsManager.getCommonTrackingFieldForAQMResponse(response),
|
|
1461
|
+
},
|
|
1462
|
+
['operational', 'behavioral', 'business']
|
|
1463
|
+
);
|
|
1464
|
+
LoggerProxy.log(`Conference transferred successfully`, {
|
|
1465
|
+
module: TASK_FILE,
|
|
1466
|
+
method: METHODS.TRANSFER_CONFERENCE,
|
|
1467
|
+
interactionId: this.data.interactionId,
|
|
1468
|
+
});
|
|
1469
|
+
return response;
|
|
1470
|
+
} catch (error) {
|
|
1471
|
+
const err = generateTaskErrorObject(error, METHODS.TRANSFER_CONFERENCE, TASK_FILE);
|
|
1472
|
+
const taskErrorProps = {
|
|
1473
|
+
trackingId: err.data?.trackingId,
|
|
1474
|
+
errorMessage: err.data?.message,
|
|
1475
|
+
errorType: err.data?.errorType,
|
|
1476
|
+
errorData: err.data?.errorData,
|
|
1477
|
+
reasonCode: err.data?.reasonCode,
|
|
1478
|
+
};
|
|
1479
|
+
// Track failure metrics (following consultTransfer pattern)
|
|
1480
|
+
this.metricsManager.trackEvent(
|
|
1481
|
+
METRIC_EVENT_NAMES.TASK_CONFERENCE_TRANSFER_FAILED,
|
|
1482
|
+
{
|
|
1483
|
+
taskId: this.data.interactionId,
|
|
1484
|
+
error: error.toString(),
|
|
1485
|
+
...taskErrorProps,
|
|
1486
|
+
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details || {}),
|
|
1487
|
+
},
|
|
1488
|
+
['operational', 'behavioral', 'business']
|
|
1489
|
+
);
|
|
1490
|
+
LoggerProxy.error(`Failed to transfer conference`, {
|
|
1491
|
+
module: TASK_FILE,
|
|
1492
|
+
method: METHODS.TRANSFER_CONFERENCE,
|
|
1493
|
+
interactionId: this.data.interactionId,
|
|
1494
|
+
});
|
|
1495
|
+
throw err;
|
|
1496
|
+
}
|
|
1497
|
+
} */
|
|
1186
1498
|
}
|
|
1187
1499
|
exports.default = Task;
|
|
1188
1500
|
//# sourceMappingURL=index.js.map
|