ApplicationApiEvents

ApplicationApiEvents

Methods

(abstract) error(event) → {void}

Implement this callback to execute your code when an error occurs in the SDK. This unified error event captures all errors from different sources (REST API, WebSocket, hooks, SDK state, UI error messages). Use the source field to filter and handle specific error types.

Events can originate from:

  • SDK library (REST API validation, hook errors, SDK state errors)
  • Adapter/ADT (REST API failures, WebSocket errors, UI error messages)
applicationApi.subscribe({
    error: (event) => {
        console.error(`[${event.source}] ${event.errorMessage}`);

        switch (event.source) {
            case 'rest-api':
                // Handle REST API errors (from SDK or adapter)
                console.log('Status:', event.context.statusCode);
                break;
            case 'websocket':
                // Handle WebSocket errors
                console.log('Subscription:', event.context.subscriptionId);
                break;
            case 'hook':
                // Handle hook errors (SDK only)
                console.log('Hook:', event.context.hookName);
                break;
            case 'sdk':
                // Handle SDK state errors (SDK only)
                console.log('Method params:', event.context.methodParams);
                break;
            case 'ui-message':
                // Handle UI error messages (adapter only, displayType: 'error')
                console.log('Message:', event.context.messageText);
                break;
        }
    }
});
Parameters:
Name Type Description
event ErrorEvent

Error event data

Name Type Description
timestamp number

Unix timestamp when error occurred

source ErrorEventSource

Error source: 'rest-api' | 'websocket' | 'hook' | 'sdk' | 'ui-message'

errorCode string

Error code

errorMessage string

Error description

apiName string

Which API triggered the error (e.g., 'interactionApi', 'applicationApi')

methodName string | null

Which SDK method triggered the error (null for adapter-originated errors)

context object

Source-specific additional context (varies by source type)

Returns:
Type:
void

(abstract) loginStateChanged(params) → {void}

Implement this callback to execute your code when login state is changed. Agent login consists of some steps following in particular order. You can use this event to detect the state. For example, you can get application configuration in 'WORKING' state only.

Parameters:
Name Type Description
params object
Name Type Description
state LoginState

Login state

Returns:
Type:
void

(abstract) sessionInitialized() → {void}

Implement this callback to execute your code when web socket initialization complete.

Returns:
Type:
void

(abstract) uiNotification(notification) → {void}

Implement this callback to execute your code when UI notifications (info/success messages) are displayed.

applicationApi.subscribe({
    uiNotification: (notification) => {
        console.log(`[${notification.displayType}] ${notification.messageText}`);
    }
});
Parameters:
Name Type Description
notification object

Notification data

Name Type Description
displayType string

Display type: 'info' or 'success'

messageText string

Message text displayed to user

contextCode string | null

Context code if available

apiUrl string | null

API URL if available

args array | null

Arguments if available

format string | null

Format if available

Returns:
Type:
void