@webex/contact-center 3.9.0-next.9 → 3.10.0

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 (95) hide show
  1. package/dist/cc.js +182 -47
  2. package/dist/cc.js.map +1 -1
  3. package/dist/constants.js +1 -0
  4. package/dist/constants.js.map +1 -1
  5. package/dist/index.js +9 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/logger-proxy.js +24 -1
  8. package/dist/logger-proxy.js.map +1 -1
  9. package/dist/metrics/behavioral-events.js +89 -0
  10. package/dist/metrics/behavioral-events.js.map +1 -1
  11. package/dist/metrics/constants.js +30 -2
  12. package/dist/metrics/constants.js.map +1 -1
  13. package/dist/services/AddressBook.js +271 -0
  14. package/dist/services/AddressBook.js.map +1 -0
  15. package/dist/services/EntryPoint.js +227 -0
  16. package/dist/services/EntryPoint.js.map +1 -0
  17. package/dist/services/Queue.js +261 -0
  18. package/dist/services/Queue.js.map +1 -0
  19. package/dist/services/config/constants.js +36 -2
  20. package/dist/services/config/constants.js.map +1 -1
  21. package/dist/services/config/index.js +29 -21
  22. package/dist/services/config/index.js.map +1 -1
  23. package/dist/services/config/types.js +33 -1
  24. package/dist/services/config/types.js.map +1 -1
  25. package/dist/services/core/Utils.js +42 -1
  26. package/dist/services/core/Utils.js.map +1 -1
  27. package/dist/services/task/TaskManager.js +113 -3
  28. package/dist/services/task/TaskManager.js.map +1 -1
  29. package/dist/services/task/TaskUtils.js +76 -0
  30. package/dist/services/task/TaskUtils.js.map +1 -0
  31. package/dist/services/task/constants.js +26 -1
  32. package/dist/services/task/constants.js.map +1 -1
  33. package/dist/services/task/contact.js +86 -0
  34. package/dist/services/task/contact.js.map +1 -1
  35. package/dist/services/task/index.js +241 -5
  36. package/dist/services/task/index.js.map +1 -1
  37. package/dist/services/task/types.js +14 -0
  38. package/dist/services/task/types.js.map +1 -1
  39. package/dist/types/cc.d.ts +115 -35
  40. package/dist/types/constants.d.ts +1 -0
  41. package/dist/types/index.d.ts +3 -2
  42. package/dist/types/metrics/constants.d.ts +24 -1
  43. package/dist/types/services/AddressBook.d.ts +74 -0
  44. package/dist/types/services/EntryPoint.d.ts +67 -0
  45. package/dist/types/services/Queue.d.ts +76 -0
  46. package/dist/types/services/config/constants.d.ts +35 -1
  47. package/dist/types/services/config/index.d.ts +6 -9
  48. package/dist/types/services/config/types.d.ts +79 -58
  49. package/dist/types/services/core/Utils.d.ts +14 -1
  50. package/dist/types/services/task/TaskUtils.d.ts +28 -0
  51. package/dist/types/services/task/constants.d.ts +23 -0
  52. package/dist/types/services/task/contact.d.ts +10 -0
  53. package/dist/types/services/task/index.d.ts +64 -1
  54. package/dist/types/services/task/types.d.ts +221 -19
  55. package/dist/types/types.d.ts +162 -0
  56. package/dist/types/utils/PageCache.d.ts +173 -0
  57. package/dist/types.js +17 -0
  58. package/dist/types.js.map +1 -1
  59. package/dist/utils/PageCache.js +192 -0
  60. package/dist/utils/PageCache.js.map +1 -0
  61. package/dist/webex.js +1 -1
  62. package/package.json +10 -9
  63. package/src/cc.ts +206 -52
  64. package/src/constants.ts +1 -0
  65. package/src/index.ts +16 -2
  66. package/src/logger-proxy.ts +24 -1
  67. package/src/metrics/behavioral-events.ts +94 -0
  68. package/src/metrics/constants.ts +34 -1
  69. package/src/services/AddressBook.ts +291 -0
  70. package/src/services/EntryPoint.ts +241 -0
  71. package/src/services/Queue.ts +277 -0
  72. package/src/services/config/constants.ts +42 -2
  73. package/src/services/config/index.ts +30 -30
  74. package/src/services/config/types.ts +59 -58
  75. package/src/services/core/Utils.ts +44 -0
  76. package/src/services/task/TaskManager.ts +122 -5
  77. package/src/services/task/TaskUtils.ts +81 -0
  78. package/src/services/task/constants.ts +25 -0
  79. package/src/services/task/contact.ts +80 -0
  80. package/src/services/task/index.ts +300 -4
  81. package/src/services/task/types.ts +239 -18
  82. package/src/types.ts +180 -0
  83. package/src/utils/PageCache.ts +252 -0
  84. package/test/unit/spec/cc.ts +282 -85
  85. package/test/unit/spec/metrics/behavioral-events.ts +42 -0
  86. package/test/unit/spec/services/AddressBook.ts +332 -0
  87. package/test/unit/spec/services/EntryPoint.ts +259 -0
  88. package/test/unit/spec/services/Queue.ts +323 -0
  89. package/test/unit/spec/services/config/index.ts +279 -65
  90. package/test/unit/spec/services/task/TaskManager.ts +382 -0
  91. package/test/unit/spec/services/task/TaskUtils.ts +131 -0
  92. package/test/unit/spec/services/task/contact.ts +31 -1
  93. package/test/unit/spec/services/task/index.ts +242 -8
  94. package/umd/contact-center.min.js +2 -2
  95. package/umd/contact-center.min.js.map +1 -1
@@ -5,11 +5,12 @@ import {
5
5
  generateTaskErrorObject,
6
6
  deriveConsultTransferDestinationType,
7
7
  getDestinationAgentId,
8
+ buildConsultConferenceParamData,
8
9
  } from '../core/Utils';
9
10
  import {Failure} from '../core/GlobalTypes';
10
11
  import {LoginOption} from '../../types';
11
12
  import {TASK_FILE} from '../../constants';
12
- import {METHODS} from './constants';
13
+ import {METHODS, KEYS_TO_NOT_DELETE} from './constants';
13
14
  import routingContact from './contact';
14
15
  import LoggerProxy from '../../logger-proxy';
15
16
  import {
@@ -138,6 +139,7 @@ export default class Task extends EventEmitter implements ITask {
138
139
  public webCallMap: Record<TaskId, CallId>;
139
140
  private wrapupData: WrapupData;
140
141
  public autoWrapup?: AutoWrapup;
142
+ private agentId: string;
141
143
 
142
144
  /**
143
145
  * Creates a new Task instance which provides the following features:
@@ -150,7 +152,8 @@ export default class Task extends EventEmitter implements ITask {
150
152
  contact: ReturnType<typeof routingContact>,
151
153
  webCallingService: WebCallingService,
152
154
  data: TaskData,
153
- wrapupData: WrapupData
155
+ wrapupData: WrapupData,
156
+ agentId: string
154
157
  ) {
155
158
  super();
156
159
  this.contact = contact;
@@ -161,6 +164,7 @@ export default class Task extends EventEmitter implements ITask {
161
164
  this.metricsManager = MetricsManager.getInstance();
162
165
  this.registerWebCallListeners();
163
166
  this.setupAutoWrapupTimer();
167
+ this.agentId = agentId;
164
168
  }
165
169
 
166
170
  /**
@@ -277,9 +281,24 @@ export default class Task extends EventEmitter implements ITask {
277
281
  * @private
278
282
  */
279
283
  private reconcileData(oldData: TaskData, newData: TaskData): TaskData {
284
+ // Remove keys from oldData that are not in newData
285
+ Object.keys(oldData).forEach((key) => {
286
+ if (!(key in newData) && !KEYS_TO_NOT_DELETE.includes(key as string)) {
287
+ delete oldData[key];
288
+ }
289
+ });
290
+
291
+ // Merge or update keys from newData
280
292
  Object.keys(newData).forEach((key) => {
281
- if (newData[key] && typeof newData[key] === 'object' && !Array.isArray(newData[key])) {
282
- oldData[key] = this.reconcileData({...oldData[key]}, newData[key]);
293
+ if (
294
+ newData[key] &&
295
+ typeof newData[key] === 'object' &&
296
+ !Array.isArray(newData[key]) &&
297
+ oldData[key] &&
298
+ typeof oldData[key] === 'object' &&
299
+ !Array.isArray(oldData[key])
300
+ ) {
301
+ this.reconcileData(oldData[key], newData[key]);
283
302
  } else {
284
303
  oldData[key] = newData[key];
285
304
  }
@@ -1488,4 +1507,281 @@ export default class Task extends EventEmitter implements ITask {
1488
1507
  throw err;
1489
1508
  }
1490
1509
  }
1510
+
1511
+ /**
1512
+ * Starts a consultation conference by merging the consultation call with the main call
1513
+ *
1514
+ * Creates a three-way conference between the agent, customer, and consulted party
1515
+ * Extracts required consultation data from the current task data
1516
+ * On success, emits a `task:conferenceStarted` event
1517
+ *
1518
+ * @returns Promise<TaskResponse> - Response from the consultation conference API
1519
+ * @throws Error if the operation fails or if consultation data is invalid
1520
+ *
1521
+ * @example
1522
+ * ```typescript
1523
+ * try {
1524
+ * await task.consultConference();
1525
+ * console.log('Conference started successfully');
1526
+ * } catch (error) {
1527
+ * console.error('Failed to start conference:', error);
1528
+ * }
1529
+ * ```
1530
+ */
1531
+ public async consultConference(): Promise<TaskResponse> {
1532
+ // Extract consultation conference data from task data (used in both try and catch)
1533
+ const consultationData = {
1534
+ agentId: this.agentId,
1535
+ destAgentId: this.data.destAgentId,
1536
+ destinationType: this.data.destinationType || 'agent',
1537
+ };
1538
+
1539
+ try {
1540
+ LoggerProxy.info(`Initiating consult conference to ${consultationData.destAgentId}`, {
1541
+ module: TASK_FILE,
1542
+ method: METHODS.CONSULT_CONFERENCE,
1543
+ interactionId: this.data.interactionId,
1544
+ });
1545
+
1546
+ const paramsDataForConferenceV2 = buildConsultConferenceParamData(
1547
+ consultationData,
1548
+ this.data.interactionId
1549
+ );
1550
+
1551
+ const response = await this.contact.consultConference({
1552
+ interactionId: paramsDataForConferenceV2.interactionId,
1553
+ data: paramsDataForConferenceV2.data,
1554
+ });
1555
+
1556
+ // Track success metrics (following consultTransfer pattern)
1557
+ this.metricsManager.trackEvent(
1558
+ METRIC_EVENT_NAMES.TASK_CONFERENCE_START_SUCCESS,
1559
+ {
1560
+ taskId: this.data.interactionId,
1561
+ destination: paramsDataForConferenceV2.data.to,
1562
+ destinationType: paramsDataForConferenceV2.data.destinationType,
1563
+ agentId: paramsDataForConferenceV2.data.agentId,
1564
+ ...MetricsManager.getCommonTrackingFieldForAQMResponse(response),
1565
+ },
1566
+ ['operational', 'behavioral', 'business']
1567
+ );
1568
+
1569
+ LoggerProxy.log(`Consult conference started successfully`, {
1570
+ module: TASK_FILE,
1571
+ method: METHODS.CONSULT_CONFERENCE,
1572
+ interactionId: this.data.interactionId,
1573
+ });
1574
+
1575
+ return response;
1576
+ } catch (error) {
1577
+ const err = generateTaskErrorObject(error, METHODS.CONSULT_CONFERENCE, TASK_FILE);
1578
+ const taskErrorProps = {
1579
+ trackingId: err.data?.trackingId,
1580
+ errorMessage: err.data?.message,
1581
+ errorType: err.data?.errorType,
1582
+ errorData: err.data?.errorData,
1583
+ reasonCode: err.data?.reasonCode,
1584
+ };
1585
+
1586
+ // Track failure metrics (following consultTransfer pattern)
1587
+ // Build conference data for error tracking using extracted data
1588
+ const failedParamsData = buildConsultConferenceParamData(
1589
+ consultationData,
1590
+ this.data.interactionId
1591
+ );
1592
+
1593
+ this.metricsManager.trackEvent(
1594
+ METRIC_EVENT_NAMES.TASK_CONFERENCE_START_FAILED,
1595
+ {
1596
+ taskId: this.data.interactionId,
1597
+ destination: failedParamsData.data.to,
1598
+ destinationType: failedParamsData.data.destinationType,
1599
+ agentId: failedParamsData.data.agentId,
1600
+ error: error.toString(),
1601
+ ...taskErrorProps,
1602
+ ...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details || {}),
1603
+ },
1604
+ ['operational', 'behavioral', 'business']
1605
+ );
1606
+
1607
+ LoggerProxy.error(`Failed to start consult conference`, {
1608
+ module: TASK_FILE,
1609
+ method: METHODS.CONSULT_CONFERENCE,
1610
+ interactionId: this.data.interactionId,
1611
+ });
1612
+
1613
+ throw err;
1614
+ }
1615
+ }
1616
+
1617
+ /**
1618
+ * Exits the current conference by removing the agent from the conference call
1619
+ *
1620
+ * Exits the agent from the conference, leaving the customer and consulted party connected
1621
+ * On success, emits a `task:conferenceEnded` event
1622
+ *
1623
+ * @returns Promise<TaskResponse> - Response from the conference exit API
1624
+ * @throws Error if the operation fails or if no active conference exists
1625
+ *
1626
+ * @example
1627
+ * ```typescript
1628
+ * try {
1629
+ * await task.exitConference();
1630
+ * console.log('Successfully exited conference');
1631
+ * } catch (error) {
1632
+ * console.error('Failed to exit conference:', error);
1633
+ * }
1634
+ * ```
1635
+ */
1636
+ public async exitConference(): Promise<TaskResponse> {
1637
+ try {
1638
+ LoggerProxy.info(`Exiting consult conference`, {
1639
+ module: TASK_FILE,
1640
+ method: METHODS.EXIT_CONFERENCE,
1641
+ interactionId: this.data.interactionId,
1642
+ });
1643
+
1644
+ // Validate that interaction ID exists
1645
+ if (!this.data.interactionId) {
1646
+ throw new Error('Invalid interaction ID');
1647
+ }
1648
+
1649
+ const response = await this.contact.exitConference({
1650
+ interactionId: this.data.interactionId,
1651
+ });
1652
+
1653
+ // Track success metrics (following consultTransfer pattern)
1654
+ this.metricsManager.trackEvent(
1655
+ METRIC_EVENT_NAMES.TASK_CONFERENCE_END_SUCCESS,
1656
+ {
1657
+ taskId: this.data.interactionId,
1658
+ ...MetricsManager.getCommonTrackingFieldForAQMResponse(response),
1659
+ },
1660
+ ['operational', 'behavioral', 'business']
1661
+ );
1662
+
1663
+ LoggerProxy.log(`Consult conference exited successfully`, {
1664
+ module: TASK_FILE,
1665
+ method: METHODS.EXIT_CONFERENCE,
1666
+ interactionId: this.data.interactionId,
1667
+ });
1668
+
1669
+ return response;
1670
+ } catch (error) {
1671
+ const err = generateTaskErrorObject(error, METHODS.EXIT_CONFERENCE, TASK_FILE);
1672
+ const taskErrorProps = {
1673
+ trackingId: err.data?.trackingId,
1674
+ errorMessage: err.data?.message,
1675
+ errorType: err.data?.errorType,
1676
+ errorData: err.data?.errorData,
1677
+ reasonCode: err.data?.reasonCode,
1678
+ };
1679
+
1680
+ // Track failure metrics (following consultTransfer pattern)
1681
+ this.metricsManager.trackEvent(
1682
+ METRIC_EVENT_NAMES.TASK_CONFERENCE_END_FAILED,
1683
+ {
1684
+ taskId: this.data.interactionId,
1685
+ error: error.toString(),
1686
+ ...taskErrorProps,
1687
+ ...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details || {}),
1688
+ },
1689
+ ['operational', 'behavioral', 'business']
1690
+ );
1691
+
1692
+ LoggerProxy.error(`Failed to exit consult conference`, {
1693
+ module: TASK_FILE,
1694
+ method: METHODS.EXIT_CONFERENCE,
1695
+ interactionId: this.data.interactionId,
1696
+ });
1697
+
1698
+ throw err;
1699
+ }
1700
+ }
1701
+
1702
+ /**
1703
+ * Transfers the current conference to another agent
1704
+ *
1705
+ * Moves the entire conference (including all participants) to a new agent,
1706
+ * while the current agent exits and goes to wrapup
1707
+ * On success, the current agent receives `task:conferenceEnded` event
1708
+ *
1709
+ * @returns Promise<TaskResponse> - Response from the conference transfer API
1710
+ * @throws Error if the operation fails or if no active conference exists
1711
+ *
1712
+ * @example
1713
+ * ```typescript
1714
+ * try {
1715
+ * await task.transferConference();
1716
+ * console.log('Conference transferred successfully');
1717
+ * } catch (error) {
1718
+ * console.error('Failed to transfer conference:', error);
1719
+ * }
1720
+ * ```
1721
+ */
1722
+ public async transferConference(): Promise<TaskResponse> {
1723
+ try {
1724
+ LoggerProxy.info(`Transferring conference`, {
1725
+ module: TASK_FILE,
1726
+ method: METHODS.TRANSFER_CONFERENCE,
1727
+ interactionId: this.data.interactionId,
1728
+ });
1729
+
1730
+ // Validate that interaction ID exists
1731
+ if (!this.data.interactionId) {
1732
+ throw new Error('Invalid interaction ID');
1733
+ }
1734
+
1735
+ const response = await this.contact.conferenceTransfer({
1736
+ interactionId: this.data.interactionId,
1737
+ });
1738
+
1739
+ // Track success metrics (following consultTransfer pattern)
1740
+ this.metricsManager.trackEvent(
1741
+ METRIC_EVENT_NAMES.TASK_CONFERENCE_TRANSFER_SUCCESS,
1742
+ {
1743
+ taskId: this.data.interactionId,
1744
+ ...MetricsManager.getCommonTrackingFieldForAQMResponse(response),
1745
+ },
1746
+ ['operational', 'behavioral', 'business']
1747
+ );
1748
+
1749
+ LoggerProxy.log(`Conference transferred successfully`, {
1750
+ module: TASK_FILE,
1751
+ method: METHODS.TRANSFER_CONFERENCE,
1752
+ interactionId: this.data.interactionId,
1753
+ });
1754
+
1755
+ return response;
1756
+ } catch (error) {
1757
+ const err = generateTaskErrorObject(error, METHODS.TRANSFER_CONFERENCE, TASK_FILE);
1758
+ const taskErrorProps = {
1759
+ trackingId: err.data?.trackingId,
1760
+ errorMessage: err.data?.message,
1761
+ errorType: err.data?.errorType,
1762
+ errorData: err.data?.errorData,
1763
+ reasonCode: err.data?.reasonCode,
1764
+ };
1765
+
1766
+ // Track failure metrics (following consultTransfer pattern)
1767
+ this.metricsManager.trackEvent(
1768
+ METRIC_EVENT_NAMES.TASK_CONFERENCE_TRANSFER_FAILED,
1769
+ {
1770
+ taskId: this.data.interactionId,
1771
+ error: error.toString(),
1772
+ ...taskErrorProps,
1773
+ ...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details || {}),
1774
+ },
1775
+ ['operational', 'behavioral', 'business']
1776
+ );
1777
+
1778
+ LoggerProxy.error(`Failed to transfer conference`, {
1779
+ module: TASK_FILE,
1780
+ method: METHODS.TRANSFER_CONFERENCE,
1781
+ interactionId: this.data.interactionId,
1782
+ });
1783
+
1784
+ throw err;
1785
+ }
1786
+ }
1491
1787
  }
@@ -370,6 +370,126 @@ export enum TASK_EVENTS {
370
370
  * ```
371
371
  */
372
372
  TASK_OFFER_CONTACT = 'task:offerContact',
373
+
374
+ /**
375
+ * Triggered when a conference is being established
376
+ * @example
377
+ * ```typescript
378
+ * task.on(TASK_EVENTS.TASK_CONFERENCE_ESTABLISHING, (task: ITask) => {
379
+ * console.log('Conference establishing:', task.data.interactionId);
380
+ * // Handle conference setup in progress
381
+ * });
382
+ * ```
383
+ */
384
+ TASK_CONFERENCE_ESTABLISHING = 'task:conferenceEstablishing',
385
+
386
+ /**
387
+ * Triggered when a conference is started successfully
388
+ * @example
389
+ * ```typescript
390
+ * task.on(TASK_EVENTS.TASK_CONFERENCE_STARTED, (task: ITask) => {
391
+ * console.log('Conference started:', task.data.interactionId);
392
+ * // Handle conference start
393
+ * });
394
+ * ```
395
+ */
396
+ TASK_CONFERENCE_STARTED = 'task:conferenceStarted',
397
+
398
+ /**
399
+ * Triggered when a conference fails to start
400
+ * @example
401
+ * ```typescript
402
+ * task.on(TASK_EVENTS.TASK_CONFERENCE_FAILED, (task: ITask) => {
403
+ * console.log('Conference failed:', task.data.interactionId);
404
+ * // Handle conference failure
405
+ * });
406
+ * ```
407
+ */
408
+ TASK_CONFERENCE_FAILED = 'task:conferenceFailed',
409
+
410
+ /**
411
+ * Triggered when a conference is ended successfully
412
+ * @example
413
+ * ```typescript
414
+ * task.on(TASK_EVENTS.TASK_CONFERENCE_ENDED, (task: ITask) => {
415
+ * console.log('Conference ended:', task.data.interactionId);
416
+ * // Handle conference end
417
+ * });
418
+ * ```
419
+ */
420
+ TASK_CONFERENCE_ENDED = 'task:conferenceEnded',
421
+
422
+ /**
423
+ * Triggered when a participant joins the conference
424
+ * @example
425
+ * ```typescript
426
+ * task.on(TASK_EVENTS.TASK_PARTICIPANT_JOINED, (task: ITask) => {
427
+ * console.log('Participant joined conference:', task.data.interactionId);
428
+ * // Handle participant joining
429
+ * });
430
+ * ```
431
+ */
432
+ TASK_PARTICIPANT_JOINED = 'task:participantJoined',
433
+
434
+ /**
435
+ * Triggered when a participant leaves the conference
436
+ * @example
437
+ * ```typescript
438
+ * task.on(TASK_EVENTS.TASK_PARTICIPANT_LEFT, (task: ITask) => {
439
+ * console.log('Participant left conference:', task.data.interactionId);
440
+ * // Handle participant leaving
441
+ * });
442
+ * ```
443
+ */
444
+ TASK_PARTICIPANT_LEFT = 'task:participantLeft',
445
+
446
+ /**
447
+ * Triggered when conference transfer is successful
448
+ * @example
449
+ * ```typescript
450
+ * task.on(TASK_EVENTS.TASK_CONFERENCE_TRANSFERRED, (task: ITask) => {
451
+ * console.log('Conference transferred:', task.data.interactionId);
452
+ * // Handle successful conference transfer
453
+ * });
454
+ * ```
455
+ */
456
+ TASK_CONFERENCE_TRANSFERRED = 'task:conferenceTransferred',
457
+
458
+ /**
459
+ * Triggered when conference transfer fails
460
+ * @example
461
+ * ```typescript
462
+ * task.on(TASK_EVENTS.TASK_CONFERENCE_TRANSFER_FAILED, (task: ITask) => {
463
+ * console.log('Conference transfer failed:', task.data.interactionId);
464
+ * // Handle failed conference transfer
465
+ * });
466
+ * ```
467
+ */
468
+ TASK_CONFERENCE_TRANSFER_FAILED = 'task:conferenceTransferFailed',
469
+
470
+ /**
471
+ * Triggered when ending a conference fails
472
+ * @example
473
+ * ```typescript
474
+ * task.on(TASK_EVENTS.TASK_CONFERENCE_END_FAILED, (task: ITask) => {
475
+ * console.log('Conference end failed:', task.data.interactionId);
476
+ * // Handle failed conference end
477
+ * });
478
+ * ```
479
+ */
480
+ TASK_CONFERENCE_END_FAILED = 'task:conferenceEndFailed',
481
+
482
+ /**
483
+ * Triggered when participant exit from conference fails
484
+ * @example
485
+ * ```typescript
486
+ * task.on(TASK_EVENTS.TASK_PARTICIPANT_LEFT_FAILED, (task: ITask) => {
487
+ * console.log('Participant failed to leave conference:', task.data.interactionId);
488
+ * // Handle failed participant exit
489
+ * });
490
+ * ```
491
+ */
492
+ TASK_PARTICIPANT_LEFT_FAILED = 'task:participantLeftFailed',
373
493
  }
374
494
 
375
495
  /**
@@ -613,6 +733,8 @@ export type TaskData = {
613
733
  isConsulted?: boolean;
614
734
  /** Indicates if the task is in conference state */
615
735
  isConferencing: boolean;
736
+ /** Indicates if a conference is currently in progress (2+ active agents) */
737
+ isConferenceInProgress?: boolean;
616
738
  /** Identifier of agent who last updated the task */
617
739
  updatedBy?: string;
618
740
  /** Type of destination for transfer/consult */
@@ -883,6 +1005,19 @@ export type ConsultConferenceData = {
883
1005
  destinationType: string;
884
1006
  };
885
1007
 
1008
+ /**
1009
+ * Legacy consultation conference data type matching Agent Desktop
1010
+ * @public
1011
+ */
1012
+ export type consultConferencePayloadData = {
1013
+ /** Identifier of the agent initiating consult/conference */
1014
+ agentId: string;
1015
+ /** Type of destination (e.g., 'agent', 'queue') */
1016
+ destinationType: string;
1017
+ /** Identifier of the destination agent */
1018
+ destAgentId: string;
1019
+ };
1020
+
886
1021
  /**
887
1022
  * Parameters required for cancelling a consult to queue operation
888
1023
  * @public
@@ -931,6 +1066,8 @@ export type DialerPayload = {
931
1066
  mediaType: 'telephony' | 'chat' | 'social' | 'email';
932
1067
  /** The outbound type for the task */
933
1068
  outboundType: 'OUTDIAL' | 'CALLBACK' | 'EXECUTE_FLOW';
1069
+ /** The Outdial ANI number that will be used while making a call to the customer. */
1070
+ origin: string;
934
1071
  };
935
1072
 
936
1073
  /**
@@ -1000,16 +1137,16 @@ export interface ITask extends EventEmitter {
1000
1137
  autoWrapup?: AutoWrapup;
1001
1138
 
1002
1139
  /**
1003
- * cancels the auto-wrapup timer for the task
1004
- * This method stops the auto-wrapup process if it is currently active
1140
+ * Cancels the auto-wrapup timer for the task.
1141
+ * This method stops the auto-wrapup process if it is currently active.
1005
1142
  * Note: This is supported only in single session mode. Not supported in multi-session mode.
1006
1143
  * @returns void
1007
1144
  */
1008
1145
  cancelAutoWrapupTimer(): void;
1009
1146
 
1010
1147
  /**
1011
- * Deregisters all web call event listeners
1012
- * Used when cleaning up task resources
1148
+ * Deregisters all web call event listeners.
1149
+ * Used when cleaning up task resources.
1013
1150
  * @ignore
1014
1151
  */
1015
1152
  unregisterWebCallListeners(): void;
@@ -1029,7 +1166,7 @@ export interface ITask extends EventEmitter {
1029
1166
  * @returns Promise<TaskResponse>
1030
1167
  * @example
1031
1168
  * ```typescript
1032
- * task.accept();
1169
+ * await task.accept();
1033
1170
  * ```
1034
1171
  */
1035
1172
  accept(): Promise<TaskResponse>;
@@ -1039,48 +1176,48 @@ export interface ITask extends EventEmitter {
1039
1176
  * @returns Promise<TaskResponse>
1040
1177
  * @example
1041
1178
  * ```typescript
1042
- * task.decline();
1179
+ * await task.decline();
1043
1180
  * ```
1044
1181
  */
1045
1182
  decline(): Promise<TaskResponse>;
1046
1183
 
1047
1184
  /**
1048
- * Places the current task on hold
1185
+ * Places the current task on hold.
1049
1186
  * @returns Promise<TaskResponse>
1050
1187
  * @example
1051
1188
  * ```typescript
1052
- * task.hold();
1189
+ * await task.hold();
1053
1190
  * ```
1054
1191
  */
1055
1192
  hold(): Promise<TaskResponse>;
1056
1193
 
1057
1194
  /**
1058
- * Resumes a task that was previously on hold
1195
+ * Resumes a task that was previously on hold.
1059
1196
  * @returns Promise<TaskResponse>
1060
1197
  * @example
1061
1198
  * ```typescript
1062
- * task.resume();
1199
+ * await task.resume();
1063
1200
  * ```
1064
1201
  */
1065
1202
  resume(): Promise<TaskResponse>;
1066
1203
 
1067
1204
  /**
1068
- * Ends/terminates the current task
1205
+ * Ends/terminates the current task.
1069
1206
  * @returns Promise<TaskResponse>
1070
1207
  * @example
1071
1208
  * ```typescript
1072
- * task.end();
1209
+ * await task.end();
1073
1210
  * ```
1074
1211
  */
1075
1212
  end(): Promise<TaskResponse>;
1076
1213
 
1077
1214
  /**
1078
- * Initiates wrap-up process for the task with specified details
1215
+ * Initiates wrap-up process for the task with specified details.
1079
1216
  * @param wrapupPayload - Wrap-up details including reason and auxiliary code
1080
1217
  * @returns Promise<TaskResponse>
1081
1218
  * @example
1082
1219
  * ```typescript
1083
- * task.wrapup({
1220
+ * await task.wrapup({
1084
1221
  * wrapUpReason: "Customer issue resolved",
1085
1222
  * auxCodeId: "RESOLVED"
1086
1223
  * });
@@ -1089,25 +1226,109 @@ export interface ITask extends EventEmitter {
1089
1226
  wrapup(wrapupPayload: WrapupPayLoad): Promise<TaskResponse>;
1090
1227
 
1091
1228
  /**
1092
- * Pauses the recording for current task
1229
+ * Pauses the recording for current task.
1093
1230
  * @returns Promise<TaskResponse>
1094
1231
  * @example
1095
1232
  * ```typescript
1096
- * task.pauseRecording();
1233
+ * await task.pauseRecording();
1097
1234
  * ```
1098
1235
  */
1099
1236
  pauseRecording(): Promise<TaskResponse>;
1100
1237
 
1101
1238
  /**
1102
- * Resumes a previously paused recording
1239
+ * Resumes a previously paused recording.
1103
1240
  * @param resumeRecordingPayload - Parameters for resuming the recording
1104
1241
  * @returns Promise<TaskResponse>
1105
1242
  * @example
1106
1243
  * ```typescript
1107
- * task.resumeRecording({
1244
+ * await task.resumeRecording({
1108
1245
  * autoResumed: false
1109
1246
  * });
1110
1247
  * ```
1111
1248
  */
1112
1249
  resumeRecording(resumeRecordingPayload: ResumeRecordingPayload): Promise<TaskResponse>;
1250
+
1251
+ /**
1252
+ * Initiates a consultation with another agent or queue.
1253
+ * @param consultPayload - Consultation details including destination and type
1254
+ * @returns Promise<TaskResponse>
1255
+ * @example
1256
+ * ```typescript
1257
+ * await task.consult({ to: "agentId", destinationType: "agent" });
1258
+ * ```
1259
+ */
1260
+ consult(consultPayload: ConsultPayload): Promise<TaskResponse>;
1261
+
1262
+ /**
1263
+ * Ends an ongoing consultation.
1264
+ * @param consultEndPayload - Details for ending the consultation
1265
+ * @returns Promise<TaskResponse>
1266
+ * @example
1267
+ * ```typescript
1268
+ * await task.endConsult({ isConsult: true, taskId: "taskId" });
1269
+ * ```
1270
+ */
1271
+ endConsult(consultEndPayload: ConsultEndPayload): Promise<TaskResponse>;
1272
+
1273
+ /**
1274
+ * Transfers the task to another agent or queue.
1275
+ * @param transferPayload - Transfer details including destination and type
1276
+ * @returns Promise<TaskResponse>
1277
+ * @example
1278
+ * ```typescript
1279
+ * await task.transfer({ to: "queueId", destinationType: "queue" });
1280
+ * ```
1281
+ */
1282
+ transfer(transferPayload: TransferPayLoad): Promise<TaskResponse>;
1283
+
1284
+ /**
1285
+ * Transfers the task after consultation.
1286
+ * @param consultTransferPayload - Details for consult transfer (optional)
1287
+ * @returns Promise<TaskResponse>
1288
+ * @example
1289
+ * ```typescript
1290
+ * await task.consultTransfer({ to: "agentId", destinationType: "agent" });
1291
+ * ```
1292
+ */
1293
+ consultTransfer(consultTransferPayload?: ConsultTransferPayLoad): Promise<TaskResponse>;
1294
+
1295
+ /**
1296
+ * Initiates a consult conference (merge consult call with main call).
1297
+ * @returns Promise<TaskResponse>
1298
+ * @example
1299
+ * ```typescript
1300
+ * await task.consultConference();
1301
+ * ```
1302
+ */
1303
+ consultConference(): Promise<TaskResponse>;
1304
+
1305
+ /**
1306
+ * Exits from an ongoing conference.
1307
+ * @returns Promise<TaskResponse>
1308
+ * @example
1309
+ * ```typescript
1310
+ * await task.exitConference();
1311
+ * ```
1312
+ */
1313
+ exitConference(): Promise<TaskResponse>;
1314
+
1315
+ /**
1316
+ * Transfers the conference to another participant.
1317
+ * @returns Promise<TaskResponse>
1318
+ * @example
1319
+ * ```typescript
1320
+ * await task.transferConference();
1321
+ * ```
1322
+ */
1323
+ transferConference(): Promise<TaskResponse>;
1324
+
1325
+ /**
1326
+ * Toggles mute/unmute for the local audio stream during a WebRTC task.
1327
+ * @returns Promise<void>
1328
+ * @example
1329
+ * ```typescript
1330
+ * await task.toggleMute();
1331
+ * ```
1332
+ */
1333
+ toggleMute(): Promise<void>;
1113
1334
  }