Logger utility for Contact Center plugin Provides consistent logging across the plugin
The plugin's unique namespace identifier in the Webex SDK. Used to access the plugin via webex.cc
Private
$configPlugin configuration settings including connection and authentication options
Private
$webexReference to the parent Webex SDK instance Used to access core Webex functionality and credentials
Private
agentAgent's profile and configuration data Includes capabilities, teams, settings, and current state
Private
eventEvent emitter for handling internal plugin events Manages event subscriptions and notifications
Private
metricsManager for tracking and reporting SDK metrics and analytics Monitors performance, errors, and usage patterns
Private
servicesCore service managers for Contact Center operations Includes agent, connection, and configuration services
Private
taskManager for handling contact center tasks (calls, chats, etc.) Coordinates task lifecycle events and state
Private
webService for managing browser-based calling (WebRTC) Handles audio/video streaming and device management
Private
webexService for making authenticated HTTP requests to Webex APIs Handles request/response lifecycle and error handling
Unregisters the Contact Center SDK by closing all web socket connections, removing event listeners, and cleaning up internal state.
Resolves when deregistration and cleanup are complete.
This method only disconnects the SDK from the backend and cleans up resources. It does NOT perform a station logout (i.e., the agent remains logged in to the contact center unless you explicitly call stationLogout). Use this when you want to fully tear down the SDK instance, such as during application shutdown or user sign-out.
If deregistration fails.
// Typical usage: clean up SDK before application exit or user logout
import Webex from 'webex';
const webex = Webex.init({ credentials: 'YOUR_ACCESS_TOKEN' });
const cc = webex.cc;
await cc.register();
await cc.stationLogin({ teamId: 'team123', loginOption: 'BROWSER' });
// ... perform agent operations ...
// If you want to log out the agent as well, call:
// await cc.stationLogout({ logoutReason: 'User signed out' });
// On application shutdown or user sign-out:
await cc.deregister();
Returns the list of buddy agents who are in the given user state and media type based on their agent profile settings
The data required to fetch buddy agents
A promise resolving to the buddy agents information
If fetching buddy agents fails
// Get list of available agents for consultation or transfer
const cc = webex.cc;
// First ensure you're registered and logged in
await cc.register();
await cc.stationLogin({ teamId: 'team123', loginOption: 'BROWSER' });
// Get buddy agents filtered by state and media type
const response = await cc.getBuddyAgents({
state: 'Available', // Filter by agent state ('Available', 'Idle', etc.)
mediaType: 'telephony' // Filter by media type ('telephony', 'chat', 'email', 'social')
});
// Process the buddy agents list
if (response.data.agentList.length > 0) {
const buddyAgents = response.data.agentList;
console.log(`Found ${buddyAgents.length} available agents`);
// Access agent details
buddyAgents.forEach(agent => {
console.log(`Agent ID: ${agent.agentId}`);
console.log(`Name: ${agent.firstName} ${agent.lastName}`);
console.log(`State: ${agent.state}`);
console.log(`Team: ${agent.teamName}`);
});
}
This is used for getting the list of queues to which a task can be consulted or transferred.
Optional
search: stringOptional search string to filter queues by name
Optional
filter: stringOptional OData filter expression (e.g., 'teamId eq "team123"')
Optional
page: number = DEFAULT_PAGEPage number for paginated results, starting at 0
Optional
pageSize: number = DEFAULT_PAGE_SIZENumber of queues to return per page
Promise<ContactServiceQueue[]> Resolves with the list of queues
Error If the operation fails
const cc = webex.cc;
await cc.register();
await cc.stationLogin({ teamId: 'team123', loginOption: 'BROWSER' });
// Basic usage - get all queues
const allQueues = await cc.getQueues();
// Search for specific queues
const salesQueues = await cc.getQueues('sales'); // Search for 'sales' in queue names
// Use filtering and pagination
const filteredQueues = await cc.getQueues(
'', // No search term
'teamId eq "team123"', // Filter by team
0, // First page
50 // 50 items per page
);
// Process queue results
queues.forEach(queue => {
console.log('Queue:', {
id: queue.queueId,
name: queue.queueName,
channelType: queue.channelType,
isActive: queue.isActive,
description: queue.description
});
});
Initializes the Contact Center SDK by setting up the web socket connections. This method must be called before performing any agent operations such as login, state change, or handling tasks.
Agent profile information after successful registration.
The returned Profile
object contains details such as:
agentId
: The unique identifier for the agent.defaultDn
: The default dial number associated with the agent.teams
: Array of teams the agent belongs to.webRtcEnabled
: Indicates if WebRTC (browser calling) is enabled.loginVoiceOptions
: Supported login options for the agent (e.g., BROWSER, EXTENSION).If registration fails.
import Webex from 'webex';
const webex = Webex.init({ credentials: 'YOUR_ACCESS_TOKEN' });
const cc = webex.cc;
// Register the SDK and fetch agent profile
const profile = await cc.register();
console.log('Agent ID:', profile.agentId);
console.log('Default DN:', profile.defaultDn);
console.log('Teams:', profile.teams.map(t => t.teamId));
console.log('WebRTC Enabled:', profile.webRtcEnabled);
console.log('Supported Login Options:', profile.loginVoiceOptions);
// Now you can proceed with station login, state changes, etc.
await cc.stationLogin({ teamId: profile.teams[0].teamId, loginOption: 'BROWSER' });
Sets the state of the agent to Available or any of the Idle states. After a state change attempt, one of the following events will be emitted:
State change parameters including the new state
Response with updated state information
If state change fails
const cc = webex.cc;
await cc.register();
await cc.stationLogin({ teamId: 'team123', loginOption: 'BROWSER' });
// Using promise-based approach
try {
await cc.setAgentState({
state: 'Available',
auxCodeId: '12345',
lastStateChangeReason: 'Manual state change',
agentId: 'agent123',
});
} catch (error) {
console.error('State change failed:', error);
}
// Optionally, listen for events
cc.on('agent:stateChange', (eventData) => {
// Triggered for both local and remote state changes
console.log('State changed:', eventData);
});
cc.on('agent:stateChangeSuccess', (eventData) => {
console.log('State change succeeded:', eventData);
});
cc.on('agent:stateChangeFailed', (error) => {
console.error('State change failed:', error);
});
Makes an outbound call to a specified phone number.
The phone number to dial (e.g., '+1234567890'). Should include country code and be in E.164 format.
Resolves with the task response containing:
If the outdial operation fails:
// Initialize and prepare agent
const cc = webex.cc;
await cc.register();
await cc.stationLogin({
teamId: 'team123',
loginOption: 'BROWSER'
});
// Set Available state before outbound call
await cc.setAgentState({
state: 'Available',
auxCodeId: '0'
});
// Make outbound call with full error handling
try {
// Verify agent is properly configured for outdial
if (!cc.agentConfig.isOutboundEnabledForAgent) {
throw new Error('Agent not configured for outbound calls');
}
// Start the outbound call
const destination = '+1234567890';
const task = await cc.startOutdial(destination);
// Listen for all relevant task events
task.on('task:ringing', () => {
console.log('Call is ringing');
updateCallStatus('Ringing...');
});
task.on('task:established', () => {
console.log('Call connected');
updateCallStatus('Connected');
enableCallControls(); // Show mute, hold, transfer buttons
});
task.on('task:hold', () => {
console.log('Call placed on hold');
updateCallStatus('On Hold');
});
task.on('task:error', (error) => {
console.error('Call error:', error);
updateCallStatus('Error');
showErrorDialog(error.message);
});
task.on('task:ended', () => {
console.log('Call ended');
updateCallStatus('Call Ended');
resetCallControls();
// Handle wrap-up if required
if (task.data.wrapUpRequired) {
showWrapupForm();
}
});
// Example call control usage
function handleMuteToggle() {
await task.toggleMute();
}
function handleHoldToggle() {
if (task.data.isOnHold) {
await task.resume();
} else {
await task.hold();
}
}
async function handleTransfer() {
// Get available queues for transfer
const queues = await cc.getQueues();
// Transfer to first available queue
if (queues.length > 0) {
await task.transfer({
to: queues[0].queueId,
destinationType: 'QUEUE'
});
}
}
} catch (error) {
console.error('Outdial failed:', error);
showErrorNotification('Failed to place call: ' + error.message);
}
Performs agent login with specified credentials and device type
Login parameters including teamId, loginOption and dialNumber
Response containing login status and profile
If login fails
const cc = webex.cc;
await cc.register();
// Primary usage: using Promise response
try {
const response = await cc.stationLogin({
teamId: 'team123',
loginOption: 'EXTENSION',
dialNumber: '1002'
});
console.log('Login successful:', response);
} catch (error) {
console.error('Login failed:', error);
}
// Optional: Also listen for events elsewhere in your application
// cc.on('agent:stationLoginSuccess', (data) => { ... });
// cc.on('agent:stationLoginFailed', (error) => { ... });
Performs a station logout operation for the agent
Logout parameters with logoutReason - a string explaining why the agent is logging out
Response indicating logout status
A logout operation cannot happen if the agent is in an interaction or haven't logged in yet.
If logout fails
// Basic logout
try {
await cc.stationLogout({
logoutReason: 'End of shift'
});
console.log('Logged out successfully');
} catch (error) {
console.error('Logout failed:', error);
}
Updates the agent device type and login configuration. 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).
Configuration containing:
Promise
Error If the update fails
const cc = webex.cc;
// Switch from browser to extension
try {
await cc.updateAgentProfile({
loginOption: 'EXTENSION',
dialNumber: '1234', // Required for EXTENSION
teamId: 'currentTeam' // Optional: uses current team if not specified
});
} catch (error) {
console.error('Failed to update device:', error.message);
}
Uploads logs to help troubleshoot SDK issues.
This method collects the current SDK logs including network requests, WebSocket messages, and client-side events, then securely submits them to Webex's diagnostics service. The returned tracking ID, feedbackID can be provided to Webex support for faster issue resolution.
Promise
Error If the upload fails
const cc = webex.cc;
try {
await cc.register();
} catch (error) {
console.error('Error:', error);
const result = await cc.uploadLogs();
console.log('Logs uploaded. Tracking ID:', result.trackingId);
}
Private
connectPrivate
getPrivate
getPrivate
handlePrivate
handlePrivate
Handles device type specific configuration and setup Configures services and settings based on the login device type
The type of device being used for login
The dial number associated with the device
Private
handlePrivate
Handles incoming task events and triggers appropriate notifications
The incoming task object containing task details
Private
handlePrivate
Handles task hydration events for updating task data
The task object to be hydrated with additional data
Private
handlePrivate
incomingPrivate
setupPrivate
silent
The main Contact Center plugin class that enables integration with Webex Contact Center.
ContactCenter
Implements
IContactCenter
Description
Features:
Agent State Events:
agent:stateChange
- Agent's state has changed (Available, Idle, etc.)agent:stateChangeSuccess
- Agent state change was successfulagent:stateChangeFailed
- Agent state change failedSession Events:
agent:stationLoginSuccess
- Agent login was successfulagent:stationLoginFailed
- Agent login failedagent:logoutSuccess
- Agent logout was successfulagent:logoutFailed
- Agent logout failedTask Events:
task:incoming
- New task is being offeredtask:hydrate
- Task data has been updatedtask:established
- Task/call has been connectedtask:ended
- Task/call has endedtask:error
- An error occurred during task handlingExample