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