@@ -38,14 +38,20 @@ import {
3838 MERCURY_DISCONNECTED_SUCCESS ,
3939 METHODS ,
4040} from './constants' ;
41+ import { AGENT_STATE_AVAILABLE , AGENT_STATE_AVAILABLE_ID } from './services/config/constants' ;
4142import { AGENT , WEB_RTC_PREFIX } from './services/constants' ;
4243import Services from './services' ;
4344import WebexRequest from './services/core/WebexRequest' ;
4445import LoggerProxy from './logger-proxy' ;
4546import { StateChange , Logout , StateChangeSuccess , AGENT_EVENTS } from './services/agent/types' ;
4647import { getErrorDetails , isValidDialNumber } from './services/core/Utils' ;
47- import { Profile , WelcomeEvent , CC_EVENTS } from './services/config/types' ;
48- import { AGENT_STATE_AVAILABLE , AGENT_STATE_AVAILABLE_ID } from './services/config/constants' ;
48+ import {
49+ Profile ,
50+ WelcomeEvent ,
51+ CC_EVENTS ,
52+ OutdialAniEntriesResponse ,
53+ OutdialAniParams ,
54+ } from './services/config/types' ;
4955import { ConnectionLostDetails } from './services/core/websocket/types' ;
5056import TaskManager from './services/task/TaskManager' ;
5157import WebCallingService from './services/WebCallingService' ;
@@ -1330,6 +1336,7 @@ export default class ContactCenter extends WebexPlugin implements IContactCenter
13301336 * Makes an outbound call to a specified phone number.
13311337 *
13321338 * @param {string } destination - The phone number to dial (e.g., '+1234567890').
1339+ * @param {string } origin - The contact center number that will be used while making a call to the customer.
13331340 * Should include country code and be in E.164 format.
13341341 * @returns {Promise<TaskResponse> } Resolves with the task response containing:
13351342 * - interactionId: Unique identifier for the outbound call
@@ -1365,7 +1372,7 @@ export default class ContactCenter extends WebexPlugin implements IContactCenter
13651372 *
13661373 * // Start the outbound call
13671374 * const destination = '+1234567890';
1368- * const task = await cc.startOutdial(destination);
1375+ * const task = await cc.startOutdial(destination, origin );
13691376 *
13701377 * // Listen for all relevant task events
13711378 * task.on('task:ringing', () => {
@@ -1433,7 +1440,7 @@ export default class ContactCenter extends WebexPlugin implements IContactCenter
14331440 * }
14341441 * ```
14351442 */
1436- public async startOutdial ( destination : string ) : Promise < TaskResponse > {
1443+ public async startOutdial ( destination : string , origin : string ) : Promise < TaskResponse > {
14371444 LoggerProxy . info ( 'Starting outbound dial' , {
14381445 module : CC_FILE ,
14391446 method : METHODS . START_OUTDIAL ,
@@ -1447,6 +1454,7 @@ export default class ContactCenter extends WebexPlugin implements IContactCenter
14471454 // Construct the outdial payload.
14481455 const outDialPayload : DialerPayload = {
14491456 destination,
1457+ origin,
14501458 entryPointId : this . agentConfig . outDialEp ,
14511459 direction : OUTDIAL_DIRECTION ,
14521460 attributes : ATTRIBUTES ,
@@ -1461,6 +1469,7 @@ export default class ContactCenter extends WebexPlugin implements IContactCenter
14611469 {
14621470 ...MetricsManager . getCommonTrackingFieldForAQMResponse ( result ) ,
14631471 destination,
1472+ origin,
14641473 mediaType : OUTDIAL_MEDIA_TYPE ,
14651474 } ,
14661475 [ 'behavioral' , 'business' , 'operational' ]
@@ -1481,6 +1490,7 @@ export default class ContactCenter extends WebexPlugin implements IContactCenter
14811490 {
14821491 ...MetricsManager . getCommonTrackingFieldForAQMResponseFailed ( failure ) ,
14831492 destination,
1493+ origin,
14841494 mediaType : OUTDIAL_MEDIA_TYPE ,
14851495 } ,
14861496 [ 'behavioral' , 'business' , 'operational' ]
@@ -1490,6 +1500,124 @@ export default class ContactCenter extends WebexPlugin implements IContactCenter
14901500 }
14911501 }
14921502
1503+ /**
1504+ * Fetches outdial ANI (Automatic Number Identification) entries for an outdial ANI ID.
1505+ *
1506+ * This method retrieves the list of phone numbers that can be used as caller ID when making
1507+ * outbound calls. The ANI data is associated with an outdial ANI ID and can be filtered
1508+ * and paginated as needed.
1509+ *
1510+ * @param {string } outdialANI - The outdial ANI ID to fetch ANI data for
1511+ * @param {number } [page] - Optional page number for pagination (0-based)
1512+ * @param {number } [pageSize] - Optional number of items per page
1513+ * @param {string } [search] - Optional search term to filter results by name or number
1514+ * @param {string } [filter] - Optional filter string
1515+ * @param {string } [attributes] - Optional attributes to include in response
1516+ * @returns {Promise<OutdialAniEntriesResponse> } Promise resolving to outdial ANI response containing:
1517+ * - data: Array of ANI entries with number and name
1518+ * - meta: Pagination metadata
1519+ * @throws {Error } If the operation fails or agent is not registered
1520+ * @public
1521+ * @example
1522+ * ```typescript
1523+ * const cc = webex.cc;
1524+ * await cc.register();
1525+ *
1526+ * // Get agent profile to obtain outdial ANI ID
1527+ * const agentProfile = cc.agentConfig;
1528+ * const outdialANI = agentProfile.outdialANIId;
1529+ *
1530+ * // Basic usage - get all ANI data for an outdial ANI ID
1531+ * const aniData = await cc.getOutdialAniEntries({ outdialANI });
1532+ *
1533+ * // With pagination and search
1534+ * const paginatedAni = await cc.getOutdialAniEntries({
1535+ * outdialANI,
1536+ * page: 0,
1537+ * pageSize: 50,
1538+ * search: '555' // search for numbers containing '555'
1539+ * });
1540+ *
1541+ * // Process the results
1542+ * paginatedAni.forEach(ani => {
1543+ * console.log(`ANI: ${ani.number} - ${ani.name}`);
1544+ * });
1545+ * ```
1546+ */
1547+ public async getOutdialAniEntries ( params : OutdialAniParams ) : Promise < OutdialAniEntriesResponse > {
1548+ const { outdialANI, page, pageSize, search, filter, attributes} = params ;
1549+
1550+ LoggerProxy . info ( 'Fetching outdial ANI entries' , {
1551+ module : CC_FILE ,
1552+ method : METHODS . GET_OUTDIAL_ANI_ENTRIES ,
1553+ } ) ;
1554+
1555+ const orgId = this . $webex . credentials . getOrgId ( ) ;
1556+
1557+ if ( ! orgId ) {
1558+ LoggerProxy . error ( 'Org ID not found.' , {
1559+ module : CC_FILE ,
1560+ method : METHODS . GET_OUTDIAL_ANI_ENTRIES ,
1561+ } ) ;
1562+
1563+ throw new Error ( 'Org ID not found.' ) ;
1564+ }
1565+
1566+ try {
1567+ const result = await this . services . config . getOutdialAniEntries ( orgId , {
1568+ outdialANI,
1569+ page,
1570+ pageSize,
1571+ search,
1572+ filter,
1573+ attributes,
1574+ } ) ;
1575+
1576+ this . metricsManager . trackEvent (
1577+ METRIC_EVENT_NAMES . OUTDIAL_ANI_EP_FETCH_SUCCESS ,
1578+ {
1579+ outdialANI,
1580+ resultCount : result ?. length || 0 ,
1581+ } ,
1582+ [ 'behavioral' , 'business' , 'operational' ]
1583+ ) ;
1584+
1585+ LoggerProxy . log ( `Successfully retrieved outdial ANI entries for ANI ID ${ outdialANI } ` , {
1586+ module : CC_FILE ,
1587+ method : METHODS . GET_OUTDIAL_ANI_ENTRIES ,
1588+ } ) ;
1589+
1590+ return result ;
1591+ } catch ( error ) {
1592+ const failure = error . details as Failure ;
1593+ this . metricsManager . trackEvent (
1594+ METRIC_EVENT_NAMES . OUTDIAL_ANI_EP_FETCH_FAILED ,
1595+ {
1596+ ...MetricsManager . getCommonTrackingFieldForAQMResponseFailed ( failure ) ,
1597+ outdialANI,
1598+ error,
1599+ } ,
1600+ [ 'behavioral' , 'business' , 'operational' ]
1601+ ) ;
1602+
1603+ LoggerProxy . error (
1604+ `Failed to fetch outdial ANI entries for ANI ID ${ outdialANI } due to: ${ error } ` ,
1605+ {
1606+ module : CC_FILE ,
1607+ method : METHODS . GET_OUTDIAL_ANI_ENTRIES ,
1608+ trackingId : failure . trackingId ,
1609+ }
1610+ ) ;
1611+
1612+ const { error : detailedError } = getErrorDetails (
1613+ error ,
1614+ METHODS . GET_OUTDIAL_ANI_ENTRIES ,
1615+ CC_FILE
1616+ ) ;
1617+ throw detailedError ;
1618+ }
1619+ }
1620+
14931621 /**
14941622 * Uploads logs to help troubleshoot SDK issues.
14951623 *
0 commit comments