Element API
@avaya/infinity-elements-api v1.0.0
ElementAPI
ElementAPI - Main API for web components to interact with the Infinity Extensibility Framework
This is the primary interface that elements use to communicate with core-agent-ui.
Uses window.postMessage for API requests/responses and events, with BroadcastChannel
for inter-element communication.
The methods are organized into four API families:
-
Interaction API Family - Controls and monitors customer interactions throughout their lifecycle. Initiate new voice and chat interactions, execute controls (transfer, consult, conference), and subscribe to interaction events.
-
Media API Family - Manages channel-specific capabilities including DTMF tones on voice channels and rich text messages with formatting and attachments.
-
Agent API Family - Manages agent presence and availability. Modify agent state and subscribe to state change notifications.
-
Admin API Family - Provides environmental and configuration data including logged-in agent context, users, queues, and reason codes.
Examples
import { ElementAPI } from '@avaya/infinity-elements-api';
const api = new ElementAPI({
elementId: 'my-element',
timeout: 5000,
debug: true
});
const userInfo = await api.getUserInfo();
console.log('Agent name:', userInfo.displayName);
console.log('Agent status:', userInfo.agentStatus);
api.onInteractionAccepted((interactionId) => {
console.log('Interaction accepted:', interactionId);
});
api.onInteractionEnded((interactionId) => {
console.log('Interaction ended:', interactionId);
});
Constructors
Constructor
new ElementAPI(options: ElementAPIOptions): ElementAPI;
Creates a new ElementAPI instance
Parameters
| Parameter | Type |
|---|---|
options | ElementAPIOptions |
Returns
Example
const api = new ElementAPI({
elementId: 'my-custom-element',
timeout: 10000,
debug: true
});
Interaction API Family
getInteraction()
getInteraction(): Promise<InteractionInfo>;
Get information about the current active interaction
Returns
Promise<InteractionInfo>
Promise resolving to the interaction information
Throws
Error if no active interaction exists
Example
try {
const interaction = await api.getInteraction();
console.log('Interaction ID:', interaction.interactionId);
console.log('Customer:', interaction.customer?.name);
console.log('Status:', interaction.status);
} catch (error) {
console.error('No active interaction');
}
getUserInteractions()
getUserInteractions(params?: GetUserInteractionsParams): Promise<GetUserInteractionsResponse>;
Get user interactions including owned and viewing interactions
Retrieves all active interactions for the current or specified user,
including interactions they own and ones they are viewing.
Optionally includes queue and user details.
Parameters
| Parameter | Type | Description |
|---|---|---|
params? | GetUserInteractionsParams | Optional parameters |
Returns
Promise<GetUserInteractionsResponse>
Promise resolving to user interactions data
Examples
// Get current user's interactions with full details
const result = await api.getUserInteractions({ details: true });
console.log('Owned interactions:', result.interactions);
console.log('Viewing interactions:', result.viewing);
console.log('Logged in queues:', result.queue.loggedIn);
// Get interactions without queue/user details for better performance
const result = await api.getUserInteractions({ details: false });
const totalCount = result.interactions.length + result.viewing.length;
console.log('Total active interactions:', totalCount);
viewerRemoveInteraction()
viewerRemoveInteraction(): Promise<{
message: string;
}>;
Remove the current interaction from the viewer
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Example
await api.viewerRemoveInteraction();
endInteraction()
endInteraction(): Promise<{
message: string;
}>;
End the current interaction
Terminates the active interaction and disconnects the call.
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Example
await api.endInteraction();
console.log('Interaction ended');
startVoiceCall()
startVoiceCall(): Promise<{
message: string;
}>;
Start a voice call for the current interaction
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Example
await api.startVoiceCall();
createVoiceInteraction()
createVoiceInteraction(params: CreateVoiceInteractionParams): Promise<{
message: string;
}>;
Create a new voice interaction with a Queue ID and Phone Number
Creates a new outbound voice call interaction to the specified phone number
and assigns it to the specified queue.
Parameters
| Parameter | Type | Description |
|---|---|---|
params | CreateVoiceInteractionParams | Voice interaction parameters |
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Example
await api.createVoiceInteraction({
phoneNumber: '+1234567890',
queueId: '003'
});
completeBlindTransfer()
completeBlindTransfer(options: BlindTransferOptions): Promise<boolean>;
Complete a blind transfer
Transfers the call to another agent or number without consultation.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | BlindTransferOptions | Transfer configuration |
Returns
Promise<boolean>
Promise resolving to true if successful
Example
const interaction = await api.getInteraction();
await api.completeBlindTransfer({
interactionId: interaction.interactionId,
transferTo: '[email protected]',
transferToName: 'John Doe',
transferCallerIdType: 'internal'
});
singleStepTransfer()
singleStepTransfer(params: SingleStepTransferParams): Promise<{
message: string;
}>;
Perform a single-step transfer
Transfers the interaction directly to the specified target.
Parameters
| Parameter | Type | Description |
|---|---|---|
params | SingleStepTransferParams | Transfer parameters |
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Example
await api.singleStepTransfer({
targetId: 'user123',
targetName: 'Support Team'
});
consultCall()
consultCall(options: ConsultCallOptions): Promise<{
message: string;
}>;
Initiate a consult call
Starts a consultation with another agent, phone number, or queue while keeping
the original caller on hold.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | ConsultCallOptions | Consult call configuration |
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Examples
const interaction = await api.getInteraction();
await api.consultCall({
interactionId: interaction.interactionId,
transferTo: '[email protected]'
});
await api.consultCall({
interactionId: interaction.interactionId,
phoneNumber: '+1234567890'
});
// Get available queues first
const queues = await api.getTransferQueuesInteraction();
const targetQueue = queues.find(q => q.name === 'Support Queue');
await api.consultCall({
interactionId: interaction.interactionId,
queueId: targetQueue.id
});
completeAttendedTransfer()
completeAttendedTransfer(): Promise<{
message: string;
}>;
Complete an attended transfer
Finalizes the attended transfer after consulting with the target party.
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Example
// After consulting
await api.completeAttendedTransfer();
attendedTransferWarm()
attendedTransferWarm(): Promise<{
message: string;
}>;
Perform a warm attended transfer
Introduces the caller to the transfer target before completing the transfer.
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Example
await api.attendedTransferWarm();
attendedTransferCancel()
attendedTransferCancel(): Promise<{
message: string;
}>;
Cancel an attended transfer
Cancels the ongoing attended transfer and returns to the original call.
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Example
await api.attendedTransferCancel();
acceptInteraction()
acceptInteraction(): Promise<{
message: string;
}>;
Accept an incoming interaction
Accepts a queued or alerting interaction.
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Example
api.onInteractionAccepted(async (interactionId) => {
console.log('New interaction:', interactionId);
});
// When ready to accept
await api.acceptInteraction();
onInteractionStatusChanged()
onInteractionStatusChanged(callback: InteractionStatusChangedCallback): () => void;
Subscribe to interaction status changes
Fires when the status of an interaction changes (e.g., alerting, connected, held)
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | InteractionStatusChangedCallback | Function to call when interaction status changes |
Returns
Unsubscribe function
(): void;
Returns
void
Example
const unsubscribe = api.onInteractionStatusChanged(({ interactionId, status }) => {
console.log(`Interaction ${interactionId} status changed to ${status}`);
});
// Later, to unsubscribe:
unsubscribe();
onInteractionAccepted()
onInteractionAccepted(callback: InteractionAcceptedCallback): () => void;
Subscribe to interaction accepted events
Fires when an agent accepts an incoming interaction
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | InteractionAcceptedCallback | Function to call when an interaction is accepted |
Returns
Unsubscribe function
(): void;
Returns
void
Example
api.onInteractionAccepted((interactionId) => {
console.log('Accepted interaction:', interactionId);
// Load customer data, show interaction UI, etc.
});
onInteractionEnded()
onInteractionEnded(callback: InteractionEndedCallback): () => void;
Subscribe to interaction ended events
Fires when an interaction is ended or disconnected
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | InteractionEndedCallback | Function to call when an interaction ends |
Returns
Unsubscribe function
(): void;
Returns
void
Example
api.onInteractionEnded((interactionId) => {
console.log('Interaction ended:', interactionId);
// Clean up UI, save data, etc.
});
onInteractionUpdated()
onInteractionUpdated(callback: InteractionUpdatedCallback): () => void;
Subscribe to interaction updated events
Fires when an interaction is updated with new information
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | InteractionUpdatedCallback | Function to call when an interaction is updated |
Returns
Unsubscribe function
(): void;
Returns
void
Example
api.onInteractionUpdated(({ interactionId, payload }) => {
console.log('Interaction updated:', interactionId);
console.log('New data:', payload);
});
onConsultStatusChanged()
onConsultStatusChanged(callback: ConsultStatusChangedCallback): () => void;
Subscribe to consult status changes
Fires when the status of a consultation changes
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | ConsultStatusChangedCallback | Function to call when consult status changes |
Returns
Unsubscribe function
(): void;
Returns
void
Example
api.onConsultStatusChanged(({ interactionId, consultStatus, consultParty }) => {
console.log(`Consult ${consultStatus} with ${consultParty}`);
});
Media API Family
sendDialpadDigit()
sendDialpadDigit(
digit: DialpadDigit,
audioOutputDeviceId: string | null,
noSendDialTone: boolean,
audioContextOverride?: "none" | "standard" | "webkit"): Promise<{
message: string;
}>;
Send a DTMF dialpad digit during a call
Parameters
| Parameter | Type | Description |
|---|---|---|
digit | DialpadDigit | The dialpad digit to send (0-9) |
audioOutputDeviceId | string | null | Audio output device ID or null for default |
noSendDialTone | boolean | Whether to suppress the dial tone sound |
audioContextOverride? | "none" | "standard" | "webkit" | Audio context type override |
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Example
import { DialpadDigit } from '@avaya/infinity-elements-api';
await api.sendDialpadDigit(
DialpadDigit.One,
null,
false
);
insertTextIntoFeedInput()
insertTextIntoFeedInput(text: string): Promise<{
message: string;
}>;
Insert text into the chat feed input field
Parameters
| Parameter | Type | Description |
|---|---|---|
text | string | The text to insert |
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Example
await api.insertTextIntoFeedInput('Hello, how can I help you today?');
sendRichMediaMessage()
sendRichMediaMessage(options: SendRichMediaMessageOptions): Promise<{
message: string;
}>;
Send a rich media message (image, file, etc.) to the interaction
Parameters
| Parameter | Type | Description |
|---|---|---|
options | SendRichMediaMessageOptions | Message options (must provide either mediaUrl or file) |
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Deprecated
This method is deprecated and will be removed in a future version.
Examples
await api.sendRichMediaMessage({
name: 'Product Image',
mediaUrl: 'https://example.com/image.jpg',
text: 'Here is the product you requested'
});
const fileInput = document.querySelector('input[type="file"]');
const file = fileInput.files[0];
await api.sendRichMediaMessage({
name: 'Document',
file: file,
text: 'Attached document'
});
sendChatMessage()
sendChatMessage(options: SendChatMessageOptions): Promise<{
message: string;
}>;
Send a chat message to the interaction
Supports sending text messages, media from URLs, or file uploads.
At least one of text, mediaUrl, or file must be provided.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | SendChatMessageOptions | Message options (must provide interactionId and at least one of text, mediaUrl, or file) |
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Examples
await api.sendChatMessage({
interactionId: 'int-123',
text: 'Hello, how can I help you today?'
});
await api.sendChatMessage({
interactionId: 'int-123',
mediaUrl: 'https://example.com/image.jpg',
text: 'Here is the product you requested'
});
const fileInput = document.querySelector('input[type="file"]');
const file = fileInput.files[0];
await api.sendChatMessage({
interactionId: 'int-123',
file: file,
text: 'Attached document'
});
await api.sendChatMessage({
interactionId: 'int-123',
text: 'Please review this document',
file: documentFile,
fileName: 'Important Document.pdf'
});
onReceivedFeedMessage()
onReceivedFeedMessage(callback: FeedMessageCallback): () => void;
Subscribe to feed messages
Fires when a new message is received in the interaction feed
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | FeedMessageCallback | Function to call when a feed message is received |
Returns
Unsubscribe function
(): void;
Returns
void
Example
api.onReceivedFeedMessage((message) => {
console.log('New message:', message.text);
console.log('From:', message.from);
});
Agent API Family
getUserInfo()
getUserInfo(): Promise<UserInfo>;
Get information about the current logged-in user/agent
Returns
Promise<UserInfo>
Promise resolving to the user information including agent status, queues, and profile
Example
const userInfo = await api.getUserInfo();
console.log('Agent:', userInfo.displayName);
console.log('Status:', userInfo.agentStatus);
console.log('Queues:', userInfo.queues);
console.log('Email:', userInfo.email);
setAgentStatus()
setAgentStatus(
userId: string,
status: AgentStatus,
reason?: {
id: string;
name: string;
}): Promise<{
message: string;
}>;
Set the agent's status (Available, Away, Busy, etc.)
Parameters
| Parameter | Type | Description |
|---|---|---|
userId | string | The user ID of the agent |
status | AgentStatus | The new agent status |
reason? | { id: string; name: string; } | Optional reason for the status change (required for some statuses) |
reason.id? | string | - |
reason.name? | string | - |
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Examples
const userInfo = await api.getUserInfo();
await api.setAgentStatus(userInfo.id, 'Available');
const userInfo = await api.getUserInfo();
await api.setAgentStatus(userInfo.id, 'Away', {
id: 'lunch',
name: 'Lunch Break'
});
getAvayaJwt()
getAvayaJwt(options: {
authorizationEndpoint?: string;
tokenEndpoint?: string;
clientId?: string;
scopes?: string[];
redirectUri?: string;
popupOptions?: PopupOptions;
forceRefresh?: boolean;
}): Promise<string>;
Get Avaya JWT token with multi-level request deduplication and automatic refresh
- Returns cached token from localStorage if available and not expired
- Automatically refreshes token if expired (using refresh token)
- Prevents duplicate concurrent fetch requests (instance-level)
- Prevents duplicate OAuth popups across iframes/elements (cross-iframe coordination)
- Initiates Keycloak OAuth flow if no token exists
Cross-iframe coordination ensures that if 10 iframes all call getAvayaJwt(),
only ONE OAuth popup will appear, and all iframes will receive the same token.
Uses the existing inter-element BroadcastChannel for coordination (consistent with other APIs)
GUARANTEE: This function ALWAYS either returns a JWT string or throws an error.
There are no code paths that return undefined or hang indefinitely.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | { authorizationEndpoint?: string; tokenEndpoint?: string; clientId?: string; scopes?: string[]; redirectUri?: string; popupOptions?: PopupOptions; forceRefresh?: boolean; } | Configuration options (all optional, uses defaults if not provided) |
options.authorizationEndpoint? | string | Keycloak authorization endpoint URL |
options.tokenEndpoint? | string | Keycloak token endpoint URL |
options.clientId? | string | OAuth client ID |
options.scopes? | string[] | OAuth scopes to request |
options.redirectUri? | string | OAuth redirect URI (URL to redirect.html) |
options.popupOptions? | PopupOptions | Popup window size/position (defaults to 500x600) |
options.forceRefresh? | boolean | Force token refresh even if not expired (defaults to false) |
Returns
Promise<string>
Promise The JWT token (never returns undefined, always throws on error)
Example
// Use defaults
const jwt = await api.getAvayaJwt();
// With configuration
const jwt = await api.getAvayaJwt({
authorizationEndpoint: 'https://keycloak.example.com/auth/realms/xxx/protocol/openid-connect/auth',
tokenEndpoint: 'https://keycloak.example.com/auth/realms/xxx/protocol/openid-connect/token',
clientId: 'my-client-id',
redirectUri: 'https://myapp.com/redirect.html',
forceRefresh: true
});
refreshToken()
refreshToken(options: {
tokenEndpoint?: string;
clientId?: string;
}): Promise<string>;
Refresh the access token using the stored refresh token
Parameters
| Parameter | Type | Description |
|---|---|---|
options | { tokenEndpoint?: string; clientId?: string; } | Configuration options |
options.tokenEndpoint? | string | Keycloak token endpoint URL (required) |
options.clientId? | string | OAuth client ID (required) |
Returns
Promise<string>
Promise The new JWT access token
Throws
Error if refresh token is not available or refresh fails
Example
try {
const newJwt = await api.refreshToken({
tokenEndpoint: 'https://keycloak.example.com/auth/realms/xxx/protocol/openid-connect/token',
clientId: 'my-client-id'
});
console.log('Token refreshed successfully');
} catch (error) {
console.error('Token refresh failed:', error);
// May need to re-authenticate
}
clearAvayaJwt()
clearAvayaJwt(): void;
Clear the cached JWT token and force re-authentication on next getAvayaJwt call
Returns
void
Example
api.clearAvayaJwt();
const newJwt = await api.getAvayaJwt(); // Will trigger OAuth flow
Admin API Family
getUsers()
getUsers(params?: {
interactionId?: string;
filter?: string;
}): Promise<GetUsersResponse[]>;
Get a list of users in Infinity
Returns users available for transfer or consult operations. Returns up to 100 users.
- App Level (sidebar widgets): Provide
interactionIdparameter - Interaction Level (interaction widgets): Omit
interactionId, uses interaction context automatically
Parameters
| Parameter | Type | Description |
|---|---|---|
params? | { interactionId?: string; filter?: string; } | Optional parameters |
params.interactionId? | string | Required for app-level widgets, optional for interaction-level widgets |
params.filter? | string | Optional substring search against user name fields |
Returns
Promise<GetUsersResponse[]>
Promise resolving to array of user information
Examples
const users = await api.getUsers();
users.forEach(user => {
console.log(`${user.fullName} - ${user.cxStatus.status} - ${user.presence}`);
});
const users = await api.getUsers({ filter: 'john' });
console.log('Found users:', users.map(u => u.fullName));
const users = await api.getUsers({ interactionId: 'int-123' });
users.forEach(user => {
console.log(`${user.fullName} - ${user.cxStatus.status} - ${user.presence}`);
});
const users = await api.getUsers({
interactionId: 'int-123',
filter: 'john'
});
const users = await api.getUsers({ filter: searchInput });
const eligibleUsers = users.filter(u => u.eligible);
eligibleUsers.forEach(user => {
console.log(`${user.fullName} (${user.extension}) - ${user.cxStatus.status}`);
});
getUserQueues()
getUserQueues(params?: {
filter?: string;
}): Promise<UserQueueInfo[]>;
Get all queues available to the current user (App Level)
Returns a basic list of queues the agent has access to.
Parameters
| Parameter | Type | Description |
|---|---|---|
params? | { filter?: string; } | Optional filter parameters |
params.filter? | string | - |
Returns
Promise<UserQueueInfo[]>
Promise resolving to array of user queue information
Example
const queues = await api.getUserQueues();
console.log('Available queues:', queues.map(q => q.name));
// With filter
const salesQueues = await api.getUserQueues({ filter: 'Sales' });
getTransferQueues()
getTransferQueues(params: {
interactionId: string;
filter?: string;
}): Promise<InteractionQueueInfo[]>;
Get transfer queues with real-time statistics (App Level)
Returns detailed queue information including waiting interactions, active agents,
and average wait times. Requires explicit interactionId since this is used at app level
where interaction context is not available.
Parameters
| Parameter | Type | Description |
|---|---|---|
params | { interactionId: string; filter?: string; } | Required interactionId and optional filter parameters |
params.interactionId | string | - |
params.filter? | string | - |
Returns
Promise<InteractionQueueInfo[]>
Promise resolving to array of queue information with statistics
Example
const queues = await api.getTransferQueues({
interactionId: 'int-123',
filter: 'support'
});
queues.forEach(queue => {
console.log(`${queue.name}: ${queue.waitingInteractions} waiting`);
console.log(`Active agents: ${queue.countActiveAgents}`);
});
getTransferQueuesInteraction()
getTransferQueuesInteraction(params?: {
filter?: string;
}): Promise<InteractionQueueInfo[]>;
Get transfer queues with real-time statistics (Interaction Level)
Returns detailed queue information including waiting interactions, active agents,
and average wait times. Uses interaction context automatically.
Parameters
| Parameter | Type | Description |
|---|---|---|
params? | { filter?: string; } | Optional filter parameters |
params.filter? | string | - |
Returns
Promise<InteractionQueueInfo[]>
Promise resolving to array of queue information with statistics
Example
const queues = await api.getTransferQueuesInteraction({ filter: 'support' });
queues.forEach(queue => {
console.log(`${queue.name}: ${queue.waitingInteractions} waiting`);
console.log(`Active agents: ${queue.countActiveAgents}`);
});
getReasonCodes()
getReasonCodes(params?: GetReasonCodesParams): Promise<GetReasonCodesResponse>;
Get reason codes for agent status changes
Returns available reason codes that can be used when changing agent status.
Parameters
| Parameter | Type | Description |
|---|---|---|
params? | GetReasonCodesParams | Optional parameters |
Returns
Promise<GetReasonCodesResponse>
Promise resolving to reason codes response
Examples
const response = await api.getReasonCodes();
console.log('Reason codes:', response.reasons);
const response = await api.getReasonCodes({ type: 'away' });
const awayReasons = response.reasons;
Inter-Element Communication
sendInterElementMessage()
sendInterElementMessage<T>(message: T): void;
Send a message to other elements via the inter-element BroadcastChannel
Type Parameters
| Type Parameter | Description |
|---|---|
T | The type of the message |
Parameters
| Parameter | Type | Description |
|---|---|---|
message | T | The message to send (can be any serializable type) |
Returns
void
onInterElementMessage()
onInterElementMessage<T>(callback: (message: T) => void): () => void;
Subscribe to messages from other elements via the inter-element BroadcastChannel
This is the easiest way to listen for messages - just provide a callback function
Type Parameters
| Type Parameter | Description |
|---|---|
T | The expected type of messages |
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | (message: T) => void | Function called when a message is received |
Returns
Unsubscribe function to stop listening
(): void;
Returns
void
Example
const unsubscribe = api.onInterElementMessage<MyMessageType>((message) => {
console.log('Received:', message);
});
// Later, stop listening
unsubscribe();
Events
onError()
onError(callback: ErrorCallback): () => void;
Subscribe to error events
Fires when an error occurs in the API
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | ErrorCallback | Function to call when an error occurs |
Returns
Unsubscribe function
(): void;
Returns
void
Example
api.onError((error) => {
console.error('API Error:', error.code, error.message);
// Display error notification to user
});
Lifecycle
destroy()
destroy(): void;
Clean up resources when the React component is unmounted or no longer needed
Removes all event listeners, closes channels, and clears pending requests.
Call this method in your React component's cleanup/unmount lifecycle.
Returns
void
Example
// In a React component
useEffect(() => {
const api = new ElementAPI();
return () => {
api.destroy(); // Cleanup on unmount
};
}, []);
Enumerations
DialpadDigit
DTMF dialpad digits (0-9) for sending tones during calls
Example
import { DialpadDigit } from '@avaya/infinity-elements-api';
await api.sendDialpadDigit(DialpadDigit.Five, null, false);
Functions
setupOAuthCallbackHandler()
function setupOAuthCallbackHandler(): void;
Setup OAuth callback handler - call once at app initialization
Sets up listener for redirect.html config requests
Returns
void
refreshAccessToken()
function refreshAccessToken(
refreshToken: string,
tokenEndpoint: string,
clientId: string): Promise<TokenResponse>;
Refresh an expired access token using the refresh token
Elements run in sandboxed iframes (about:srcdoc) which have origin "null".
Direct fetch to Keycloak fails due to CORS.
This function delegates the refresh request to the host (agent-ui) via
postMessage. The host has a proper origin and can make the request
without CORS issues. This is completely silent - no popups or visible UI.
Parameters
| Parameter | Type | Description |
|---|---|---|
refreshToken | string | The refresh token to use |
tokenEndpoint | string | The token endpoint URL |
clientId | string | The OAuth client ID |
Returns
Promise<TokenResponse>
getStoredTokenData()
function getStoredTokenData(jwtStorageKey: string): StoredTokenData | null;
Get stored token data from localStorage
Parameters
| Parameter | Type |
|---|---|
jwtStorageKey | string |
Returns
StoredTokenData | null
isTokenExpired()
function isTokenExpired(tokenData: StoredTokenData): boolean;
Check if a token is expired
Parameters
| Parameter | Type |
|---|---|
tokenData | StoredTokenData |
Returns
boolean
isRefreshTokenExpired()
function isRefreshTokenExpired(tokenData: StoredTokenData): boolean;
Check if refresh token is expired
Parameters
| Parameter | Type |
|---|---|
tokenData | StoredTokenData |
Returns
boolean
Interfaces
InteractionInfo
Properties
InteractionUpdatePayload
Properties
BlindTransferOptions
Properties
SingleStepTransferParams
Properties
CreateVoiceInteractionParams
Properties
SendRichMediaMessageOptions
Properties
SendChatMessageOptions
Properties
ConsultCallOptions
Properties
AgentStatus
Properties
ReasonCode
Properties
GetReasonCodesParams
Properties
GetReasonCodesResponse
Properties
| Property | Type |
|---|---|
reasons | ReasonCode[] |
GetUserInteractionsParams
Properties
QueueLoggedIn
Properties
QueueAccess
Properties
UserInteractionsUser
Properties
GetUserInteractionsResponse
Properties
| Property | Type |
|---|---|
interactions | Interaction[] |
viewing | Interaction[] |
combinedIds? | string[] |
queue | { loggedIn: QueueLoggedIn[]; access: QueueAccess[]; } |
queue.loggedIn | QueueLoggedIn[] |
queue.access | QueueAccess[] |
user | UserInteractionsUser |
ElementAPIOptions
Configuration options for ElementAPI initialization
Properties
InteractionQueueInfo
Properties
UserQueueInfo
Properties
KeycloakConfig
Keycloak OAuth 2.0 PKCE Authentication Module
Supports cross-iframe coordination to prevent multiple OAuth popups
Uses postMessage-based config exchange with redirect.html:
- Component opens popup directly
- redirect.html requests config via postMessage
- Component responds with config + code verifier
- redirect.html performs token exchange
- redirect.html sends token back to component
No localStorage bridging needed - config stays in memory.
Properties
PopupOptions
Properties
TokenResponse
Properties
StoredTokenData
Properties
GetUsersResponse
Response from getUsers API
Used for transfer/consult target selection
Properties
UserLocation
Properties
QueueInfo
Properties
UserTag
Properties
DefaultLeaveEventToStatus
Properties
InfinityElement
Properties
UserInfo
Properties
| Property | Type | Description |
|---|---|---|
userId | string | User ID |
status? | string | Whether the user is enabled (status === 'enabled' for yes) |
firstName | string | First name |
lastName | string | Last name |
nameSuffix? | string | null | Name suffix (e.g., Jr., Sr., III) |
title | string | Job title |
email | string | Email address |
mobile? | string | null | Mobile phone number |
languageCode? | string | Language code (e.g., 'en', 'es') |
location? | UserLocation | null | E911 location information |
timezone? | string | Timezone (e.g., 'America/New_York') |
licenseType? | string | License type |
consolePermissions? | { account?: Record<"read", string>; api?: Record<"read", string>; callRecordings?: Record<"delete", string>; cx?: Record<"read", string>; mL?: Record<"read", string>; numbers?: Record<"read", string>; objects?: Record<"read", string>; portal?: Record<"console-web", string>; queues?: Record<"read", string>; } | Console permissions |
consolePermissions.account? | Record<"read", string> | - |
consolePermissions.api? | Record<"read", string> | - |
consolePermissions.callRecordings? | Record<"delete", string> | - |
consolePermissions.cx? | Record<"read", string> | - |
consolePermissions.mL? | Record<"read", string> | - |
consolePermissions.numbers? | Record<"read", string> | - |
consolePermissions.objects? | Record<"read", string> | - |
consolePermissions.portal? | Record<"console-web", string> | - |
consolePermissions.queues? | Record<"read", string> | - |
appPermissions? | { agent?: Record<"read", string>; analytics?: Record<"read", string>; chat?: Record<"read" | "admin", string>; coaching?: Record<"read", string>; contacts?: Record<"read", string>; workflowReplay?: Record<"read", string>; dashboards?: Record<"read", string>; portal?: { app-android: string; app-ios: string; app-osx: string; app-web: string; app-win: string; app-support-access: string; }; queueList?: Record<"read", string>; queueToggling?: Record<"read", string>; teamview?: Record<"read", string>; ucFax?: Record<"read", string>; outreachmonitor?: Record<"read", string>; } | Application permissions |
appPermissions.agent? | Record<"read", string> | - |
appPermissions.analytics? | Record<"read", string> | - |
appPermissions.chat? | Record<"read" | "admin", string> | - |
appPermissions.coaching? | Record<"read", string> | - |
appPermissions.contacts? | Record<"read", string> | - |
appPermissions.workflowReplay? | Record<"read", string> | - |
appPermissions.dashboards? | Record<"read", string> | - |
appPermissions.portal? | { app-android: string; app-ios: string; app-osx: string; app-web: string; app-win: string; app-support-access: string; } | - |
appPermissions.portal.app-android | string | - |
appPermissions.portal.app-ios | string | - |
appPermissions.portal.app-osx | string | - |
appPermissions.portal.app-web | string | - |
appPermissions.portal.app-win | string | - |
appPermissions.portal.app-support-access | string | - |
appPermissions.queueList? | Record<"read", string> | - |
appPermissions.queueToggling? | Record<"read", string> | - |
appPermissions.teamview? | Record<"read", string> | - |
appPermissions.ucFax? | Record<"read", string> | - |
appPermissions.outreachmonitor? | Record<"read", string> | - |
outboundPermissions? | { task: "0" | "1"; email: "0" | "1"; phone: "0" | "1"; messaging: "0" | "1"; } | Outbound permissions by communication type |
outboundPermissions.task | "0" | "1" | - |
outboundPermissions.email | "0" | "1" | - |
outboundPermissions.phone | "0" | "1" | - |
outboundPermissions.messaging | "0" | "1" | - |
rejectInteractions? | boolean | Inbound permissions - can reject interactions |
monitoringAction? | string | Monitoring action configuration |
completedAction? | string | Completed action configuration |
interactionViewsType? | string | Interaction view type |
modifyInteractionViews? | boolean | Can create/edit interaction views |
tags? | UserTag[] | List of assigned tags |
personalQueueId? | string | Personal queue ID |
defaultOutboundQueue? | string | Default outbound queue name |
outboundActionAndStatus? | DefaultLeaveEventToStatus | Outbound call action and status |
inboundActionAndStatus? | DefaultLeaveEventToStatus | Inbound call action and status |
callbackActionAndStatus? | DefaultLeaveEventToStatus | Callback action and status |
voicemailActionAndStatus? | DefaultLeaveEventToStatus | Voicemail action and status |
queues? | QueueInfo[] | List of assigned queues with access, auto-login, and proficiency info |
phoneSpaces? | number | Number of concurrent phone interactions allowed |
messagingSpaces? | number | Number of concurrent messaging interactions allowed |
emailSpaces? | number | Number of concurrent email interactions allowed |
taskSpaces? | number | Number of concurrent task interactions allowed |
eliteExtension? | string | null | Elite Agent Extension |
eliteAgentId? | string | null | Elite Agent ID |
eliteSipAddress? | string | null | SIP Address |
eliteSbcGroupId? | string | null | SBC Group ID |
crmConfigurations? | unknown | CRM Configuration object |
infinityElements? | InfinityElement[] | App-level Infinity Elements assigned |
authToken? | string | Authentication token (JWT) using accessToken |
Type Aliases
CHANNEL_NAMES
type CHANNEL_NAMES = {
INTERACTION_STATUS_CHANGED: "interaction-status-changed";
INTERACTION_ENDED: "on-interaction-ended";
INTERACTION_ACCEPTED: "on-interaction-accepted";
INTERACTION_UPDATED: "on-interaction-updated";
CONSULT_STATUS_CHANGED: "consult-status-changed";
FEED_MESSAGE: "feed-message";
INTER_ELEMENT: "inter-element";
};
Properties
InteractionStatusChangedCallback()
type InteractionStatusChangedCallback = (payload: {
interactionId: string;
status: string;
}) => void;
Parameters
| Parameter | Type |
|---|---|
payload | { interactionId: string; status: string; } |
payload.interactionId | string |
payload.status | string |
Returns
void
InteractionEndedCallback()
type InteractionEndedCallback = (interactionId: string) => void;
Parameters
| Parameter | Type |
|---|---|
interactionId | string |
Returns
void
InteractionAcceptedCallback()
type InteractionAcceptedCallback = (interactionId: string) => void;
Parameters
| Parameter | Type |
|---|---|
interactionId | string |
Returns
void
InteractionUpdatedCallback()
type InteractionUpdatedCallback = (payload: {
interactionId: string;
event: "interaction.update";
payload: Interaction;
}) => void;
Parameters
| Parameter | Type |
|---|---|
payload | { interactionId: string; event: "interaction.update"; payload: Interaction; } |
payload.interactionId | string |
payload.event | "interaction.update" |
payload.payload | Interaction |
Returns
void
ConsultStatusChangedCallback()
type ConsultStatusChangedCallback = (payload: {
interactionId: string;
consultStatus: string;
consultParty?: string;
error?: string;
}) => void;
Parameters
| Parameter | Type |
|---|---|
payload | { interactionId: string; consultStatus: string; consultParty?: string; error?: string; } |
payload.interactionId | string |
payload.consultStatus | string |
payload.consultParty? | string |
payload.error? | string |
Returns
void
FeedMessageCallback()
type FeedMessageCallback = (message: Message) => void;
Parameters
| Parameter | Type |
|---|---|
message | Message |
Returns
void
ErrorCallback()
type ErrorCallback = (error: {
code: string;
message: string;
details?: unknown;
}) => void;
Parameters
| Parameter | Type |
|---|---|
error | { code: string; message: string; details?: unknown; } |
error.code | string |
error.message | string |
error.details? | unknown |
Returns
void
Variables
VERSION
const VERSION: "0.1.0" = "0.1.0";
@avaya/infinity-elements-api v1.0.0
ElementAPI
ElementAPI - Main API for web components to interact with the Infinity Extensibility Framework
This is the primary interface that elements use to communicate with core-agent-ui.
Uses window.postMessage for API requests/responses and events, with BroadcastChannel
for inter-element communication.
The methods are organized into four API families:
-
Interaction API Family - Controls and monitors customer interactions throughout their lifecycle. Initiate new voice and chat interactions, execute controls (transfer, consult, conference), and subscribe to interaction events.
-
Media API Family - Manages channel-specific capabilities including DTMF tones on voice channels and rich text messages with formatting and attachments.
-
Agent API Family - Manages agent presence and availability. Modify agent state and subscribe to state change notifications.
-
Admin API Family - Provides environmental and configuration data including logged-in agent context, users, queues, and reason codes.
Examples
import { ElementAPI } from '@avaya/infinity-elements-api';
const api = new ElementAPI({
elementId: 'my-element',
timeout: 5000,
debug: true
});
const userInfo = await api.getUserInfo();
console.log('Agent name:', userInfo.displayName);
console.log('Agent status:', userInfo.agentStatus);
api.onInteractionAccepted((interactionId) => {
console.log('Interaction accepted:', interactionId);
});
api.onInteractionEnded((interactionId) => {
console.log('Interaction ended:', interactionId);
});
Constructors
Constructor
new ElementAPI(options: ElementAPIOptions): ElementAPI;
Creates a new ElementAPI instance
Parameters
| Parameter | Type |
|---|---|
options | ElementAPIOptions |
Returns
Example
const api = new ElementAPI({
elementId: 'my-custom-element',
timeout: 10000,
debug: true
});
Methods
Interaction API Family
getInteraction()
getInteraction(): Promise<InteractionInfo>;
Get information about the current active interaction
Returns
Promise<InteractionInfo>
Promise resolving to the interaction information
Throws
Error if no active interaction exists
Example
try {
const interaction = await api.getInteraction();
console.log('Interaction ID:', interaction.interactionId);
console.log('Customer:', interaction.customer?.name);
console.log('Status:', interaction.status);
} catch (error) {
console.error('No active interaction');
}
getUserInteractions()
getUserInteractions(params?: GetUserInteractionsParams): Promise<GetUserInteractionsResponse>;
Get user interactions including owned and viewing interactions
Retrieves all active interactions for the current or specified user,
including interactions they own and ones they are viewing.
Optionally includes queue and user details.
Parameters
| Parameter | Type | Description |
|---|---|---|
params? | GetUserInteractionsParams | Optional parameters |
Returns
Promise<GetUserInteractionsResponse>
Promise resolving to user interactions data
Examples
// Get current user's interactions with full details
const result = await api.getUserInteractions({ details: true });
console.log('Owned interactions:', result.interactions);
console.log('Viewing interactions:', result.viewing);
console.log('Logged in queues:', result.queue.loggedIn);
// Get interactions without queue/user details for better performance
const result = await api.getUserInteractions({ details: false });
const totalCount = result.interactions.length + result.viewing.length;
console.log('Total active interactions:', totalCount);
viewerRemoveInteraction()
viewerRemoveInteraction(): Promise<{
message: string;
}>;
Remove the current interaction from the viewer
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Example
await api.viewerRemoveInteraction();
endInteraction()
endInteraction(): Promise<{
message: string;
}>;
End the current interaction
Terminates the active interaction and disconnects the call.
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Example
await api.endInteraction();
console.log('Interaction ended');
startVoiceCall()
startVoiceCall(): Promise<{
message: string;
}>;
Start a voice call for the current interaction
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Example
await api.startVoiceCall();
createVoiceInteraction()
createVoiceInteraction(params: CreateVoiceInteractionParams): Promise<{
message: string;
}>;
Create a new voice interaction with a Queue ID and Phone Number
Creates a new outbound voice call interaction to the specified phone number
and assigns it to the specified queue.
Parameters
| Parameter | Type | Description |
|---|---|---|
params | CreateVoiceInteractionParams | Voice interaction parameters |
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Example
await api.createVoiceInteraction({
phoneNumber: '+1234567890',
queueId: '003'
});
completeBlindTransfer()
completeBlindTransfer(options: BlindTransferOptions): Promise<boolean>;
Complete a blind transfer
Transfers the call to another agent or number without consultation.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | BlindTransferOptions | Transfer configuration |
Returns
Promise<boolean>
Promise resolving to true if successful
Example
const interaction = await api.getInteraction();
await api.completeBlindTransfer({
interactionId: interaction.interactionId,
transferTo: '[email protected]',
transferToName: 'John Doe',
transferCallerIdType: 'internal'
});
singleStepTransfer()
singleStepTransfer(params: SingleStepTransferParams): Promise<{
message: string;
}>;
Perform a single-step transfer
Transfers the interaction directly to the specified target.
Parameters
| Parameter | Type | Description |
|---|---|---|
params | SingleStepTransferParams | Transfer parameters |
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Example
await api.singleStepTransfer({
targetId: 'user123',
targetName: 'Support Team'
});
consultCall()
consultCall(options: ConsultCallOptions): Promise<{
message: string;
}>;
Initiate a consult call
Starts a consultation with another agent, phone number, or queue while keeping
the original caller on hold.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | ConsultCallOptions | Consult call configuration |
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Examples
const interaction = await api.getInteraction();
await api.consultCall({
interactionId: interaction.interactionId,
transferTo: '[email protected]'
});
await api.consultCall({
interactionId: interaction.interactionId,
phoneNumber: '+1234567890'
});
// Get available queues first
const queues = await api.getTransferQueuesInteraction();
const targetQueue = queues.find(q => q.name === 'Support Queue');
await api.consultCall({
interactionId: interaction.interactionId,
queueId: targetQueue.id
});
completeAttendedTransfer()
completeAttendedTransfer(): Promise<{
message: string;
}>;
Complete an attended transfer
Finalizes the attended transfer after consulting with the target party.
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Example
// After consulting
await api.completeAttendedTransfer();
attendedTransferWarm()
attendedTransferWarm(): Promise<{
message: string;
}>;
Perform a warm attended transfer
Introduces the caller to the transfer target before completing the transfer.
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Example
await api.attendedTransferWarm();
attendedTransferCancel()
attendedTransferCancel(): Promise<{
message: string;
}>;
Cancel an attended transfer
Cancels the ongoing attended transfer and returns to the original call.
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Example
await api.attendedTransferCancel();
acceptInteraction()
acceptInteraction(): Promise<{
message: string;
}>;
Accept an incoming interaction
Accepts a queued or alerting interaction.
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Example
api.onInteractionAccepted(async (interactionId) => {
console.log('New interaction:', interactionId);
});
// When ready to accept
await api.acceptInteraction();
onInteractionStatusChanged()
onInteractionStatusChanged(callback: InteractionStatusChangedCallback): () => void;
Subscribe to interaction status changes
Fires when the status of an interaction changes (e.g., alerting, connected, held)
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | InteractionStatusChangedCallback | Function to call when interaction status changes |
Returns
Unsubscribe function
(): void;
Returns
void
Example
const unsubscribe = api.onInteractionStatusChanged(({ interactionId, status }) => {
console.log(`Interaction ${interactionId} status changed to ${status}`);
});
// Later, to unsubscribe:
unsubscribe();
onInteractionAccepted()
onInteractionAccepted(callback: InteractionAcceptedCallback): () => void;
Subscribe to interaction accepted events
Fires when an agent accepts an incoming interaction
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | InteractionAcceptedCallback | Function to call when an interaction is accepted |
Returns
Unsubscribe function
(): void;
Returns
void
Example
api.onInteractionAccepted((interactionId) => {
console.log('Accepted interaction:', interactionId);
// Load customer data, show interaction UI, etc.
});
onInteractionEnded()
onInteractionEnded(callback: InteractionEndedCallback): () => void;
Subscribe to interaction ended events
Fires when an interaction is ended or disconnected
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | InteractionEndedCallback | Function to call when an interaction ends |
Returns
Unsubscribe function
(): void;
Returns
void
Example
api.onInteractionEnded((interactionId) => {
console.log('Interaction ended:', interactionId);
// Clean up UI, save data, etc.
});
onInteractionUpdated()
onInteractionUpdated(callback: InteractionUpdatedCallback): () => void;
Subscribe to interaction updated events
Fires when an interaction is updated with new information
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | InteractionUpdatedCallback | Function to call when an interaction is updated |
Returns
Unsubscribe function
(): void;
Returns
void
Example
api.onInteractionUpdated(({ interactionId, payload }) => {
console.log('Interaction updated:', interactionId);
console.log('New data:', payload);
});
onConsultStatusChanged()
onConsultStatusChanged(callback: ConsultStatusChangedCallback): () => void;
Subscribe to consult status changes
Fires when the status of a consultation changes
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | ConsultStatusChangedCallback | Function to call when consult status changes |
Returns
Unsubscribe function
(): void;
Returns
void
Example
api.onConsultStatusChanged(({ interactionId, consultStatus, consultParty }) => {
console.log(`Consult ${consultStatus} with ${consultParty}`);
});
Media API Family
sendDialpadDigit()
sendDialpadDigit(
digit: DialpadDigit,
audioOutputDeviceId: string | null,
noSendDialTone: boolean,
audioContextOverride?: "none" | "standard" | "webkit"): Promise<{
message: string;
}>;
Send a DTMF dialpad digit during a call
Parameters
| Parameter | Type | Description |
|---|---|---|
digit | DialpadDigit | The dialpad digit to send (0-9) |
audioOutputDeviceId | string | null | Audio output device ID or null for default |
noSendDialTone | boolean | Whether to suppress the dial tone sound |
audioContextOverride? | "none" | "standard" | "webkit" | Audio context type override |
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Example
import { DialpadDigit } from '@avaya/infinity-elements-api';
await api.sendDialpadDigit(
DialpadDigit.One,
null,
false
);
insertTextIntoFeedInput()
insertTextIntoFeedInput(text: string): Promise<{
message: string;
}>;
Insert text into the chat feed input field
Parameters
| Parameter | Type | Description |
|---|---|---|
text | string | The text to insert |
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Example
await api.insertTextIntoFeedInput('Hello, how can I help you today?');
sendRichMediaMessage()
sendRichMediaMessage(options: SendRichMediaMessageOptions): Promise<{
message: string;
}>;
Send a rich media message (image, file, etc.) to the interaction
Parameters
| Parameter | Type | Description |
|---|---|---|
options | SendRichMediaMessageOptions | Message options (must provide either mediaUrl or file) |
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Deprecated
This method is deprecated and will be removed in a future version.
Examples
await api.sendRichMediaMessage({
name: 'Product Image',
mediaUrl: 'https://example.com/image.jpg',
text: 'Here is the product you requested'
});
const fileInput = document.querySelector('input[type="file"]');
const file = fileInput.files[0];
await api.sendRichMediaMessage({
name: 'Document',
file: file,
text: 'Attached document'
});
sendChatMessage()
sendChatMessage(options: SendChatMessageOptions): Promise<{
message: string;
}>;
Send a chat message to the interaction
Supports sending text messages, media from URLs, or file uploads.
At least one of text, mediaUrl, or file must be provided.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | SendChatMessageOptions | Message options (must provide interactionId and at least one of text, mediaUrl, or file) |
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Examples
await api.sendChatMessage({
interactionId: 'int-123',
text: 'Hello, how can I help you today?'
});
await api.sendChatMessage({
interactionId: 'int-123',
mediaUrl: 'https://example.com/image.jpg',
text: 'Here is the product you requested'
});
const fileInput = document.querySelector('input[type="file"]');
const file = fileInput.files[0];
await api.sendChatMessage({
interactionId: 'int-123',
file: file,
text: 'Attached document'
});
await api.sendChatMessage({
interactionId: 'int-123',
text: 'Please review this document',
file: documentFile,
fileName: 'Important Document.pdf'
});
onReceivedFeedMessage()
onReceivedFeedMessage(callback: FeedMessageCallback): () => void;
Subscribe to feed messages
Fires when a new message is received in the interaction feed
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | FeedMessageCallback | Function to call when a feed message is received |
Returns
Unsubscribe function
(): void;
Returns
void
Example
api.onReceivedFeedMessage((message) => {
console.log('New message:', message.text);
console.log('From:', message.from);
});
Agent API Family
getUserInfo()
getUserInfo(): Promise<UserInfo>;
Get information about the current logged-in user/agent
Returns
Promise<UserInfo>
Promise resolving to the user information including agent status, queues, and profile
Example
const userInfo = await api.getUserInfo();
console.log('Agent:', userInfo.displayName);
console.log('Status:', userInfo.agentStatus);
console.log('Queues:', userInfo.queues);
console.log('Email:', userInfo.email);
setAgentStatus()
setAgentStatus(
userId: string,
status: AgentStatus,
reason?: {
id: string;
name: string;
}): Promise<{
message: string;
}>;
Set the agent's status (Available, Away, Busy, etc.)
Parameters
| Parameter | Type | Description |
|---|---|---|
userId | string | The user ID of the agent |
status | AgentStatus | The new agent status |
reason? | { id: string; name: string; } | Optional reason for the status change (required for some statuses) |
reason.id? | string | - |
reason.name? | string | - |
Returns
Promise<{
message: string;
}>
Promise resolving to a success message
Examples
const userInfo = await api.getUserInfo();
await api.setAgentStatus(userInfo.id, 'Available');
const userInfo = await api.getUserInfo();
await api.setAgentStatus(userInfo.id, 'Away', {
id: 'lunch',
name: 'Lunch Break'
});
getAvayaJwt()
getAvayaJwt(options: {
authorizationEndpoint?: string;
tokenEndpoint?: string;
clientId?: string;
scopes?: string[];
redirectUri?: string;
popupOptions?: PopupOptions;
forceRefresh?: boolean;
}): Promise<string>;
Get Avaya JWT token with multi-level request deduplication and automatic refresh
- Returns cached token from localStorage if available and not expired
- Automatically refreshes token if expired (using refresh token)
- Prevents duplicate concurrent fetch requests (instance-level)
- Prevents duplicate OAuth popups across iframes/elements (cross-iframe coordination)
- Initiates Keycloak OAuth flow if no token exists
Cross-iframe coordination ensures that if 10 iframes all call getAvayaJwt(),
only ONE OAuth popup will appear, and all iframes will receive the same token.
Uses the existing inter-element BroadcastChannel for coordination (consistent with other APIs)
GUARANTEE: This function ALWAYS either returns a JWT string or throws an error.
There are no code paths that return undefined or hang indefinitely.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | { authorizationEndpoint?: string; tokenEndpoint?: string; clientId?: string; scopes?: string[]; redirectUri?: string; popupOptions?: PopupOptions; forceRefresh?: boolean; } | Configuration options (all optional, uses defaults if not provided) |
options.authorizationEndpoint? | string | Keycloak authorization endpoint URL |
options.tokenEndpoint? | string | Keycloak token endpoint URL |
options.clientId? | string | OAuth client ID |
options.scopes? | string[] | OAuth scopes to request |
options.redirectUri? | string | OAuth redirect URI (URL to redirect.html) |
options.popupOptions? | PopupOptions | Popup window size/position (defaults to 500x600) |
options.forceRefresh? | boolean | Force token refresh even if not expired (defaults to false) |
Returns
Promise<string>
Promise The JWT token (never returns undefined, always throws on error)
Example
// Use defaults
const jwt = await api.getAvayaJwt();
// With configuration
const jwt = await api.getAvayaJwt({
authorizationEndpoint: 'https://keycloak.example.com/auth/realms/xxx/protocol/openid-connect/auth',
tokenEndpoint: 'https://keycloak.example.com/auth/realms/xxx/protocol/openid-connect/token',
clientId: 'my-client-id',
redirectUri: 'https://myapp.com/redirect.html',
forceRefresh: true
});
refreshToken()
refreshToken(options: {
tokenEndpoint?: string;
clientId?: string;
}): Promise<string>;
Refresh the access token using the stored refresh token
Parameters
| Parameter | Type | Description |
|---|---|---|
options | { tokenEndpoint?: string; clientId?: string; } | Configuration options |
options.tokenEndpoint? | string | Keycloak token endpoint URL (required) |
options.clientId? | string | OAuth client ID (required) |
Returns
Promise<string>
Promise The new JWT access token
Throws
Error if refresh token is not available or refresh fails
Example
try {
const newJwt = await api.refreshToken({
tokenEndpoint: 'https://keycloak.example.com/auth/realms/xxx/protocol/openid-connect/token',
clientId: 'my-client-id'
});
console.log('Token refreshed successfully');
} catch (error) {
console.error('Token refresh failed:', error);
// May need to re-authenticate
}
clearAvayaJwt()
clearAvayaJwt(): void;
Clear the cached JWT token and force re-authentication on next getAvayaJwt call
Returns
void
Example
api.clearAvayaJwt();
const newJwt = await api.getAvayaJwt(); // Will trigger OAuth flow
Admin API Family
getUsers()
getUsers(params?: {
interactionId?: string;
filter?: string;
}): Promise<GetUsersResponse[]>;
Get a list of users in Infinity
Returns users available for transfer or consult operations. Returns up to 100 users.
- App Level (sidebar widgets): Provide
interactionIdparameter - Interaction Level (interaction widgets): Omit
interactionId, uses interaction context automatically
Parameters
| Parameter | Type | Description |
|---|---|---|
params? | { interactionId?: string; filter?: string; } | Optional parameters |
params.interactionId? | string | Required for app-level widgets, optional for interaction-level widgets |
params.filter? | string | Optional substring search against user name fields |
Returns
Promise<GetUsersResponse[]>
Promise resolving to array of user information
Examples
const users = await api.getUsers();
users.forEach(user => {
console.log(`${user.fullName} - ${user.cxStatus.status} - ${user.presence}`);
});
const users = await api.getUsers({ filter: 'john' });
console.log('Found users:', users.map(u => u.fullName));
const users = await api.getUsers({ interactionId: 'int-123' });
users.forEach(user => {
console.log(`${user.fullName} - ${user.cxStatus.status} - ${user.presence}`);
});
const users = await api.getUsers({
interactionId: 'int-123',
filter: 'john'
});
const users = await api.getUsers({ filter: searchInput });
const eligibleUsers = users.filter(u => u.eligible);
eligibleUsers.forEach(user => {
console.log(`${user.fullName} (${user.extension}) - ${user.cxStatus.status}`);
});
getUserQueues()
getUserQueues(params?: {
filter?: string;
}): Promise<UserQueueInfo[]>;
Get all queues available to the current user (App Level)
Returns a basic list of queues the agent has access to.
Parameters
| Parameter | Type | Description |
|---|---|---|
params? | { filter?: string; } | Optional filter parameters |
params.filter? | string | - |
Returns
Promise<UserQueueInfo[]>
Promise resolving to array of user queue information
Example
const queues = await api.getUserQueues();
console.log('Available queues:', queues.map(q => q.name));
// With filter
const salesQueues = await api.getUserQueues({ filter: 'Sales' });
getTransferQueues()
getTransferQueues(params: {
interactionId: string;
filter?: string;
}): Promise<InteractionQueueInfo[]>;
Get transfer queues with real-time statistics (App Level)
Returns detailed queue information including waiting interactions, active agents,
and average wait times. Requires explicit interactionId since this is used at app level
where interaction context is not available.
Parameters
| Parameter | Type | Description |
|---|---|---|
params | { interactionId: string; filter?: string; } | Required interactionId and optional filter parameters |
params.interactionId | string | - |
params.filter? | string | - |
Returns
Promise<InteractionQueueInfo[]>
Promise resolving to array of queue information with statistics
Example
const queues = await api.getTransferQueues({
interactionId: 'int-123',
filter: 'support'
});
queues.forEach(queue => {
console.log(`${queue.name}: ${queue.waitingInteractions} waiting`);
console.log(`Active agents: ${queue.countActiveAgents}`);
});
getTransferQueuesInteraction()
getTransferQueuesInteraction(params?: {
filter?: string;
}): Promise<InteractionQueueInfo[]>;
Get transfer queues with real-time statistics (Interaction Level)
Returns detailed queue information including waiting interactions, active agents,
and average wait times. Uses interaction context automatically.
Parameters
| Parameter | Type | Description |
|---|---|---|
params? | { filter?: string; } | Optional filter parameters |
params.filter? | string | - |
Returns
Promise<InteractionQueueInfo[]>
Promise resolving to array of queue information with statistics
Example
const queues = await api.getTransferQueuesInteraction({ filter: 'support' });
queues.forEach(queue => {
console.log(`${queue.name}: ${queue.waitingInteractions} waiting`);
console.log(`Active agents: ${queue.countActiveAgents}`);
});
getReasonCodes()
getReasonCodes(params?: GetReasonCodesParams): Promise<GetReasonCodesResponse>;
Get reason codes for agent status changes
Returns available reason codes that can be used when changing agent status.
Parameters
| Parameter | Type | Description |
|---|---|---|
params? | GetReasonCodesParams | Optional parameters |
Returns
Promise<GetReasonCodesResponse>
Promise resolving to reason codes response
Examples
const response = await api.getReasonCodes();
console.log('Reason codes:', response.reasons);
const response = await api.getReasonCodes({ type: 'away' });
const awayReasons = response.reasons;
Inter-Element Communication
sendInterElementMessage()
sendInterElementMessage<T>(message: T): void;
Send a message to other elements via the inter-element BroadcastChannel
Type Parameters
| Type Parameter | Description |
|---|---|
T | The type of the message |
Parameters
| Parameter | Type | Description |
|---|---|---|
message | T | The message to send (can be any serializable type) |
Returns
void
onInterElementMessage()
onInterElementMessage<T>(callback: (message: T) => void): () => void;
Subscribe to messages from other elements via the inter-element BroadcastChannel
This is the easiest way to listen for messages - just provide a callback function
Type Parameters
| Type Parameter | Description |
|---|---|
T | The expected type of messages |
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | (message: T) => void | Function called when a message is received |
Returns
Unsubscribe function to stop listening
(): void;
Returns
void
Example
const unsubscribe = api.onInterElementMessage<MyMessageType>((message) => {
console.log('Received:', message);
});
// Later, stop listening
unsubscribe();
Events
onError()
onError(callback: ErrorCallback): () => void;
Subscribe to error events
Fires when an error occurs in the API
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | ErrorCallback | Function to call when an error occurs |
Returns
Unsubscribe function
(): void;
Returns
void
Example
api.onError((error) => {
console.error('API Error:', error.code, error.message);
// Display error notification to user
});
Lifecycle
destroy()
destroy(): void;
Clean up resources when the React component is unmounted or no longer needed
Removes all event listeners, closes channels, and clears pending requests.
Call this method in your React component's cleanup/unmount lifecycle.
Returns
void
Example
// In a React component
useEffect(() => {
const api = new ElementAPI();
return () => {
api.destroy(); // Cleanup on unmount
};
}, []);
Enumerations
DialpadDigit
DTMF dialpad digits (0-9) for sending tones during calls
Example
import { DialpadDigit } from '@avaya/infinity-elements-api';
await api.sendDialpadDigit(DialpadDigit.Five, null, false);
Functions
setupOAuthCallbackHandler()
function setupOAuthCallbackHandler(): void;
Setup OAuth callback handler - call once at app initialization
Sets up listener for redirect.html config requests
Returns
void
refreshAccessToken()
function refreshAccessToken(
refreshToken: string,
tokenEndpoint: string,
clientId: string): Promise<TokenResponse>;
Refresh an expired access token using the refresh token
Elements run in sandboxed iframes (about:srcdoc) which have origin "null".
Direct fetch to Keycloak fails due to CORS.
This function delegates the refresh request to the host (agent-ui) via
postMessage. The host has a proper origin and can make the request
without CORS issues. This is completely silent - no popups or visible UI.
Parameters
| Parameter | Type | Description |
|---|---|---|
refreshToken | string | The refresh token to use |
tokenEndpoint | string | The token endpoint URL |
clientId | string | The OAuth client ID |
Returns
Promise<TokenResponse>
getStoredTokenData()
function getStoredTokenData(jwtStorageKey: string): StoredTokenData | null;
Get stored token data from localStorage
Parameters
| Parameter | Type |
|---|---|
jwtStorageKey | string |
Returns
StoredTokenData | null
isTokenExpired()
function isTokenExpired(tokenData: StoredTokenData): boolean;
Check if a token is expired
Parameters
| Parameter | Type |
|---|---|
tokenData | StoredTokenData |
Returns
boolean
isRefreshTokenExpired()
function isRefreshTokenExpired(tokenData: StoredTokenData): boolean;
Check if refresh token is expired
Parameters
| Parameter | Type |
|---|---|
tokenData | StoredTokenData |
Returns
boolean
Interfaces
InteractionInfo
Properties
InteractionUpdatePayload
Properties
BlindTransferOptions
Properties
SingleStepTransferParams
Properties
CreateVoiceInteractionParams
Properties
SendRichMediaMessageOptions
Properties
SendChatMessageOptions
Properties
ConsultCallOptions
Properties
AgentStatus
Properties
ReasonCode
Properties
GetReasonCodesParams
Properties
GetReasonCodesResponse
Properties
| Property | Type |
|---|---|
reasons | ReasonCode[] |
GetUserInteractionsParams
Properties
QueueLoggedIn
Properties
QueueAccess
Properties
UserInteractionsUser
Properties
GetUserInteractionsResponse
Properties
| Property | Type |
|---|---|
interactions | Interaction[] |
viewing | Interaction[] |
combinedIds? | string[] |
queue | { loggedIn: QueueLoggedIn[]; access: QueueAccess[]; } |
queue.loggedIn | QueueLoggedIn[] |
queue.access | QueueAccess[] |
user | UserInteractionsUser |
ElementAPIOptions
Configuration options for ElementAPI initialization
Properties
InteractionQueueInfo
Properties
UserQueueInfo
Properties
KeycloakConfig
Keycloak OAuth 2.0 PKCE Authentication Module
Supports cross-iframe coordination to prevent multiple OAuth popups
Uses postMessage-based config exchange with redirect.html:
- Component opens popup directly
- redirect.html requests config via postMessage
- Component responds with config + code verifier
- redirect.html performs token exchange
- redirect.html sends token back to component
No localStorage bridging needed - config stays in memory.
Properties
PopupOptions
Properties
TokenResponse
Properties
StoredTokenData
Properties
GetUsersResponse
Response from getUsers API
Used for transfer/consult target selection
Properties
UserLocation
Properties
QueueInfo
Properties
UserTag
Properties
DefaultLeaveEventToStatus
Properties
InfinityElement
Properties
UserInfo
Properties
| Property | Type | Description |
|---|---|---|
userId | string | User ID |
status? | string | Whether the user is enabled (status === 'enabled' for yes) |
firstName | string | First name |
lastName | string | Last name |
nameSuffix? | string | null | Name suffix (e.g., Jr., Sr., III) |
title | string | Job title |
email | string | Email address |
mobile? | string | null | Mobile phone number |
languageCode? | string | Language code (e.g., 'en', 'es') |
location? | UserLocation | null | E911 location information |
timezone? | string | Timezone (e.g., 'America/New_York') |
licenseType? | string | License type |
consolePermissions? | { account?: Record<"read", string>; api?: Record<"read", string>; callRecordings?: Record<"delete", string>; cx?: Record<"read", string>; mL?: Record<"read", string>; numbers?: Record<"read", string>; objects?: Record<"read", string>; portal?: Record<"console-web", string>; queues?: Record<"read", string>; } | Console permissions |
consolePermissions.account? | Record<"read", string> | - |
consolePermissions.api? | Record<"read", string> | - |
consolePermissions.callRecordings? | Record<"delete", string> | - |
consolePermissions.cx? | Record<"read", string> | - |
consolePermissions.mL? | Record<"read", string> | - |
consolePermissions.numbers? | Record<"read", string> | - |
consolePermissions.objects? | Record<"read", string> | - |
consolePermissions.portal? | Record<"console-web", string> | - |
consolePermissions.queues? | Record<"read", string> | - |
appPermissions? | { agent?: Record<"read", string>; analytics?: Record<"read", string>; chat?: Record<"read" | "admin", string>; coaching?: Record<"read", string>; contacts?: Record<"read", string>; workflowReplay?: Record<"read", string>; dashboards?: Record<"read", string>; portal?: { app-android: string; app-ios: string; app-osx: string; app-web: string; app-win: string; app-support-access: string; }; queueList?: Record<"read", string>; queueToggling?: Record<"read", string>; teamview?: Record<"read", string>; ucFax?: Record<"read", string>; outreachmonitor?: Record<"read", string>; } | Application permissions |
appPermissions.agent? | Record<"read", string> | - |
appPermissions.analytics? | Record<"read", string> | - |
appPermissions.chat? | Record<"read" | "admin", string> | - |
appPermissions.coaching? | Record<"read", string> | - |
appPermissions.contacts? | Record<"read", string> | - |
appPermissions.workflowReplay? | Record<"read", string> | - |
appPermissions.dashboards? | Record<"read", string> | - |
appPermissions.portal? | { app-android: string; app-ios: string; app-osx: string; app-web: string; app-win: string; app-support-access: string; } | - |
appPermissions.portal.app-android | string | - |
appPermissions.portal.app-ios | string | - |
appPermissions.portal.app-osx | string | - |
appPermissions.portal.app-web | string | - |
appPermissions.portal.app-win | string | - |
appPermissions.portal.app-support-access | string | - |
appPermissions.queueList? | Record<"read", string> | - |
appPermissions.queueToggling? | Record<"read", string> | - |
appPermissions.teamview? | Record<"read", string> | - |
appPermissions.ucFax? | Record<"read", string> | - |
appPermissions.outreachmonitor? | Record<"read", string> | - |
outboundPermissions? | { task: "0" | "1"; email: "0" | "1"; phone: "0" | "1"; messaging: "0" | "1"; } | Outbound permissions by communication type |
outboundPermissions.task | "0" | "1" | - |
outboundPermissions.email | "0" | "1" | - |
outboundPermissions.phone | "0" | "1" | - |
outboundPermissions.messaging | "0" | "1" | - |
rejectInteractions? | boolean | Inbound permissions - can reject interactions |
monitoringAction? | string | Monitoring action configuration |
completedAction? | string | Completed action configuration |
interactionViewsType? | string | Interaction view type |
modifyInteractionViews? | boolean | Can create/edit interaction views |
tags? | UserTag[] | List of assigned tags |
personalQueueId? | string | Personal queue ID |
defaultOutboundQueue? | string | Default outbound queue name |
outboundActionAndStatus? | DefaultLeaveEventToStatus | Outbound call action and status |
inboundActionAndStatus? | DefaultLeaveEventToStatus | Inbound call action and status |
callbackActionAndStatus? | DefaultLeaveEventToStatus | Callback action and status |
voicemailActionAndStatus? | DefaultLeaveEventToStatus | Voicemail action and status |
queues? | QueueInfo[] | List of assigned queues with access, auto-login, and proficiency info |
phoneSpaces? | number | Number of concurrent phone interactions allowed |
messagingSpaces? | number | Number of concurrent messaging interactions allowed |
emailSpaces? | number | Number of concurrent email interactions allowed |
taskSpaces? | number | Number of concurrent task interactions allowed |
eliteExtension? | string | null | Elite Agent Extension |
eliteAgentId? | string | null | Elite Agent ID |
eliteSipAddress? | string | null | SIP Address |
eliteSbcGroupId? | string | null | SBC Group ID |
crmConfigurations? | unknown | CRM Configuration object |
infinityElements? | InfinityElement[] | App-level Infinity Elements assigned |
authToken? | string | Authentication token (JWT) using accessToken |
Type Aliases
CHANNEL_NAMES
type CHANNEL_NAMES = {
INTERACTION_STATUS_CHANGED: "interaction-status-changed";
INTERACTION_ENDED: "on-interaction-ended";
INTERACTION_ACCEPTED: "on-interaction-accepted";
INTERACTION_UPDATED: "on-interaction-updated";
CONSULT_STATUS_CHANGED: "consult-status-changed";
FEED_MESSAGE: "feed-message";
INTER_ELEMENT: "inter-element";
};
Properties
InteractionStatusChangedCallback()
type InteractionStatusChangedCallback = (payload: {
interactionId: string;
status: string;
}) => void;
Parameters
| Parameter | Type |
|---|---|
payload | { interactionId: string; status: string; } |
payload.interactionId | string |
payload.status | string |
Returns
void
InteractionEndedCallback()
type InteractionEndedCallback = (interactionId: string) => void;
Parameters
| Parameter | Type |
|---|---|
interactionId | string |
Returns
void
InteractionAcceptedCallback()
type InteractionAcceptedCallback = (interactionId: string) => void;
Parameters
| Parameter | Type |
|---|---|
interactionId | string |
Returns
void
InteractionUpdatedCallback()
type InteractionUpdatedCallback = (payload: {
interactionId: string;
event: "interaction.update";
payload: Interaction;
}) => void;
Parameters
| Parameter | Type |
|---|---|
payload | { interactionId: string; event: "interaction.update"; payload: Interaction; } |
payload.interactionId | string |
payload.event | "interaction.update" |
payload.payload | Interaction |
Returns
void
ConsultStatusChangedCallback()
type ConsultStatusChangedCallback = (payload: {
interactionId: string;
consultStatus: string;
consultParty?: string;
error?: string;
}) => void;
Parameters
| Parameter | Type |
|---|---|
payload | { interactionId: string; consultStatus: string; consultParty?: string; error?: string; } |
payload.interactionId | string |
payload.consultStatus | string |
payload.consultParty? | string |
payload.error? | string |
Returns
void
FeedMessageCallback()
type FeedMessageCallback = (message: Message) => void;
Parameters
| Parameter | Type |
|---|---|
message | Message |
Returns
void
ErrorCallback()
type ErrorCallback = (error: {
code: string;
message: string;
details?: unknown;
}) => void;
Parameters
| Parameter | Type |
|---|---|
error | { code: string; message: string; details?: unknown; } |
error.code | string |
error.message | string |
error.details? | unknown |
Returns
void
Variables
VERSION
Updated 10 days ago
