@webex/contact-center 3.12.0-next.4 → 3.12.0-next.41

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 +133 -3
  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 +161 -3
  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 +133 -5
  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
@@ -312,7 +312,6 @@ class ContactCenter extends _webexCore.WebexPlugin {
312
312
  webex: this.$webex,
313
313
  connectionConfig: this.getConnectionConfig()
314
314
  });
315
- this.services.webSocketManager.on('message', this.handleWebsocketMessage);
316
315
  this.webCallingService = new _WebCallingService.default(this.$webex);
317
316
  this.apiAIAssistant = new _ApiAiAssistant.ApiAIAssistant(this.$webex);
318
317
  this.metricsManager = _MetricsManager.default.getInstance({
@@ -429,6 +428,7 @@ class ContactCenter extends _webexCore.WebexPlugin {
429
428
  try {
430
429
  this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.WEBSOCKET_REGISTER_SUCCESS, _constants4.METRIC_EVENT_NAMES.WEBSOCKET_REGISTER_FAILED]);
431
430
  this.setupEventListeners();
431
+ this.services.webSocketManager.on('message', this.handleWebsocketMessage);
432
432
  const resp = await this.connectWebsocket();
433
433
  // Ensure 'dn' is always populated from 'defaultDn'
434
434
  resp.dn = resp.defaultDn;
@@ -1169,8 +1169,6 @@ class ContactCenter extends _webexCore.WebexPlugin {
1169
1169
  }
1170
1170
  this.agentConfig.lastStateAuxCodeId = auxCodeId;
1171
1171
  this.agentConfig.isAgentLoggedIn = true;
1172
- // TODO: https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-626777 Implement the de-register method and close the listener there
1173
- this.services.webSocketManager.on('message', this.handleWebsocketMessage);
1174
1172
  _loggerProxy.default.log(`Silent relogin process completed successfully with login Option: ${reLoginResponse.data.deviceType} teamId: ${reLoginResponse.data.teamId}`, {
1175
1173
  module: _constants.CC_FILE,
1176
1174
  method: _constants.METHODS.SILENT_RELOGIN,
@@ -1444,6 +1442,138 @@ class ContactCenter extends _webexCore.WebexPlugin {
1444
1442
  }
1445
1443
  }
1446
1444
 
1445
+ /**
1446
+ * Skips a campaign preview contact, requesting the next contact from the campaign.
1447
+ *
1448
+ * When a campaign manager reserves a contact for an agent, the agent receives an
1449
+ * `AgentOfferCampaignReservation` event. Instead of accepting, the agent can skip the
1450
+ * preview contact to move to the next contact in the campaign.
1451
+ *
1452
+ * @param {PreviewContactPayload} payload - The preview contact payload containing interactionId and campaignId (campaign name, not UUID).
1453
+ * @returns {Promise<TaskResponse>} Promise resolving with agent contact on success.
1454
+ * @throws {Error} If the operation fails (network error, etc.)
1455
+ *
1456
+ * @example
1457
+ * ```typescript
1458
+ * webex.cc.on('task:campaignPreviewReservation', async (task) => {
1459
+ * const { interactionId } = task.data;
1460
+ * const campaignId = task.data.interaction.callProcessingDetails.campaignId;
1461
+ *
1462
+ * const result = await webex.cc.skipPreviewContact({ interactionId, campaignId });
1463
+ * });
1464
+ * ```
1465
+ */
1466
+ async skipPreviewContact(payload) {
1467
+ const task = this.taskManager.getTask(payload.interactionId);
1468
+ if (task?.data?.interaction?.callProcessingDetails?.campaignPreviewSkipDisabled === 'true') {
1469
+ _loggerProxy.default.warn('Skip action is disabled for this campaign preview contact', {
1470
+ module: _constants.CC_FILE,
1471
+ method: _constants.METHODS.SKIP_PREVIEW_CONTACT,
1472
+ interactionId: payload.interactionId
1473
+ });
1474
+ throw new Error('Skip action is disabled for this campaign preview contact');
1475
+ }
1476
+ _loggerProxy.default.info('Skipping campaign preview contact', {
1477
+ module: _constants.CC_FILE,
1478
+ method: _constants.METHODS.SKIP_PREVIEW_CONTACT
1479
+ });
1480
+ try {
1481
+ this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.CAMPAIGN_PREVIEW_SKIP_SUCCESS, _constants4.METRIC_EVENT_NAMES.CAMPAIGN_PREVIEW_SKIP_FAILED]);
1482
+ const result = await this.services.dialer.skipPreviewContact({
1483
+ data: payload
1484
+ });
1485
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.CAMPAIGN_PREVIEW_SKIP_SUCCESS, {
1486
+ ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(result),
1487
+ interactionId: payload.interactionId,
1488
+ campaignId: payload.campaignId
1489
+ }, ['behavioral', 'business', 'operational']);
1490
+ _loggerProxy.default.log('Campaign preview contact skipped successfully', {
1491
+ module: _constants.CC_FILE,
1492
+ method: _constants.METHODS.SKIP_PREVIEW_CONTACT,
1493
+ trackingId: result.trackingId,
1494
+ interactionId: payload.interactionId
1495
+ });
1496
+ return result;
1497
+ } catch (error) {
1498
+ const failure = error.details;
1499
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.CAMPAIGN_PREVIEW_SKIP_FAILED, {
1500
+ ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(failure),
1501
+ interactionId: payload.interactionId,
1502
+ campaignId: payload.campaignId
1503
+ }, ['behavioral', 'business', 'operational']);
1504
+ const {
1505
+ error: detailedError
1506
+ } = (0, _Utils.getErrorDetails)(error, _constants.METHODS.SKIP_PREVIEW_CONTACT, _constants.CC_FILE);
1507
+ throw detailedError;
1508
+ }
1509
+ }
1510
+
1511
+ /**
1512
+ * Removes a campaign preview contact from the campaign list entirely.
1513
+ *
1514
+ * When a campaign manager reserves a contact for an agent, the agent receives an
1515
+ * `AgentOfferCampaignReservation` event. Instead of accepting or skipping, the agent can
1516
+ * remove the preview contact to permanently take it out of the campaign contact list.
1517
+ *
1518
+ * @param {PreviewContactPayload} payload - The preview contact payload containing interactionId and campaignId (campaign name, not UUID).
1519
+ * @returns {Promise<TaskResponse>} Promise resolving with agent contact on success.
1520
+ * @throws {Error} If the operation fails (network error, etc.)
1521
+ *
1522
+ * @example
1523
+ * ```typescript
1524
+ * webex.cc.on('task:campaignPreviewReservation', async (task) => {
1525
+ * const { interactionId } = task.data;
1526
+ * const campaignId = task.data.interaction.callProcessingDetails.campaignId;
1527
+ *
1528
+ * const result = await webex.cc.removePreviewContact({ interactionId, campaignId });
1529
+ * });
1530
+ * ```
1531
+ */
1532
+ async removePreviewContact(payload) {
1533
+ const task = this.taskManager.getTask(payload.interactionId);
1534
+ if (task?.data?.interaction?.callProcessingDetails?.campaignPreviewRemoveDisabled === 'true') {
1535
+ _loggerProxy.default.warn('Remove action is disabled for this campaign preview contact', {
1536
+ module: _constants.CC_FILE,
1537
+ method: _constants.METHODS.REMOVE_PREVIEW_CONTACT,
1538
+ interactionId: payload.interactionId
1539
+ });
1540
+ throw new Error('Remove action is disabled for this campaign preview contact');
1541
+ }
1542
+ _loggerProxy.default.info('Removing campaign preview contact', {
1543
+ module: _constants.CC_FILE,
1544
+ method: _constants.METHODS.REMOVE_PREVIEW_CONTACT
1545
+ });
1546
+ try {
1547
+ this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.CAMPAIGN_PREVIEW_REMOVE_SUCCESS, _constants4.METRIC_EVENT_NAMES.CAMPAIGN_PREVIEW_REMOVE_FAILED]);
1548
+ const result = await this.services.dialer.removePreviewContact({
1549
+ data: payload
1550
+ });
1551
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.CAMPAIGN_PREVIEW_REMOVE_SUCCESS, {
1552
+ ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(result),
1553
+ interactionId: payload.interactionId,
1554
+ campaignId: payload.campaignId
1555
+ }, ['behavioral', 'business', 'operational']);
1556
+ _loggerProxy.default.log('Campaign preview contact removed successfully', {
1557
+ module: _constants.CC_FILE,
1558
+ method: _constants.METHODS.REMOVE_PREVIEW_CONTACT,
1559
+ trackingId: result.trackingId,
1560
+ interactionId: payload.interactionId
1561
+ });
1562
+ return result;
1563
+ } catch (error) {
1564
+ const failure = error.details;
1565
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.CAMPAIGN_PREVIEW_REMOVE_FAILED, {
1566
+ ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(failure),
1567
+ interactionId: payload.interactionId,
1568
+ campaignId: payload.campaignId
1569
+ }, ['behavioral', 'business', 'operational']);
1570
+ const {
1571
+ error: detailedError
1572
+ } = (0, _Utils.getErrorDetails)(error, _constants.METHODS.REMOVE_PREVIEW_CONTACT, _constants.CC_FILE);
1573
+ throw detailedError;
1574
+ }
1575
+ }
1576
+
1447
1577
  /**
1448
1578
  * Fetches outdial ANI (Automatic Number Identification) entries for an outdial ANI ID.
1449
1579
  *