@webex/contact-center 3.11.0 → 3.12.0-mobius-socket.2

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 (126) hide show
  1. package/dist/cc.js +121 -28
  2. package/dist/cc.js.map +1 -1
  3. package/dist/constants.js +5 -1
  4. package/dist/constants.js.map +1 -1
  5. package/dist/index.js +7 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/metrics/behavioral-events.js +13 -0
  8. package/dist/metrics/behavioral-events.js.map +1 -1
  9. package/dist/metrics/constants.js +9 -1
  10. package/dist/metrics/constants.js.map +1 -1
  11. package/dist/services/ApiAiAssistant.js +173 -0
  12. package/dist/services/ApiAiAssistant.js.map +1 -0
  13. package/dist/services/agent/types.js.map +1 -1
  14. package/dist/services/config/Util.js +6 -2
  15. package/dist/services/config/Util.js.map +1 -1
  16. package/dist/services/config/constants.js +12 -0
  17. package/dist/services/config/constants.js.map +1 -1
  18. package/dist/services/config/index.js +41 -2
  19. package/dist/services/config/index.js.map +1 -1
  20. package/dist/services/config/types.js +19 -1
  21. package/dist/services/config/types.js.map +1 -1
  22. package/dist/services/constants.js +27 -1
  23. package/dist/services/constants.js.map +1 -1
  24. package/dist/services/core/Err.js.map +1 -1
  25. package/dist/services/core/Utils.js +28 -6
  26. package/dist/services/core/Utils.js.map +1 -1
  27. package/dist/services/core/aqm-reqs.js +92 -17
  28. package/dist/services/core/aqm-reqs.js.map +1 -1
  29. package/dist/services/core/websocket/WebSocketManager.js +20 -5
  30. package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
  31. package/dist/services/core/websocket/connection-service.js +3 -1
  32. package/dist/services/core/websocket/connection-service.js.map +1 -1
  33. package/dist/services/index.js +6 -0
  34. package/dist/services/index.js.map +1 -1
  35. package/dist/services/task/TaskManager.js +117 -24
  36. package/dist/services/task/TaskManager.js.map +1 -1
  37. package/dist/services/task/TaskUtils.js +16 -3
  38. package/dist/services/task/TaskUtils.js.map +1 -1
  39. package/dist/services/task/constants.js +15 -1
  40. package/dist/services/task/constants.js.map +1 -1
  41. package/dist/services/task/dialer.js +51 -0
  42. package/dist/services/task/dialer.js.map +1 -1
  43. package/dist/services/task/types.js +15 -0
  44. package/dist/services/task/types.js.map +1 -1
  45. package/dist/types/cc.d.ts +801 -0
  46. package/dist/types/config.d.ts +66 -0
  47. package/dist/types/constants.d.ts +50 -0
  48. package/dist/types/index.d.ts +184 -0
  49. package/dist/types/logger-proxy.d.ts +71 -0
  50. package/dist/types/metrics/MetricsManager.d.ts +223 -0
  51. package/dist/types/metrics/behavioral-events.d.ts +29 -0
  52. package/dist/types/metrics/constants.d.ts +161 -0
  53. package/dist/types/services/AddressBook.d.ts +74 -0
  54. package/dist/types/services/ApiAiAssistant.d.ts +31 -0
  55. package/dist/types/services/EntryPoint.d.ts +67 -0
  56. package/dist/types/services/Queue.d.ts +76 -0
  57. package/dist/types/services/WebCallingService.d.ts +1 -0
  58. package/dist/types/services/agent/index.d.ts +46 -0
  59. package/dist/types/services/agent/types.d.ts +413 -0
  60. package/dist/types/services/config/Util.d.ts +20 -0
  61. package/dist/types/services/config/constants.d.ts +249 -0
  62. package/dist/types/services/config/index.d.ts +177 -0
  63. package/dist/types/services/config/types.d.ts +1207 -0
  64. package/dist/types/services/constants.d.ts +110 -0
  65. package/dist/types/services/core/Err.d.ts +121 -0
  66. package/dist/types/services/core/GlobalTypes.d.ts +58 -0
  67. package/dist/types/services/core/Utils.d.ts +101 -0
  68. package/dist/types/services/core/WebexRequest.d.ts +22 -0
  69. package/dist/types/services/core/aqm-reqs.d.ts +65 -0
  70. package/dist/types/services/core/constants.d.ts +99 -0
  71. package/dist/types/services/core/types.d.ts +47 -0
  72. package/dist/types/services/core/websocket/WebSocketManager.d.ts +35 -0
  73. package/dist/types/services/core/websocket/connection-service.d.ts +27 -0
  74. package/dist/types/services/core/websocket/keepalive.worker.d.ts +2 -0
  75. package/dist/types/services/core/websocket/types.d.ts +37 -0
  76. package/dist/types/services/index.d.ts +54 -0
  77. package/dist/types/services/task/AutoWrapup.d.ts +40 -0
  78. package/dist/types/services/task/TaskManager.d.ts +1 -0
  79. package/dist/types/services/task/TaskUtils.d.ts +92 -0
  80. package/dist/types/services/task/constants.d.ts +84 -0
  81. package/dist/types/services/task/contact.d.ts +69 -0
  82. package/dist/types/services/task/dialer.d.ts +43 -0
  83. package/dist/types/services/task/index.d.ts +650 -0
  84. package/dist/types/services/task/types.d.ts +1319 -0
  85. package/dist/types/types.d.ts +643 -0
  86. package/dist/types/utils/PageCache.d.ts +173 -0
  87. package/dist/types/webex-config.d.ts +53 -0
  88. package/dist/types/webex.d.ts +7 -0
  89. package/dist/types.js +14 -1
  90. package/dist/types.js.map +1 -1
  91. package/dist/webex.js +1 -1
  92. package/package.json +9 -9
  93. package/src/cc.ts +157 -30
  94. package/src/constants.ts +4 -0
  95. package/src/index.ts +1 -0
  96. package/src/metrics/behavioral-events.ts +14 -0
  97. package/src/metrics/constants.ts +11 -0
  98. package/src/services/ApiAiAssistant.ts +217 -0
  99. package/src/services/agent/types.ts +1 -1
  100. package/src/services/config/Util.ts +8 -0
  101. package/src/services/config/constants.ts +12 -0
  102. package/src/services/config/index.ts +45 -1
  103. package/src/services/config/types.ts +67 -0
  104. package/src/services/constants.ts +29 -0
  105. package/src/services/core/Err.ts +1 -0
  106. package/src/services/core/Utils.ts +32 -5
  107. package/src/services/core/aqm-reqs.ts +100 -22
  108. package/src/services/core/websocket/WebSocketManager.ts +21 -6
  109. package/src/services/core/websocket/connection-service.ts +5 -1
  110. package/src/services/index.ts +4 -0
  111. package/src/services/task/TaskManager.ts +174 -27
  112. package/src/services/task/TaskUtils.ts +12 -0
  113. package/src/services/task/constants.ts +16 -0
  114. package/src/services/task/dialer.ts +56 -1
  115. package/src/services/task/types.ts +24 -0
  116. package/src/types.ts +40 -1
  117. package/test/unit/spec/cc.ts +163 -23
  118. package/test/unit/spec/services/ApiAiAssistant.ts +115 -0
  119. package/test/unit/spec/services/config/index.ts +56 -0
  120. package/test/unit/spec/services/core/Utils.ts +63 -1
  121. package/test/unit/spec/services/core/websocket/WebSocketManager.ts +82 -12
  122. package/test/unit/spec/services/core/websocket/connection-service.ts +3 -1
  123. package/test/unit/spec/services/task/TaskManager.ts +1119 -251
  124. package/test/unit/spec/services/task/dialer.ts +198 -112
  125. package/umd/contact-center.min.js +2 -2
  126. package/umd/contact-center.min.js.map +1 -1
@@ -0,0 +1,801 @@
1
+ /**
2
+ * @module CCPlugin
3
+ * @packageDocumentation
4
+ * Contact Center Plugin module that provides functionality for managing contact center agents,
5
+ * handling tasks, and interacting with contact center services. This module enables integration
6
+ * with Webex Contact Center features through the WebexSDK.
7
+ */
8
+ import { WebexPlugin } from '@webex/webex-core';
9
+ import { SetStateResponse, IContactCenter, AgentLogin, AgentProfileUpdate, StationLoginResponse, StationLogoutResponse, BuddyAgentsResponse, BuddyAgents, UploadLogsResponse, UpdateDeviceTypeResponse } from './types';
10
+ import LoggerProxy from './logger-proxy';
11
+ import { StateChange, Logout } from './services/agent/types';
12
+ import { Profile, OutdialAniEntriesResponse, OutdialAniParams } from './services/config/types';
13
+ import { TaskResponse, PreviewContactPayload } from './services/task/types';
14
+ import { AddressBook } from './services/AddressBook';
15
+ import { ApiAIAssistant } from './services/ApiAiAssistant';
16
+ import type { EntryPointListResponse, EntryPointSearchParams, ContactServiceQueuesResponse, ContactServiceQueueSearchParams } from './types';
17
+ /**
18
+ * The main Contact Center plugin class that enables integration with Webex Contact Center.
19
+ *
20
+ * @class ContactCenter
21
+ * @extends WebexPlugin
22
+ * @implements IContactCenter
23
+ * @description
24
+ * Features:
25
+ *
26
+ * 1. Session Management:
27
+ * - {@link register} - Initialize and register SDK with contact center
28
+ * - {@link deregister} - Cleanup and disconnect SDK resources
29
+ *
30
+ * 2. Agent Login/Logout:
31
+ * - {@link stationLogin} - Login with browser or desk phone
32
+ * - {@link stationLogout} - Logout from current station
33
+ * - {@link updateAgentProfile} - Update device type and settings
34
+ *
35
+ * 3. Agent State Control:
36
+ * - {@link setAgentState} - Change agent state (Available/Idle)
37
+ *
38
+ * 4. Task Management:
39
+ * - Inbound task handling via events
40
+ * - {@link startOutdial} - Make outbound calls
41
+ *
42
+ * 5. Routing & Distribution:
43
+ * - {@link getQueues} - Get available queues for routing
44
+ * - {@link getBuddyAgents} - Get available buddy agents
45
+ *
46
+ * 6. Diagnostics:
47
+ * - {@link uploadLogs} - Upload logs for troubleshooting
48
+ *
49
+ * * Key Events:
50
+ * - Agent State Events:
51
+ * - `agent:stateChange` - Agent's state has changed (Available, Idle, etc.)
52
+ * - `agent:stateChangeSuccess` - Agent state change was successful
53
+ * - `agent:stateChangeFailed` - Agent state change failed
54
+ *
55
+ * - Session Events:
56
+ * - `agent:stationLoginSuccess` - Agent login was successful
57
+ * - `agent:stationLoginFailed` - Agent login failed
58
+ * - `agent:logoutSuccess` - Agent logout was successful
59
+ * - `agent:logoutFailed` - Agent logout failed
60
+ *
61
+ * - Task Events:
62
+ * - `task:incoming` - New task is being offered
63
+ * - `task:hydrate` - Task data has been updated
64
+ * - `task:established` - Task/call has been connected
65
+ * - `task:ended` - Task/call has ended
66
+ * - `task:error` - An error occurred during task handling
67
+ * - `task:campaignPreviewReservation` - Campaign preview contact offered to agent
68
+ *
69
+ * @public
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * import Webex from 'webex';
74
+ *
75
+ * // Initialize SDK with access token
76
+ * const webex = new Webex({
77
+ * credentials: 'YOUR_ACCESS_TOKEN'
78
+ * });
79
+ *
80
+ * // Get Contact Center plugin instance
81
+ * const cc = webex.cc;
82
+ *
83
+ * // Setup event handlers
84
+ * cc.on('agent:stateChange', (event) => {
85
+ * console.log('Agent state changed:', event.state);
86
+ * });
87
+ *
88
+ * cc.on('task:incoming', (task) => {
89
+ * console.log('New task received:', task.interactionId);
90
+ * });
91
+ *
92
+ * // Initialize agent session
93
+ * async function initializeAgent() {
94
+ * try {
95
+ * // Register with contact center
96
+ * const profile = await cc.register();
97
+ *
98
+ * // Login with browser-based calling
99
+ * await cc.stationLogin({
100
+ * teamId: profile.teams[0].teamId,
101
+ * loginOption: 'BROWSER'
102
+ * });
103
+ *
104
+ * // Set agent to Available state
105
+ * await cc.setAgentState({
106
+ * state: 'Available',
107
+ * auxCodeId: '0'
108
+ * });
109
+ *
110
+ * console.log('Agent initialized and ready');
111
+ * } catch (error) {
112
+ * console.error('Initialization failed:', error);
113
+ * await cc.uploadLogs(); // Upload logs for troubleshooting
114
+ * }
115
+ * }
116
+ *
117
+ * initializeAgent();
118
+ * ```
119
+ *
120
+ * @public
121
+ */
122
+ export default class ContactCenter extends WebexPlugin implements IContactCenter {
123
+ /**
124
+ * The plugin's unique namespace identifier in the Webex SDK.
125
+ * Used to access the plugin via webex.cc
126
+ * @type {string}
127
+ * @public
128
+ */
129
+ namespace: string;
130
+ /**
131
+ * Plugin configuration settings including connection and authentication options
132
+ * @type {CCPluginConfig}
133
+ * @private
134
+ */
135
+ private $config;
136
+ /**
137
+ * Reference to the parent Webex SDK instance
138
+ * Used to access core Webex functionality and credentials
139
+ * @type {WebexSDK}
140
+ * @private
141
+ */
142
+ private $webex;
143
+ /**
144
+ * Event emitter for handling internal plugin events
145
+ * Manages event subscriptions and notifications
146
+ * @type {EventEmitter}
147
+ * @private
148
+ */
149
+ private eventEmitter;
150
+ /**
151
+ * Agent's profile and configuration data
152
+ * Includes capabilities, teams, settings, and current state
153
+ * @type {Profile}
154
+ * @private
155
+ */
156
+ private agentConfig;
157
+ /**
158
+ * Service for managing browser-based calling (WebRTC)
159
+ * Handles audio/video streaming and device management
160
+ * @type {WebCallingService}
161
+ * @private
162
+ */
163
+ private webCallingService;
164
+ /**
165
+ * Core service managers for Contact Center operations
166
+ * Includes agent, connection, and configuration services
167
+ * @type {Services}
168
+ * @private
169
+ */
170
+ private services;
171
+ /**
172
+ * Service for making authenticated HTTP requests to Webex APIs
173
+ * Handles request/response lifecycle and error handling
174
+ * @type {WebexRequest}
175
+ * @private
176
+ */
177
+ private webexRequest;
178
+ /**
179
+ * Manager for handling contact center tasks (calls, chats, etc.)
180
+ * Coordinates task lifecycle events and state
181
+ * @type {TaskManager}
182
+ * @private
183
+ */
184
+ private taskManager;
185
+ /**
186
+ * Manager for tracking and reporting SDK metrics and analytics
187
+ * Monitors performance, errors, and usage patterns
188
+ * @type {MetricsManager}
189
+ * @private
190
+ */
191
+ private metricsManager;
192
+ /**
193
+ * API instance for managing Webex Contact Center entry points
194
+ * Provides functionality to fetch entry points with caching support
195
+ * @type {EntryPoint}
196
+ * @public
197
+ * @example
198
+ * ```typescript
199
+ * const cc = webex.cc;
200
+ * await cc.register();
201
+ * await cc.stationLogin({ teamId: 'team123', loginOption: 'BROWSER' });
202
+ *
203
+ * // Access EntryPointRecord
204
+ * const response = await cc.entryPoint.getEntryPoints({
205
+ * page: 0,
206
+ * pageSize: 50
207
+ * });
208
+ * ```
209
+ */
210
+ private entryPoint;
211
+ /**
212
+ * API instance for managing Webex Contact Center address book contacts
213
+ * Provides functionality to fetch address book entries with caching support
214
+ * @type {AddressBook}
215
+ * @public
216
+ * @example
217
+ * ```typescript
218
+ * const cc = webex.cc;
219
+ * await cc.register();
220
+ * await cc.stationLogin({ teamId: 'team123', loginOption: 'BROWSER' });
221
+ *
222
+ * // Access AddressBook API
223
+ * const response = await cc.addressBook.getEntries({
224
+ * page: 0,
225
+ * pageSize: 25
226
+ * });
227
+ * ```
228
+ */
229
+ addressBook: AddressBook;
230
+ /**
231
+ * API instance for managing Webex Contact Center queues
232
+ * Provides functionality to fetch queues with caching support
233
+ * @type {Queue}
234
+ * @public
235
+ * @example
236
+ * ```typescript
237
+ * const cc = webex.cc;
238
+ * await cc.register();
239
+ * await cc.stationLogin({ teamId: 'team123', loginOption: 'BROWSER' });
240
+ *
241
+ * // Access Queue API
242
+ * const response = await cc.queue.getQueues({
243
+ * page: 0,
244
+ * pageSize: 50
245
+ * });
246
+ *
247
+ * // Filter queues by specific criteria
248
+ * const filteredQueues = await cc.queue.getQueues({
249
+ * filter: 'id=="queue-id-123"'
250
+ * });
251
+ * ```
252
+ */
253
+ private queue;
254
+ /**
255
+ * API instance for AI Assistant operations such as transcript controls.
256
+ * @type {ApiAIAssistant}
257
+ * @public
258
+ */
259
+ apiAIAssistant: ApiAIAssistant;
260
+ /**
261
+ * Logger utility for Contact Center plugin
262
+ * Provides consistent logging across the plugin
263
+ * @type {LoggerProxy}
264
+ * @public
265
+ */
266
+ LoggerProxy: typeof LoggerProxy;
267
+ /**
268
+ * @ignore
269
+ * Creates an instance of ContactCenter plugin
270
+ * @param {any[]} args Arguments passed to plugin constructor
271
+ */
272
+ constructor(...args: any[]);
273
+ /**
274
+ * Handles incoming task events and triggers appropriate notifications
275
+ * @private
276
+ * @param {ITask} task The incoming task object containing task details
277
+ */
278
+ private handleIncomingTask;
279
+ /**
280
+ * Handles task hydration events for updating task data
281
+ * @private
282
+ * @param {ITask} task The task object to be hydrated with additional data
283
+ */
284
+ private handleTaskHydrate;
285
+ /**
286
+ * Handles task merged events when tasks are combined eg: EPDN merge/transfer
287
+ * @private
288
+ * @param {ITask} task The task object that has been merged
289
+ */
290
+ private handleTaskMerged;
291
+ /**
292
+ * Handles campaign preview reservation events when a contact is offered to the agent
293
+ * @private
294
+ * @param {ITask} task The campaign reservation task
295
+ */
296
+ private handleCampaignPreviewReservation;
297
+ private handleRTDWebsocketMessage;
298
+ /**
299
+ * Sets up event listeners for incoming tasks and task hydration
300
+ * Subscribes to task events from the task manager
301
+ * @private
302
+ */
303
+ private incomingTaskListener;
304
+ /**
305
+ * Initializes the Contact Center SDK by setting up the web socket connections.
306
+ * This method must be called before performing any agent operations such as login, state change, or handling tasks.
307
+ *
308
+ * @returns {Promise<Profile>} Agent profile information after successful registration.
309
+ * The returned `Profile` object contains details such as:
310
+ * - `agentId`: The unique identifier for the agent.
311
+ * - `defaultDn`: The default dial number associated with the agent.
312
+ * - `teams`: Array of teams the agent belongs to.
313
+ * - `webRtcEnabled`: Indicates if WebRTC (browser calling) is enabled.
314
+ * - `loginVoiceOptions`: Supported login options for the agent (e.g., BROWSER, EXTENSION).
315
+ * - ...and other agent configuration details.
316
+ *
317
+ * @throws {Error} If registration fails.
318
+ *
319
+ * @public
320
+ * @example
321
+ * ```typescript
322
+ * import Webex from 'webex';
323
+ *
324
+ * const webex = Webex.init({ credentials: 'YOUR_ACCESS_TOKEN' });
325
+ * const cc = webex.cc;
326
+ *
327
+ * // Register the SDK and fetch agent profile
328
+ * const profile = await cc.register();
329
+ *
330
+ * console.log('Agent ID:', profile.agentId);
331
+ * console.log('Default DN:', profile.defaultDn);
332
+ * console.log('Teams:', profile.teams.map(t => t.teamId));
333
+ * console.log('WebRTC Enabled:', profile.webRtcEnabled);
334
+ * console.log('Supported Login Options:', profile.loginVoiceOptions);
335
+ *
336
+ * // Now you can proceed with station login, state changes, etc.
337
+ * await cc.stationLogin({ teamId: profile.teams[0].teamId, loginOption: 'BROWSER' });
338
+ * ```
339
+ */
340
+ register(): Promise<Profile>;
341
+ /**
342
+ * Unregisters the Contact Center SDK by closing all web socket connections, removing event listeners,
343
+ * and cleaning up internal state.
344
+ *
345
+ * @remarks
346
+ * This method only disconnects the SDK from the backend and cleans up resources. It does NOT perform a station logout
347
+ * (i.e., the agent remains logged in to the contact center unless you explicitly call {@link stationLogout}).
348
+ * Use this when you want to fully tear down the SDK instance, such as during application shutdown or user sign-out.
349
+ *
350
+ * @returns {Promise<void>} Resolves when deregistration and cleanup are complete.
351
+ * @throws {Error} If deregistration fails.
352
+ *
353
+ * @public
354
+ * @example
355
+ * // Typical usage: clean up SDK before application exit or user logout
356
+ * import Webex from 'webex';
357
+ *
358
+ * const webex = Webex.init({ credentials: 'YOUR_ACCESS_TOKEN' });
359
+ * const cc = webex.cc;
360
+ *
361
+ * await cc.register();
362
+ * await cc.stationLogin({ teamId: 'team123', loginOption: 'BROWSER' });
363
+ * // ... perform agent operations ...
364
+ *
365
+ * // If you want to log out the agent as well, call:
366
+ * // await cc.stationLogout({ logoutReason: 'User signed out' });
367
+ * // On application shutdown or user sign-out:
368
+ * await cc.deregister();
369
+ *
370
+
371
+ */
372
+ deregister(): Promise<void>;
373
+ /**
374
+ * Returns the list of buddy agents who are in the given user state and media type based on their agent profile settings
375
+ * @param {BuddyAgents} data The data required to fetch buddy agents
376
+ * @returns {Promise<BuddyAgentsResponse>} A promise resolving to the buddy agents information
377
+ * @throws {Error} If fetching buddy agents fails
378
+ * @example
379
+ * ```typescript
380
+ * // Get list of available agents for consultation or transfer
381
+ * const cc = webex.cc;
382
+ *
383
+ * // First ensure you're registered and logged in
384
+ * await cc.register();
385
+ * await cc.stationLogin({ teamId: 'team123', loginOption: 'BROWSER' });
386
+ *
387
+ * // Get buddy agents filtered by state and media type
388
+ * const response = await cc.getBuddyAgents({
389
+ * state: 'Available', // Filter by agent state ('Available', 'Idle', etc.)
390
+ * mediaType: 'telephony' // Filter by media type ('telephony', 'chat', 'email', 'social')
391
+ * });
392
+ *
393
+ * // Process the buddy agents list
394
+ * if (response.data.agentList.length > 0) {
395
+ * const buddyAgents = response.data.agentList;
396
+ * console.log(`Found ${buddyAgents.length} available agents`);
397
+ *
398
+ * // Access agent details
399
+ * buddyAgents.forEach(agent => {
400
+ * console.log(`Agent ID: ${agent.agentId}`);
401
+ * console.log(`Name: ${agent.firstName} ${agent.lastName}`);
402
+ * console.log(`State: ${agent.state}`);
403
+ * console.log(`Team: ${agent.teamName}`);
404
+ * });
405
+ * }
406
+ * ```
407
+ */
408
+ getBuddyAgents(data: BuddyAgents): Promise<BuddyAgentsResponse>;
409
+ /**
410
+ * Connects to the websocket and fetches the agent profile
411
+ * @returns {Promise<Profile>} Agent profile information
412
+ * @throws {Error} If connection fails or profile cannot be fetched
413
+ * @private
414
+ */
415
+ private connectWebsocket;
416
+ /**
417
+ * Performs agent login with specified credentials and device type
418
+ * @param {AgentLogin} data Login parameters including teamId, loginOption and dialNumber
419
+ * @returns {Promise<StationLoginResponse>} Response containing login status and profile
420
+ * @throws {Error} If login fails
421
+ * @public
422
+ * @example
423
+ * ```typescript
424
+ * const cc = webex.cc;
425
+ * await cc.register();
426
+ *
427
+ * // Primary usage: using Promise response
428
+ * try {
429
+ * const response = await cc.stationLogin({
430
+ * teamId: 'team123',
431
+ * loginOption: 'EXTENSION',
432
+ * dialNumber: '1002'
433
+ * });
434
+ * console.log('Login successful:', response);
435
+ * } catch (error) {
436
+ * console.error('Login failed:', error);
437
+ * }
438
+ *
439
+ * // Optional: Also listen for events elsewhere in your application
440
+ * // cc.on('agent:stationLoginSuccess', (data) => { ... });
441
+ * // cc.on('agent:stationLoginFailed', (error) => { ... });
442
+ * ```
443
+ */
444
+ stationLogin(data: AgentLogin): Promise<StationLoginResponse>;
445
+ /**
446
+ * Performs a station logout operation for the agent
447
+ * @remarks
448
+ * A logout operation cannot happen if the agent is in an interaction or haven't logged in yet.
449
+ * @param {Logout} data Logout parameters with logoutReason - a string explaining why the agent is logging out
450
+ * @returns {Promise<StationLogoutResponse>} Response indicating logout status
451
+ * @throws {Error} If logout fails
452
+ * @public
453
+ * @example
454
+ * ```typescript
455
+ * // Basic logout
456
+ * try {
457
+ * await cc.stationLogout({
458
+ * logoutReason: 'End of shift'
459
+ * });
460
+ * console.log('Logged out successfully');
461
+ * } catch (error) {
462
+ * console.error('Logout failed:', error);
463
+ * }
464
+ * ```
465
+ */
466
+ stationLogout(data: Logout): Promise<StationLogoutResponse>;
467
+ /**
468
+ * Gets the device ID based on login option and dial number
469
+ * @param {string} loginOption The login option (BROWSER, EXTENSION, etc)
470
+ * @param {string} dialNumber The dial number if applicable
471
+ * @returns {string} The device ID
472
+ * @private
473
+ */
474
+ private getDeviceId;
475
+ /**
476
+ * Sets the state of the agent to Available or any of the Idle states.
477
+ * After a state change attempt, one of the following events will be emitted:
478
+ * - agent:stateChange: Emitted when agent's state changes (triggered for both local and remote changes)
479
+ * - agent:stateChangeSuccess: Emitted when agent state change is successful
480
+ * - agent:stateChangeFailed: Emitted when agent state change attempt fails
481
+ *
482
+ * @param {StateChange} data State change parameters including the new state
483
+ * @returns {Promise<SetStateResponse>} Response with updated state information
484
+ * @throws {Error} If state change fails
485
+ * @public
486
+ * @example
487
+ * ```typescript
488
+ * const cc = webex.cc;
489
+ * await cc.register();
490
+ * await cc.stationLogin({ teamId: 'team123', loginOption: 'BROWSER' });
491
+ *
492
+ * // Using promise-based approach
493
+ * try {
494
+ * await cc.setAgentState({
495
+ * state: 'Available',
496
+ * auxCodeId: '12345',
497
+ * lastStateChangeReason: 'Manual state change',
498
+ * agentId: 'agent123',
499
+ * });
500
+ * } catch (error) {
501
+ * console.error('State change failed:', error);
502
+ * }
503
+ *
504
+ * // Optionally, listen for events
505
+ * cc.on('agent:stateChange', (eventData) => {
506
+ * // Triggered for both local and remote state changes
507
+ * console.log('State changed:', eventData);
508
+ * });
509
+ *
510
+ * cc.on('agent:stateChangeSuccess', (eventData) => {
511
+ * console.log('State change succeeded:', eventData);
512
+ * });
513
+ *
514
+ * cc.on('agent:stateChangeFailed', (error) => {
515
+ * console.error('State change failed:', error);
516
+ * });
517
+ * ```
518
+ */
519
+ setAgentState(data: StateChange): Promise<SetStateResponse>;
520
+ /**
521
+ * Processes incoming websocket messages and emits corresponding events
522
+ * Handles various event types including agent state changes, login events,
523
+ * and other agent-related notifications
524
+ * @private
525
+ * @param {string} event The raw websocket event message
526
+ */
527
+ private handleWebsocketMessage;
528
+ /**
529
+ * Initializes event listeners for the Contact Center service
530
+ * Sets up handlers for connection state changes and other core events
531
+ * @private
532
+ */
533
+ private setupEventListeners;
534
+ /**
535
+ * Returns the connection configuration
536
+ * @returns {SubscribeRequest} Connection configuration
537
+ * @private
538
+ */
539
+ private getConnectionConfig;
540
+ /**
541
+ * Handles connection lost events and reconnection attempts
542
+ * @param {ConnectionLostDetails} msg Connection lost details
543
+ * @private
544
+ */
545
+ private handleConnectionLost;
546
+ /**
547
+ * Handles silent relogin after registration completion
548
+ * @private
549
+ */
550
+ private silentRelogin;
551
+ /**
552
+ * Handles device type specific configuration and setup
553
+ * Configures services and settings based on the login device type
554
+ * @param {LoginOption} deviceType The type of device being used for login
555
+ * @param {string} dn The dial number associated with the device
556
+ * @returns {Promise<void>}
557
+ * @private
558
+ */
559
+ private handleDeviceType;
560
+ /**
561
+ * Makes an outbound call to a specified phone number.
562
+ *
563
+ * @param {string} destination - The phone number to dial (e.g., '+1234567890').
564
+ * @param {string} origin - The contact center number that will be used while making a call to the customer.
565
+ * Should include country code and be in E.164 format.
566
+ * @returns {Promise<TaskResponse>} Resolves with the task response containing:
567
+ * - interactionId: Unique identifier for the outbound call
568
+ * - taskId: Identifier for the task instance
569
+ * - data: Task details including state, queue info, and media properties
570
+ * @throws {Error} If the outdial operation fails:
571
+ * - "Agent not configured for outbound calls" if isOutboundEnabledForAgent is false
572
+ * - "Invalid phone number format" if destination is not in E.164 format
573
+ * - "Agent not in Available state" if agent's state is not Available
574
+ * @public
575
+ * @example
576
+ * ```typescript
577
+ * // Initialize and prepare agent
578
+ * const cc = webex.cc;
579
+ * await cc.register();
580
+ * await cc.stationLogin({
581
+ * teamId: 'team123',
582
+ * loginOption: 'BROWSER'
583
+ * });
584
+ *
585
+ * // Set Available state before outbound call
586
+ * await cc.setAgentState({
587
+ * state: 'Available',
588
+ * auxCodeId: '0'
589
+ * });
590
+ *
591
+ * // Make outbound call with full error handling
592
+ * try {
593
+ * // Verify agent is properly configured for outdial
594
+ * if (!cc.agentConfig.isOutboundEnabledForAgent) {
595
+ * throw new Error('Agent not configured for outbound calls');
596
+ * }
597
+ *
598
+ * // Start the outbound call
599
+ * const destination = '+1234567890';
600
+ * const task = await cc.startOutdial(destination, origin);
601
+ *
602
+ * // Listen for all relevant task events
603
+ * task.on('task:ringing', () => {
604
+ * console.log('Call is ringing');
605
+ * updateCallStatus('Ringing...');
606
+ * });
607
+ *
608
+ * task.on('task:established', () => {
609
+ * console.log('Call connected');
610
+ * updateCallStatus('Connected');
611
+ * enableCallControls(); // Show mute, hold, transfer buttons
612
+ * });
613
+ *
614
+ * task.on('task:hold', () => {
615
+ * console.log('Call placed on hold');
616
+ * updateCallStatus('On Hold');
617
+ * });
618
+ *
619
+ * task.on('task:error', (error) => {
620
+ * console.error('Call error:', error);
621
+ * updateCallStatus('Error');
622
+ * showErrorDialog(error.message);
623
+ * });
624
+ *
625
+ * task.on('task:ended', () => {
626
+ * console.log('Call ended');
627
+ * updateCallStatus('Call Ended');
628
+ * resetCallControls();
629
+ *
630
+ * // Handle wrap-up if required
631
+ * if (task.data.wrapUpRequired) {
632
+ * showWrapupForm();
633
+ * }
634
+ * });
635
+ *
636
+ * // Example call control usage
637
+ * function handleMuteToggle() {
638
+ * await task.toggleMute();
639
+ * }
640
+ *
641
+ * function handleHoldToggle() {
642
+ * if (task.data.isOnHold) {
643
+ * await task.resume();
644
+ * } else {
645
+ * await task.hold();
646
+ * }
647
+ * }
648
+ *
649
+ * async function handleTransfer() {
650
+ * // Get available queues for transfer
651
+ * const queues = await cc.getQueues();
652
+ *
653
+ * // Transfer to first available queue
654
+ * if (queues.length > 0) {
655
+ * await task.transfer({
656
+ * to: queues[0].queueId,
657
+ * destinationType: 'QUEUE'
658
+ * });
659
+ * }
660
+ * }
661
+ *
662
+ * } catch (error) {
663
+ * console.error('Outdial failed:', error);
664
+ * showErrorNotification('Failed to place call: ' + error.message);
665
+ * }
666
+ * ```
667
+ */
668
+ startOutdial(destination: string, origin: string): Promise<TaskResponse>;
669
+ /**
670
+ * Accepts a campaign preview contact, initiating the outbound call.
671
+ *
672
+ * When a campaign manager reserves a contact for an agent, the agent receives an
673
+ * `AgentOfferCampaignReservation` event. The agent can then accept the preview contact
674
+ * to initiate the outbound call.
675
+ *
676
+ * @param {PreviewContactPayload} payload - The preview contact payload containing interactionId and campaignId (campaign name, not UUID).
677
+ * @returns {Promise<TaskResponse>} Promise resolving with agent contact on success.
678
+ * @throws {Error} If the operation fails (network error, customer unavailable, etc.)
679
+ *
680
+ * @example
681
+ * ```typescript
682
+ * webex.cc.on('task:campaignPreviewReservation', async (task) => {
683
+ * const { interactionId } = task.data;
684
+ * // campaignId is the campaign name (e.g. "MyCampaign"), not a UUID
685
+ * const campaignId = task.data.interaction.callProcessingDetails.campaignId;
686
+ *
687
+ * const result = await webex.cc.acceptPreviewContact({ interactionId, campaignId });
688
+ * });
689
+ * ```
690
+ */
691
+ acceptPreviewContact(payload: PreviewContactPayload): Promise<TaskResponse>;
692
+ /**
693
+ * Fetches outdial ANI (Automatic Number Identification) entries for an outdial ANI ID.
694
+ *
695
+ * This method retrieves the list of phone numbers that can be used as caller ID when making
696
+ * outbound calls. The ANI data is associated with an outdial ANI ID and can be filtered
697
+ * and paginated as needed.
698
+ *
699
+ * @param {string} outdialANI - The outdial ANI ID to fetch ANI data for
700
+ * @param {number} [page] - Optional page number for pagination (0-based)
701
+ * @param {number} [pageSize] - Optional number of items per page
702
+ * @param {string} [search] - Optional search term to filter results by name or number
703
+ * @param {string} [filter] - Optional filter string
704
+ * @param {string} [attributes] - Optional attributes to include in response
705
+ * @returns {Promise<OutdialAniEntriesResponse>} Promise resolving to outdial ANI response containing:
706
+ * - data: Array of ANI entries with number and name
707
+ * - meta: Pagination metadata
708
+ * @throws {Error} If the operation fails or agent is not registered
709
+ * @public
710
+ * @example
711
+ * ```typescript
712
+ * const cc = webex.cc;
713
+ * await cc.register();
714
+ *
715
+ * // Get agent profile to obtain outdial ANI ID
716
+ * const agentProfile = cc.agentConfig;
717
+ * const outdialANI = agentProfile.outdialANIId;
718
+ *
719
+ * // Basic usage - get all ANI data for an outdial ANI ID
720
+ * const aniData = await cc.getOutdialAniEntries({ outdialANI });
721
+ *
722
+ * // With pagination and search
723
+ * const paginatedAni = await cc.getOutdialAniEntries({
724
+ * outdialANI,
725
+ * page: 0,
726
+ * pageSize: 50,
727
+ * search: '555' // search for numbers containing '555'
728
+ * });
729
+ *
730
+ * // Process the results
731
+ * paginatedAni.forEach(ani => {
732
+ * console.log(`ANI: ${ani.number} - ${ani.name}`);
733
+ * });
734
+ * ```
735
+ */
736
+ getOutdialAniEntries(params: OutdialAniParams): Promise<OutdialAniEntriesResponse>;
737
+ /**
738
+ * Uploads logs to help troubleshoot SDK issues.
739
+ *
740
+ * This method collects the current SDK logs including network requests, WebSocket
741
+ * messages, and client-side events, then securely submits them to Webex's diagnostics
742
+ * service. The returned tracking ID, feedbackID can be provided to Webex support for faster
743
+ * issue resolution.
744
+ * @returns Promise<UploadLogsResponse> Resolves with the upload logs response
745
+ * @throws Error If the upload fails
746
+ * @public
747
+ * @example
748
+ * ```typescript
749
+ * const cc = webex.cc;
750
+ * try {
751
+ * await cc.register();
752
+ * } catch (error) {
753
+ * console.error('Error:', error);
754
+ * const result = await cc.uploadLogs();
755
+ * console.log('Logs uploaded. Tracking ID:', result.trackingId);
756
+ * }
757
+ * ```
758
+ */
759
+ uploadLogs(): Promise<UploadLogsResponse>;
760
+ /**
761
+ * Updates the agent device type and login configuration.
762
+ * Use this method to change how an agent connects to the contact center system (e.g., switching from browser-based calling to a desk phone extension).
763
+ * Change to any field of the profile is allowed;
764
+ *
765
+ * @param {AgentDeviceUpdate} data Configuration containing:
766
+ * - loginOption: New device type ('BROWSER', 'EXTENSION', 'AGENT_DN')
767
+ * - dialNumber: Required phone number when using EXTENSION or AGENT_DN
768
+ * - teamId: Optional team ID (defaults to current team if not specified)
769
+ * @returns Promise<UpdateDeviceTypeResponse> Resolves with the device type update response
770
+ * @throws Error If the update fails
771
+ * @example
772
+ * ```typescript
773
+ * const cc = webex.cc;
774
+ *
775
+ * // Switch from browser to extension
776
+ * try {
777
+ * await cc.updateAgentProfile({
778
+ * loginOption: 'EXTENSION',
779
+ * dialNumber: '1234', // Required for EXTENSION
780
+ * teamId: 'currentTeam' // Optional: uses current team if not specified
781
+ * });
782
+ * } catch (error) {
783
+ * console.error('Failed to update device:', error.message);
784
+ * }
785
+ * ```
786
+ * @public
787
+ */
788
+ updateAgentProfile(data: AgentProfileUpdate): Promise<UpdateDeviceTypeResponse>;
789
+ /**
790
+ * Returns paginated entry points for the organization.
791
+ * Thin wrapper around internal EntryPoint instance.
792
+ * @public
793
+ */
794
+ getEntryPoints(params?: EntryPointSearchParams): Promise<EntryPointListResponse>;
795
+ /**
796
+ * Returns paginated contact service queues for the organization.
797
+ * Thin wrapper around internal Queue instance.
798
+ * @public
799
+ */
800
+ getQueues(params?: ContactServiceQueueSearchParams): Promise<ContactServiceQueuesResponse>;
801
+ }