@webex/contact-center 3.12.0-next.3 → 3.12.0-next.30

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 (52) hide show
  1. package/dist/cc.js +132 -0
  2. package/dist/cc.js.map +1 -1
  3. package/dist/constants.js +2 -0
  4. package/dist/constants.js.map +1 -1
  5. package/dist/metrics/behavioral-events.js +26 -0
  6. package/dist/metrics/behavioral-events.js.map +1 -1
  7. package/dist/metrics/constants.js +4 -0
  8. package/dist/metrics/constants.js.map +1 -1
  9. package/dist/services/config/constants.js +1 -1
  10. package/dist/services/config/constants.js.map +1 -1
  11. package/dist/services/config/types.js +4 -0
  12. package/dist/services/config/types.js.map +1 -1
  13. package/dist/services/core/Err.js.map +1 -1
  14. package/dist/services/task/TaskManager.js +90 -8
  15. package/dist/services/task/TaskManager.js.map +1 -1
  16. package/dist/services/task/constants.js +3 -1
  17. package/dist/services/task/constants.js.map +1 -1
  18. package/dist/services/task/dialer.js +78 -0
  19. package/dist/services/task/dialer.js.map +1 -1
  20. package/dist/services/task/index.js +7 -2
  21. package/dist/services/task/index.js.map +1 -1
  22. package/dist/services/task/types.js +44 -0
  23. package/dist/services/task/types.js.map +1 -1
  24. package/dist/types/cc.d.ts +44 -0
  25. package/dist/types/constants.d.ts +2 -0
  26. package/dist/types/metrics/constants.d.ts +4 -0
  27. package/dist/types/services/config/types.d.ts +8 -0
  28. package/dist/types/services/core/Err.d.ts +4 -0
  29. package/dist/types/services/task/constants.d.ts +2 -0
  30. package/dist/types/services/task/dialer.d.ts +30 -0
  31. package/dist/types/services/task/types.d.ts +53 -1
  32. package/dist/webex.js +1 -1
  33. package/package.json +9 -9
  34. package/src/cc.ts +160 -0
  35. package/src/constants.ts +2 -0
  36. package/src/metrics/behavioral-events.ts +28 -0
  37. package/src/metrics/constants.ts +4 -0
  38. package/src/services/config/constants.ts +1 -1
  39. package/src/services/config/types.ts +4 -0
  40. package/src/services/core/Err.ts +2 -0
  41. package/src/services/task/TaskManager.ts +102 -22
  42. package/src/services/task/constants.ts +2 -0
  43. package/src/services/task/dialer.ts +80 -0
  44. package/src/services/task/index.ts +7 -2
  45. package/src/services/task/types.ts +56 -0
  46. package/test/unit/spec/cc.ts +130 -0
  47. package/test/unit/spec/services/config/index.ts +1 -1
  48. package/test/unit/spec/services/task/TaskManager.ts +238 -7
  49. package/test/unit/spec/services/task/dialer.ts +190 -0
  50. package/test/unit/spec/services/task/index.ts +21 -0
  51. package/umd/contact-center.min.js +2 -2
  52. package/umd/contact-center.min.js.map +1 -1
package/dist/cc.js CHANGED
@@ -1444,6 +1444,138 @@ class ContactCenter extends _webexCore.WebexPlugin {
1444
1444
  }
1445
1445
  }
1446
1446
 
1447
+ /**
1448
+ * Skips a campaign preview contact, requesting the next contact from the campaign.
1449
+ *
1450
+ * When a campaign manager reserves a contact for an agent, the agent receives an
1451
+ * `AgentOfferCampaignReservation` event. Instead of accepting, the agent can skip the
1452
+ * preview contact to move to the next contact in the campaign.
1453
+ *
1454
+ * @param {PreviewContactPayload} payload - The preview contact payload containing interactionId and campaignId (campaign name, not UUID).
1455
+ * @returns {Promise<TaskResponse>} Promise resolving with agent contact on success.
1456
+ * @throws {Error} If the operation fails (network error, etc.)
1457
+ *
1458
+ * @example
1459
+ * ```typescript
1460
+ * webex.cc.on('task:campaignPreviewReservation', async (task) => {
1461
+ * const { interactionId } = task.data;
1462
+ * const campaignId = task.data.interaction.callProcessingDetails.campaignId;
1463
+ *
1464
+ * const result = await webex.cc.skipPreviewContact({ interactionId, campaignId });
1465
+ * });
1466
+ * ```
1467
+ */
1468
+ async skipPreviewContact(payload) {
1469
+ const task = this.taskManager.getTask(payload.interactionId);
1470
+ if (task?.data?.interaction?.callProcessingDetails?.campaignPreviewSkipDisabled === 'true') {
1471
+ _loggerProxy.default.warn('Skip action is disabled for this campaign preview contact', {
1472
+ module: _constants.CC_FILE,
1473
+ method: _constants.METHODS.SKIP_PREVIEW_CONTACT,
1474
+ interactionId: payload.interactionId
1475
+ });
1476
+ throw new Error('Skip action is disabled for this campaign preview contact');
1477
+ }
1478
+ _loggerProxy.default.info('Skipping campaign preview contact', {
1479
+ module: _constants.CC_FILE,
1480
+ method: _constants.METHODS.SKIP_PREVIEW_CONTACT
1481
+ });
1482
+ try {
1483
+ this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.CAMPAIGN_PREVIEW_SKIP_SUCCESS, _constants4.METRIC_EVENT_NAMES.CAMPAIGN_PREVIEW_SKIP_FAILED]);
1484
+ const result = await this.services.dialer.skipPreviewContact({
1485
+ data: payload
1486
+ });
1487
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.CAMPAIGN_PREVIEW_SKIP_SUCCESS, {
1488
+ ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(result),
1489
+ interactionId: payload.interactionId,
1490
+ campaignId: payload.campaignId
1491
+ }, ['behavioral', 'business', 'operational']);
1492
+ _loggerProxy.default.log('Campaign preview contact skipped successfully', {
1493
+ module: _constants.CC_FILE,
1494
+ method: _constants.METHODS.SKIP_PREVIEW_CONTACT,
1495
+ trackingId: result.trackingId,
1496
+ interactionId: payload.interactionId
1497
+ });
1498
+ return result;
1499
+ } catch (error) {
1500
+ const failure = error.details;
1501
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.CAMPAIGN_PREVIEW_SKIP_FAILED, {
1502
+ ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(failure),
1503
+ interactionId: payload.interactionId,
1504
+ campaignId: payload.campaignId
1505
+ }, ['behavioral', 'business', 'operational']);
1506
+ const {
1507
+ error: detailedError
1508
+ } = (0, _Utils.getErrorDetails)(error, _constants.METHODS.SKIP_PREVIEW_CONTACT, _constants.CC_FILE);
1509
+ throw detailedError;
1510
+ }
1511
+ }
1512
+
1513
+ /**
1514
+ * Removes a campaign preview contact from the campaign list entirely.
1515
+ *
1516
+ * When a campaign manager reserves a contact for an agent, the agent receives an
1517
+ * `AgentOfferCampaignReservation` event. Instead of accepting or skipping, the agent can
1518
+ * remove the preview contact to permanently take it out of the campaign contact list.
1519
+ *
1520
+ * @param {PreviewContactPayload} payload - The preview contact payload containing interactionId and campaignId (campaign name, not UUID).
1521
+ * @returns {Promise<TaskResponse>} Promise resolving with agent contact on success.
1522
+ * @throws {Error} If the operation fails (network error, etc.)
1523
+ *
1524
+ * @example
1525
+ * ```typescript
1526
+ * webex.cc.on('task:campaignPreviewReservation', async (task) => {
1527
+ * const { interactionId } = task.data;
1528
+ * const campaignId = task.data.interaction.callProcessingDetails.campaignId;
1529
+ *
1530
+ * const result = await webex.cc.removePreviewContact({ interactionId, campaignId });
1531
+ * });
1532
+ * ```
1533
+ */
1534
+ async removePreviewContact(payload) {
1535
+ const task = this.taskManager.getTask(payload.interactionId);
1536
+ if (task?.data?.interaction?.callProcessingDetails?.campaignPreviewRemoveDisabled === 'true') {
1537
+ _loggerProxy.default.warn('Remove action is disabled for this campaign preview contact', {
1538
+ module: _constants.CC_FILE,
1539
+ method: _constants.METHODS.REMOVE_PREVIEW_CONTACT,
1540
+ interactionId: payload.interactionId
1541
+ });
1542
+ throw new Error('Remove action is disabled for this campaign preview contact');
1543
+ }
1544
+ _loggerProxy.default.info('Removing campaign preview contact', {
1545
+ module: _constants.CC_FILE,
1546
+ method: _constants.METHODS.REMOVE_PREVIEW_CONTACT
1547
+ });
1548
+ try {
1549
+ this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.CAMPAIGN_PREVIEW_REMOVE_SUCCESS, _constants4.METRIC_EVENT_NAMES.CAMPAIGN_PREVIEW_REMOVE_FAILED]);
1550
+ const result = await this.services.dialer.removePreviewContact({
1551
+ data: payload
1552
+ });
1553
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.CAMPAIGN_PREVIEW_REMOVE_SUCCESS, {
1554
+ ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(result),
1555
+ interactionId: payload.interactionId,
1556
+ campaignId: payload.campaignId
1557
+ }, ['behavioral', 'business', 'operational']);
1558
+ _loggerProxy.default.log('Campaign preview contact removed successfully', {
1559
+ module: _constants.CC_FILE,
1560
+ method: _constants.METHODS.REMOVE_PREVIEW_CONTACT,
1561
+ trackingId: result.trackingId,
1562
+ interactionId: payload.interactionId
1563
+ });
1564
+ return result;
1565
+ } catch (error) {
1566
+ const failure = error.details;
1567
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.CAMPAIGN_PREVIEW_REMOVE_FAILED, {
1568
+ ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(failure),
1569
+ interactionId: payload.interactionId,
1570
+ campaignId: payload.campaignId
1571
+ }, ['behavioral', 'business', 'operational']);
1572
+ const {
1573
+ error: detailedError
1574
+ } = (0, _Utils.getErrorDetails)(error, _constants.METHODS.REMOVE_PREVIEW_CONTACT, _constants.CC_FILE);
1575
+ throw detailedError;
1576
+ }
1577
+ }
1578
+
1447
1579
  /**
1448
1580
  * Fetches outdial ANI (Automatic Number Identification) entries for an outdial ANI ID.
1449
1581
  *