StaticretryManually triggers a WebSocket reconnection attempt, skipping any pending backoff delay.
Valid in two situations:
FAILED state. Use to offer a
"Retry" button once the agent acknowledges the failure.AWAITING_RECONNECTION backoff between automatic retry attempts.
Use to skip the remaining delay and reconnect immediately.If a manual retry is not allowed in the current
state — e.g. a reconnection attempt is already actively in progress (code ASE-1014)
// Skip backoff on each individual failed attempt
AvayaInfinityAgentSdk.subscribe(
WebSocketConnectionEventType.RECONNECTION_ATTEMPT_FAILED,
() => {
retryButton.disabled = false; // let the agent skip the wait
}
);
// Also enable after all retries are exhausted
AvayaInfinityAgentSdk.subscribe(
WebSocketConnectionEventType.CONNECTION_FAILED,
() => {
retryButton.disabled = false;
}
);
retryButton.addEventListener("click", () => {
try {
AvayaInfinityAgentSdk.retryWebSocketConnection();
} catch (err) {
console.error("Retry not available:", err);
}
});
StaticwebThe current WebSocket connection state.
Reflects real-time connectivity between the SDK and the Avaya platform. Subscribe to WebSocketConnectionEventType events for change notifications rather than polling this property.
The current WebSocketConnectionState
StaticsubscribeSubscribes to SDK events across all namespaces (sdk, user and all interactions).
This is a universal event listener that fires for any matching event, whether the event originates from the SDK, the user, or an interaction. Can be called before init - subscribe first to catch lifecycle events such as SdkEventType.SDK_INITIALIZED.
The specific event type to subscribe to
The event type to subscribe to
Callback function invoked when the event occurs
A handler ID that can be used to unsubscribe
StaticunsubscribeUnsubscribes from a previously subscribed SDK event.
The event type to unsubscribe from
The handler ID returned from subscribe
StaticversionThe current Agent SDK version.
StaticexportExports the SDK's in-memory log buffer as a JSON Blob.
The SDK continuously captures recent log entries (respecting the configured AvayaInfinityAgentSdkInitParams.logLevel) into a bounded in-memory ring buffer. This method returns a snapshot of that buffer wrapped in a versioned envelope, suitable for attaching to a support ticket.
The returned Blob has MIME type application/json. The SDK does NOT
trigger a download itself - the host application decides what to do with the
Blob (e.g. URL.createObjectURL + anchor click, or merge with another log
source). This makes it safe to call from embedded contexts (iframes, CRM
connectors) that may block synthetic download clicks.
This method is synchronous, side-effect-free, and never mutates the buffer - multiple calls return independent snapshots. It is callable across the entire SDK lifecycle, including before init and after destroy; the buffer is reset only on page reload.
A Blob of type application/json containing the log export envelope
const blob = AvayaInfinityAgentSdk.exportLogs();
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = `avaya-sdk-logs-${new Date().toISOString().replace(/:/g, "-")}.json`;
a.click();
URL.revokeObjectURL(url);
// Consume the export and append SDK entries to an existing log store.
// exportLogs() is a non-destructive snapshot, so it is safe to call
// repeatedly (e.g. each time a host log download is requested).
const blob = AvayaInfinityAgentSdk.exportLogs();
const exportData = JSON.parse(await blob.text()) as SdkLogExport;
existingLogs.push(...exportData.entries); // existingLogs: SdkLogEntry[]
StaticsetSets the capacity (maximum number of entries) of the in-memory log buffer captured for exportLogs, and returns the effective capacity that took effect.
The requested value is truncated to an integer and clamped to the range
[100, 5000]. A non-finite request (NaN)
falls back to the default of 2000;
±Infinity clamp to the range bounds. This method never throws for any
numeric argument - out-of-range or non-integer inputs are adjusted (and a
console warning is logged) rather than rejected. The returned number is the
actual capacity after truncation, clamping, and fallback.
Most-recent retention guarantee: when the new capacity is smaller than the current number of buffered entries, the most-recent entries are retained and the oldest are discarded. If you need older history, call exportLogs before reducing the capacity.
Like exportLogs, this is callable across the entire SDK lifecycle - including before init and after destroy - because the buffer is decoupled from the SDK lifecycle and reset only on page reload. The buffer can also be sized at startup via AvayaInfinityAgentSdkInitParams.logBufferCapacity.
The desired buffer capacity (entries). Truncated and clamped to [100, 5000].
The effective capacity after truncation, clamping, and NaN fallback.
StaticsetSets the active log level for the SDK. Affects all loggers created via
LoggerFactory — including those already in use.
Call this at any point in the SDK lifecycle (before init, after
destroy, or while running). Useful for raising verbosity to
LogLevel.DEBUG during a live incident and reverting once captured. The
initial level can also be set at startup via
AvayaInfinityAgentSdkInitParams.logLevel.
StatichandleHandles the OAuth callback by extracting the authorization code from the current URL and posting it back to the opener window.
Call this from a script on the page that the IdP redirects to after authentication (popup mode only).
StaticinitInitialize the SDK and authenticate the agent.
Performs authentication, establishes a connection with the server, and returns a
User object representing the authenticated agent.
The SDK transitions from UNINITIALIZED → INITIALIZING → INITIALIZED.
Behavior depends on initParams.oAuthMode:
init() must be called again
to complete authentication and return the UserOn success, fires SdkEventType.SDK_INITIALIZED.
On failure, fires SdkEventType.INITIALIZATION_FAILED and resets to UNINITIALIZED.
Configuration parameters for SDK initialization
A promise that resolves to the authenticated User instance
// Redirect mode - call once on page load; will redirect if not yet authenticated
const user = await AvayaInfinityAgentSdk.init({
avayaInfinityHost: "api.avayacloud.com",
clientId: "your-client-id",
oAuthRedirectUri: window.location.origin,
});
console.log("Signed in as:", user.userFullName);
// Popup mode - single call inside a click handler
loginButton.addEventListener("click", async () => {
const user = await AvayaInfinityAgentSdk.init({
avayaInfinityHost: "api.avayacloud.com",
clientId: "your-client-id",
oAuthRedirectUri: "https://your-app.com/callback.html",
oAuthMode: "popup",
});
console.log("Signed in as:", user.userFullName);
});
StaticdestroyDestroy the SDK instance and release all resources.
Logs the agent out from the Avaya platform, closes the connection with the server,
and clears all internal state.
The SDK transitions from INITIALIZED (or FAILED) → DESTROYING → UNINITIALIZED.
After this method resolves, init must be called again to use the SDK. On completion, fires SdkEventType.SDK_DESTROYED.
A promise that resolves when the SDK has been fully torn down
StaticsdkReturns the current SdkState of the SDK.
Use this to guard calls to init, destroy, or retryWebSocketConnection that are only valid in specific states.
The current SDK state
Main entry point for the Avaya Infinity Agent SDK.
AvayaInfinityAgentSdkis a static singleton class with all static methods. Call init once to authenticate and connect, then use the returned User object to manage agent state and interactions. Call destroy to tear everything down cleanly.SDK State Machine
The SDK transitions through the following states:
UNINITIALIZED- initial state; init may be calledINITIALIZING- init is in progress; wait for the returned promise to resolve before calling any other SDK methodsINITIALIZED- fully operational; destroy may be calledFAILED- WebSocket connection lost after all reconnect attempts; retryWebSocketConnection or destroy may be calledDESTROYING- destroy is in progressUse sdkState to read the current state at any time.
Lifecycle Events
Subscribe via subscribe to react to state transitions:
init()completed successfullyinit()threw an errordestroy()completed