amazon-connect-streams
Version:
Amazon Connect Streams Library
1,396 lines (1,184 loc) • 112 kB
TypeScript
// Type definitions for Amazon Connect Streams API 1.4
// Project: https://github.com/aws/amazon-connect-streams
// Definitions by: Andy Hopper <https://github.com/andyhopp>, Marco Gonzalez <https://github.com/marcogrcr>
// TypeScript Version: 3.0
declare namespace connect {
/**
* A callback to receive `Agent` API object instances.
*
* @param agent The `Agent` API object instance.
*/
type AgentCallback = (agent: Agent) => void;
interface FailoverDetectedData {
nextActiveRegion: string;
}
type OnFailoverDetectedCallback = (data: FailoverDetectedData) => void;
/**
* A callback to receive `AgentMutedStatus` API object instances.
*
* @param agentMutedStatus The `AgentMutedStatus` API object instance.
*/
type AgentMutedStatusCallback = (agentMutedStatus: AgentMutedStatus) => void;
/**
* A callback to receive an agent state change event.
*
* @param agentStateChange The agent state change event.
*/
type AgentStateChangeCallback = (agentStateChange: AgentStateChange) => void;
/**
* The four possible connection health states for the agent's connection
* to Amazon Connect backend services.
*/
type NetworkConnectionStatus = "connected" | "connecting" | "disconnected" | "failed";
/**
* Enum-like constant object for referencing network connection status values.
* Mirrors the runtime `connect.NetworkConnectionStatus` object defined in `api.js`.
*/
const NetworkConnectionStatus: {
readonly CONNECTED: "connected";
readonly CONNECTING: "connecting";
readonly DISCONNECTED: "disconnected";
readonly FAILED: "failed";
};
/**
* Payload delivered to `onNetworkConnectionStatusChanged` subscribers when the agent's
* connection health state transitions.
*/
interface NetworkConnectionStatusChanged {
/** The new connection health status. */
status: NetworkConnectionStatus;
/** Epoch milliseconds when the status transition occurred. */
timestamp: number;
}
/**
* A callback invoked whenever the agent's connection health state changes.
*
* @param event The `NetworkConnectionStatusChanged` payload describing the new state.
*/
type NetworkConnectionStatusChangedCallback = (event: NetworkConnectionStatusChanged) => void;
/**
* A callback to receive 'UserMediaDeviceChange' API object instances
*
* @param userMediaDeviceChange The 'UserMediaDeviceChange' API object instance
*/
type UserMediaDeviceChangeCallback = (userMediaDeviceChange: UserMediaDeviceChange) => void;
/**
* A callback to receive 'UserBackgroundBlurChange' API object instances
*
* @param UserBackgroundBlurChange The 'UserBackgroundBlurChange' API object instance
*/
type UserBackgroundBlurChangeCallback = (UserBackgroundBlurChange: UserBackgroundBlurChange) => void;
/**
* A callback to receive 'VoiceEnhancementModeChange' API object instances
*
* @param VoiceEnhancementModeChange The 'VoiceEnhancementModeChange' API object instance
*/
type VoiceEnhancementModeChangeCallback = (voiceEnhancementModeChange: VoiceEnhancementModeChange) => void;
/**
* A callback to receive `SoftphoneError` errors.
*
* @param error A `SoftphoneError` error.
*/
type SoftphoneErrorCallback = (error: SoftphoneError) => void;
/**
* A callback to receive softphone session initialization events.
*
* @param session The softphone session object.
*/
type SoftphoneSessionCallback = (session: unknown) => void;
/**
* WebSocket manager interface for chat integration.
*/
interface WebSocketManager {
connect(): void;
disconnect(): void;
send(message: unknown): void;
onMessage(callback: (message: unknown) => void): void;
onOpen(callback: () => void): void;
onClose(callback: () => void): void;
onError(callback: (error: Error) => void): void;
}
type SessionExpirationInformation = {
expiration: number;
};
/**
* Callback params for onSessionExtensionError
*
* isWarningActive: the agent has been inactive for X minutes and
* the warning modal is now present
* errorDetails: details regarding the failure
*/
type SessionExtensionErrorData = {
isWarningActive: boolean;
errorDetails: Record<string, unknown>;
}
/**
* A callback to receive `SessionExpirationInformation` data
*/
type OnExpirationWarningCallback = (sessionExpirationInformation: SessionExpirationInformation) => void;
type OnExpirationWarningClearedCallback = () => void;
type OnSessionExtensionErrorCallback = (SessionExtensionErrorData: SessionExtensionErrorData) => void;
/**
* Subscribe a method to be called when the agent is initialized.
* If the agent has already been initialized, the call is synchronous and the callback is invoked immediately.
* Otherwise, the callback is invoked once the first agent data is received from upstream.
* This callback is provided with an `Agent` API object, which can also be created at any time after initialization is complete via `new connect.Agent()`.
*
* @param callback A callback that will receive an `Agent` API object instance.
*/
function agent(callback: AgentCallback): Subscription;
/**
* A callback to receive `Contact` API object instances.
*
* @param contact A `Contact` API object instance.
*/
type ContactCallback = (contact: Contact) => void;
/**
* A callback to receive `ViewContactEvent` objects.
*
* @param contact A `ViewContactEvent` object.
*/
type ViewContactCallback = (contact: ViewContactEvent) => void;
/**
* A callback with no arguments.
*/
type Callback = () => void;
/**
* Subscribe a method to be called for each newly detected agent contact.
* Note that this function is not only for incoming contacts, but for contacts which already existed when Streams was initialized, such as from a previous agent session.
* This callback is provided with a `Contact` API object for this contact. `Contact` API objects can also be listed from the `Agent` API by calling `agent.getContacts()`.
*
* @param callback A callback that will receive an `Contact` API object instance.
*/
function contact(callback: ContactCallback): Subscription;
/**
* Subscribe a method to be called when the WebSocket connection fails to initialize.
* If the WebSocket has already failed at least once in initializing, the call is
* synchronous and the callback is invoked immediately. Otherwise, the callback is
* invoked once the first attempt to initialize fails.
*
* @param callback A callback with no arguments
*/
function onWebsocketInitFailure(callback: Callback): void;
/**
* A useful utility function for creating callback closures that bind a function to an object instance.
*
* @param scope The instance object to be set as the scope of the function.
* @param method The method to be encapsulated.
*/
function hitch<T extends (...args: any[]) => any>(scope: object, method: T): T;
type StorageAccessCallbackData = {
data: {
hasAccess?: boolean;
[key: string]: unknown;
},
event: string
}
type StorageAccessCallback = (option: StorageAccessCallbackData) => void;
interface StorageAccessCallbacks {
onInit?: StorageAccessCallback
onRequest?: StorageAccessCallback
onDeny?: StorageAccessCallback
onGrant?: StorageAccessCallback
}
interface StorageAccess {
onRequest(options: StorageAccessCallbacks): { unsubscribe: Function }
}
const storageAccess: StorageAccess;
/**
* EventBus interface for handling events and subscriptions
*/
interface EventBus {
/** Subscribe to an event with a callback function */
subscribe(eventName: string, callback: Function): Subscription;
/** Subscribe to all events with a callback function */
subscribeAll(callback: Function): Subscription;
/** Trigger an event with optional data */
trigger(eventName: string, data?: unknown): void;
/** Unsubscribe all listeners */
unsubscribeAll(): void;
}
interface Core {
/**
* Integrates with Amazon Connect by loading the pre-built CCP located at `ccpUrl` into an iframe and placing it into the `container` provided.
* API requests are funneled through this CCP and agent and contact updates are published through it and made available to your JS client code.
*
* @param container The DOM element to place the CCP.
* @param options The CCP init options.
*/
initCCP(container: HTMLElement, options: InitCCPOptions): void;
/**
* Gets the global event bus for subscribing to and triggering events.
* This is the main event system used throughout Amazon Connect Streams.
*/
getEventBus(): EventBus;
/**
* Subscribes a callback function to be called when the agent authorization api succeeds.
*/
onAuthorizeSuccess(f: Function): Subscription;
/**
* Subscribes a callback function to be called when the connect.EventType.IFRAME_RETRIES_EXHAUSTED event is triggered.
*
* @param f The callback function.
*/
onIframeRetriesExhausted(f: Function): Subscription;
/**
* Subscribes a callback function to be called when multiple authorization-type CTI API failures have happened.
* After this event occurs, streams will not try to re-authenticate the user when more CTI API authorization-type (401) failures happen.
* Note that CTI APIs are the agent, contact, and connection apis (specifically, those listed under the `connect.ClientMethods` enum).
* Therefore, it may be prudent to indicate to the agent that there is a problem related to authorization.
*
* @param f The callback function.
*/
onCTIAuthorizeRetriesExhausted(f: Function): Subscription;
/**
* Subscribes a callback function to be called when multiple agent authorization api failures have happened.
* After this event occurs, streams will not try to redirect the user to login when more agent authorization api failures happen.
* Therefore, it may be prudent to indicate to the agent that there is a problem related to authorization.
*
* @param f The callback function.
*/
onAuthorizeRetriesExhausted(f: Function): Subscription;
/**
* Terminates Amazon Connect Streams. Removing any subscription methods that have been called.
* The CCP iframe will not be removed though, so you'll have to manually remove it.
*/
terminate(): void;
/**
* Changes the currently selected contact in the CCP user interface.
* Useful when an agent handles more than one concurrent chat.
*
* @param contactId The contact ID.
*/
viewContact(contactId: string): void;
/**
* Subscribes a callback that starts whenever the currently selected contact on the CCP changes.
* The callback is called when the contact changes in the UI (i.e. via `click` events) or via `connect.core.viewContact()`.
*
* @param callback A callback that will receive a `ViewContactEvent` object.
*/
onViewContact(callback: ViewContactCallback): Subscription;
/**
* Subscribes a callback that starts whenever authentication fails (e.g. SAML authentication).
*
* @param callback A callback that will start whenever authentication fails.
*/
onAuthFail(callback: SuccessFailCallback): Subscription;
/**
* Subscribes a callback that starts whenever authorization fails (i.e. access denied).
*
* @param callback A callback that will start whenever access is denied.
*/
onAccessDenied(callback: SuccessFailCallback): Subscription;
/**
* Gets the `WebSocket` manager.
* This method is only used when integrating with `amazon-connect-chatjs`.
*/
getWebSocketManager(): WebSocketManager;
/**
* Subscribes a callback that starts whenever a new webrtc session is created. Used for handling the rtc session stats.
*
* @param callback A callback that will start whenever a new webrtc session is created.
*/
onSoftphoneSessionInit(callback: SoftphoneSessionCallback): Subscription;
/**
* Subscribes a callback that executes when the CCP initialization is completed.
*
* @param callback A callback that will execute when the CCP initialization is completed.
*/
onInitialized(callback: Callback): Subscription;
/**
* Returns a promise that is resolved with the list of media devices from iframe.
*
* @param timeout A timeout for the request in milliseconds.
*/
getFrameMediaDevices(timeout: number): Promise<MediaDeviceInfo[]>;
/**
* Global upstream conduit for external use.
*
*/
upstream?: object | null;
/**
* Configuration to be passed to SDK Client
*
*/
getSDKClientConfig(): { provider: unknown };
}
interface GlobalResiliency {
/**
* Subscribes a callback function to be called when a failover is pending, but has not yet been completed.
*
* @param f The callback function.
*/
onFailoverPending(f: Function): Subscription;
/**
* Subscribes a callback function to be called when a failover has been detected.
*
* @param callback A callback that will receive a `FailoverDetectedData` object.
*/
onFailoverDetected(callback: OnFailoverDetectedCallback): Subscription;
/**
* Subscribes a callback function to be called when the failover to another region has completed.
*
* @param f The callback function.
*/
onFailoverCompleted(f: Function): Subscription;
/**
* Subscribes a callback function to be called when there is an error setting up Global Resiliency
*
* @param f The callback function.
*/
onConfigureError(f: Function): Subscription;
/**
* Get the active region for Global Resiliency, i.e. 'us-west-2'
*
*/
getActiveRegion(): String;
}
const globalResiliency: GlobalResiliency;
enum EventType {
ACKNOWLEDGE = 'acknowledge',
ACK_TIMEOUT = 'ack_timeout',
INIT = 'init',
API_REQUEST = 'api_request',
API_RESPONSE = 'api_response',
AUTH_FAIL = 'auth_fail',
ACCESS_DENIED = 'access_denied',
CLOSE = 'close',
CONFIGURE = 'configure',
LOG = 'log',
MASTER_REQUEST = 'master_request',
MASTER_RESPONSE = 'master_response',
SYNCHRONIZE = 'synchronize',
TERMINATE = 'terminate',
TERMINATED = 'terminated',
SEND_LOGS = 'send_logs',
RELOAD_AGENT_CONFIGURATION = 'reload_agent_configuration',
BROADCAST = 'broadcast',
API_METRIC = 'api_metric',
CLIENT_METRIC = 'client_metric',
SOFTPHONE_STATS = 'softphone_stats',
SOFTPHONE_REPORT = 'softphone_report',
CLIENT_SIDE_LOGS = 'client_side_logs',
SERVER_BOUND_INTERNAL_LOG = 'server_bound_internal_log',
MUTE = 'mute',
IFRAME_STYLE = 'iframe_style',
IFRAME_RETRIES_EXHAUSTED = 'iframe_retries_exhausted',
UPDATE_CONNECTED_CCPS = 'update_connected_ccps',
OUTER_CONTEXT_INFO = 'outer_context_info',
MEDIA_DEVICE_REQUEST = 'media_device_request',
MEDIA_DEVICE_RESPONSE = 'media_device_response',
TAB_ID = 'tab_id',
AUTHORIZE_SUCCESS = 'authorize_success',
AUTHORIZE_RETRIES_EXHAUSTED = 'authorize_retries_exhausted',
CTI_AUTHORIZE_RETRIES_EXHAUSTED = 'cti_authorize_retries_exhausted',
CLICK_STREAM_DATA = 'click_stream_data',
SET_QUICK_GET_AGENT_SNAPSHOT_FLAG = 'set_quick_get_agent_snapshot_flag',
API_PROXY = 'api_proxy',
API_PROXY_REQUEST = 'api_proxy_request',
API_PROXY_RESPONSE = 'api_proxy_response'
}
const core: Core;
interface AgentApp {
/** Alias for connect.core.initCCP */
initCCP(container: HTMLElement, options: InitCCPOptions): void;
/** Waits for CCP to load to begin iframe communication. */
initAppCommunication(iframeId: string, endpoint: string): void;
/** Registers the app to the registry and initializes it. */
initApp(appName: string, containerId: string, appUrl: string, config?: AppOptions): void;
/** Destoys the app by calling the destroy method defined in the app registry. */
stopApp(): void;
/** Memoizes app data along with start and stop functions. */
AppRegistry: AppRegistry;
}
const agentApp: AgentApp;
interface AppOptions {
/** Optional CCP configuration that overrides and gets merged with defaults. */
ccpParams?: OptionalInitCCPOptions;
/** Optional CustomViews configuration */
customViewsParams?: OptionalCustomViewsOptions;
/** Optional inline styling for the app iframe. */
style?: string;
}
interface AppRegistry {
/** Saves app data to memory. */
register(appName: string, config: AppRegistryOptions, containerDOM: HTMLElement): void;
/** Initializes the app by calling the init method defined in the creator. */
start(appName: string, creator: AppCreator): void;
/** Destoys the app by calling the destroy method defined in the creator. */
stop(): void;
}
type AppCreator = (moduleData: AppData) => AppMethods;
type AppData = {
containerDOM: HTMLElement;
endpoint: string;
style?: string;
instance?: AppMethods;
}
interface AppMethods {
init(): void;
destroy(): void;
}
interface AppRegistryOptions {
/** This is the page you would normally navigate to in order to use the app in a standalone page. */
endpoint: string;
/** An optional string to supply inline styling for the iframe. */
style?: string;
}
interface ViewContactEvent {
/** The ID of the viewed contact. */
contactId: string;
}
type StorageAccessParameters = {
/** Defines whether to use a customized request access banner or default connect branded banner*/
mode?: 'default' | 'custom';
/** opt out from storage access flow */
canRequest?: boolean;
/** incase of CCP URL being the SSO URL, use this to pass the connect instance URL, example https://test.my.connect.aws, where test being the instance alias */
instanceUrl?: string;
/** customize style of the custom request access/deny banner, only works for mode "custom" */
style?: {
'font-family': string;
'primary-color': string;
'primary-button-hover-color': string;
'link-color': string;
'banner-box-shadow': string;
'banner-margin': string;
'border-radius': string;
'banner-header-color': string;
'banner-title-color': string;
'banner-request-access-description-color': string;
'banner-request-deny-description-color': string;
'banner-request-access-background': string;
'banner-request-deny-background': string;
'banner-icon-display': string;
'banner-request-access-icon-color': string;
'banner-request-deny-icon-color': string;
'line-height': string;
'header-font-size': string;
'bold-font-weight': string;
'banner-description-font-size': string;
};
/** Customize messaging on the request/deny banners */
custom?: {
/**
* provides users the option to specify whether or not to hide CCP Iframe upon granting access when using custom mode
* @default true
*/
hideCCP?: boolean;
header?: string;
title?: string;
accessBannerDescription?: string;
denyBannerDescription?: string;
accessBannerButtonText?: string;
denyBannerButtonText?: string;
accessBannerLearnMoreUrl?: string;
denyBannerLearnMoreUrl?: string;
accessBannerLearnMoreText?: string;
denyBannerLearnMoreText?: string;
// pop up customization
popupTitle?: string;
popupBannerDescription?: string;
popupBannerLearnMoreText?: string;
popupBannerButtonText?: string;
// popup prompt customization
promptBannerTitle?: string;
promptBannerDescription?: string;
promptBannerButtonText?: string;
};
};
interface SoftPhoneOptions {
/**
* Normally, the softphone microphone and speaker components are not allowed to be hosted in an iframe.
* This is because the softphone must be hosted in a single window or tab.
* The window hosting the softphone session must not be closed during the course of a softphone call or the call will be disconnected.
* If `allowFramedSoftphone` is `true`, the softphone components will be allowed to be hosted in this window or tab.
*/
readonly allowFramedSoftphone?: boolean;
/** This option allows you to completely disable the built-in ringtone audio that is played when a call is incoming. */
readonly disableRingtone?: boolean;
/** If the ringtone is not disabled, this allows for overriding the ringtone with any browser-supported audio file accessible by the user. */
readonly ringtoneUrl?: string;
/** Disable Echo Cancellation */
readonly disableEchoCancellation?: boolean;
/** Disable storing softphone parameters in local storage */
readonly disableStoringParamsInLocalStorage?: boolean;
/**
* Currently video call can only be in one single window or tab.
* If `allowFramedVideoCall` is true, the Contact Control Panel will handle video calling in this window or tab.
* @default false
*/
readonly allowFramedVideoCall?: boolean;
/**
* Currently it is recommended to enable screen share button on only one CCP in one single window or tab.
* If `allowFramedScreenSharing` is true, the Contact Control Panel will display the screen share button on that window or tab.
* @default false
*/
readonly allowFramedScreenSharing?: boolean;
/**
* If true, when agent clicks on screen sharing button in embedded CCP, it will launch the screen sharing app in a
* separate window.
* @default false
*/
readonly allowFramedScreenSharingPopUp?: boolean;
/**
* VDI platform type for virtual desktop interface integrations.
* Supported values: `VDIPlatformType.CITRIX`, `VDIPlatformType.CITRIX_413`, `VDIPlatformType.AWS_WORKSPACE`, `VDIPlatformType.OMNISSA`.
*/
readonly VDIPlatform?: string;
/**
* If `true` or not provided, CCP will capture the agent’s browser microphone media stream before the contact arrives to reduce the call setup latency.
* If `false`, CCP will only capture agent media stream after the contact arrives.
* @default true
*/
readonly allowEarlyGum?: boolean;
/**
* If `true`, enables extended persistent connection support when using `RtcPeerConnectionManagerV2`.
* @default false
*/
readonly allowExtendedPersistentConnection?: boolean;
}
interface ChatOptions {
/** This option allows you to completely disable the built-in ringtone audio that is played when a chat is incoming. */
readonly disableRingtone?: boolean;
/** If the ringtone is not disabled, this allows for overriding the ringtone with any browser-supported audio file accessible by the user. */
readonly ringtoneUrl?: string;
}
interface TaskOptions {
/** This option allows you to completely disable the built-in ringtone audio that is played when a task is incoming. */
readonly disableRingtone?: boolean;
/** If the ringtone is not disabled, this allows for overriding the ringtone with any browser-supported audio file accessible by the user. */
readonly ringtoneUrl?: string;
}
interface AutoAcceptToneOption {
/** This option allows you to completely disable the built-in audio that is played when a contact is auto-accepted. */
readonly disableRingtone?: boolean;
/** If the ringtone is not disabled, this allows for overriding the ringtone with any browser-supported audio file accessible by the user. */
readonly ringtoneUrl?: string;
}
interface LoginOptions {
/*
* Whether to open the login popup again after the agent logs out.
*/
disableAuthPopupAfterLogout?: boolean,
/*
* Whether to auto close the login prompt.
*/
autoClose?: boolean,
/*
* The height of the login prompt window.
*/
height?: number,
/*
* The width of the login prompt window.
*/
width?: number,
/*
* The top of the login prompt window.
*/
top?: number,
/*
* The left of the login prompt window.
*/
left?: number
}
interface PageOptions {
/**
* If `true`, the settings tab will display a section for configuring audio input and output devices for the agent's local machine.
* If `false`, or if `pageOptions` is not provided, the agent will not be able to change audio device settings from the settings tab.
*/
readonly enableAudioDeviceSettings?: boolean;
/**
* If `true`, the settings tab will display a section for configuring video input devices for the agent's local machine.
* If `false`, or if `pageOptions` is not provided, the agent will not be able to change video device settings from the settings tab.
*/
readonly enableVideoDeviceSettings?: boolean;
/**
* If `true`, or if `pageOptions` is not provided, the settings tab will display a section for configuring the agent's phone type and deskphone number.
* If `false`, the agent will not be able to change the phone type or deskphone number from the settings tab.
*/
readonly enablePhoneTypeSettings?: boolean;
/** Specifies whether to show the inactivity modal in embedded CCP use cases.
* @default true
*/
readonly showInactivityModal?: boolean;
}
interface InitCCPOptions {
/**
* The URL of the CCP.
* This is the page you would normally navigate to in order to use the CCP in a standalone page, it is different for each instance.
*/
readonly ccpUrl: string;
/**
* The URL for the secondary region of the CCP in your traffic distribution group.
* Required when `enableGlobalResiliency` is `true`.
*/
readonly secondaryCCPUrl?: string;
/**
* Set to `true` to activate the Global Resiliency feature in Streams.
* When enabled, `secondaryCCPUrl` and `loginUrl` must also be provided.
*/
readonly enableGlobalResiliency?: boolean;
/**
* Amazon connect instance region. Only required for chat channel.
* @example "us-west-2"
*/
readonly region?: string;
/**
* Set to `false` to disable the login popup which is shown when the user's authentication expires.
* @default true
*/
readonly loginPopup?: boolean;
/**
* Options to open login popup in a new window instead of a new tab. If loginPopup is set to
* `false`, these options will be ignored.
*/
readonly loginOptions?: LoginOptions;
/**
* Set to `true` in conjunction with the `loginPopup` parameter to automatically close the login
* Popup window once the authentication step has completed. If the login page opened in a new
* tab, this parameter will also auto-close that tab.
* @default false
*/
readonly loginPopupAutoClose?: boolean;
/** Allows custom URL to be used to initiate the ccp, as in the case of SAML authentication. */
readonly loginUrl?: string;
/** Allows you to specify some settings surrounding the softphone feature of Connect. */
readonly softphone?: SoftPhoneOptions;
/** Allows you to specify ringtone settings for Chat. */
readonly chat?: ChatOptions;
/** Allows you to specify ringtone settings for Task. */
readonly task?: TaskOptions;
/** Allows you to specify ringtone settings for AutoAccept enabled contacts. */
readonly autoAcceptTone?: AutoAcceptToneOption;
/**
* Allows you to customize the title attribute of the CCP iframe.
* @example "Contact Control Panel"
*/
readonly iframeTitle?: string;
/** Allows you to configure which configuration sections are displayed in the settings tab. **/
readonly pageOptions?: PageOptions;
/** A timeout in ms that indicates how long streams will wait for the iframed CCP to respond to its SYNCHRONIZE event emissions. These happen continuously from the first time initCCP is called. They should only appear when there is a problem that requires a refresh or a re-login */
readonly ccpAckTimeout?: number;
/** A timeout in ms that indicates how long streams will wait to send a new SYNCHRONIZE event to the iframed CCP. These happens continuously from the first time initCCP is called. */
readonly ccpSynTimeout?: number;
/** A timeout in ms that indicates how long streams will wait for the initial ACKNOWLEDGE event from the shared worker while the CCP is still standing itself up. */
readonly ccpLoadTimeout?: number;
/** used for request storage access implementations */
readonly storageAccess?: StorageAccessParameters;
/** used to associate an existing AmazonConnectProvider */
readonly provider?: InstanceType<{ new (...args: any[]): any }>;
/**
* Logging configuration options for Amazon Connect Streams.
*
* @example
* logConfig: {
* logLevel: connect.LogLevel.ERROR, // File logging level
* echoLevel: connect.LogLevel.INFO // Console logging level
* }
*/
readonly logConfig?: {
/**
* The log level for file logging (available in download log file).
* Must be a valid LogLevel enum value.
* If not specified, defaults to LogLevel.INFO.
*
* @example connect.LogLevel.ERROR
*/
readonly logLevel?: LogLevel;
/**
* The echo level for console logging output.
* Must be a valid LogLevel enum value.
* If not specified, defaults to LogLevel.WARN.
*
* @example connect.LogLevel.INFO
*/
readonly echoLevel?: LogLevel;
};
/**
* Plugin functions to extend the AmazonConnectProvider capabilities.
*
* Plugins are functions that receive the provider's prototype and can add new methods,
* modify existing ones, or enhance functionality. Each plugin function is called during
* provider initialization and can return the modified prototype or undefined.
*
* Can be a single plugin function or an array of plugin functions.
*
* @example
* // Single plugin
* plugins: (prototype) => {
* prototype.customMethod = () => "Hello from plugin";
* return prototype;
* }
*
* @example
* // Multiple plugins
* plugins: [
* (prototype) => { prototype.feature1 = () => "Feature 1"; },
* (prototype) => { prototype.feature2 = () => "Feature 2"; }
* ]
*/
readonly plugins?: (providerPrototype: any) => any | ((providerPrototype: any) => any)[];
}
interface TerminateCustomViewOptions {
/** Will deconstruct the application iframe and clear its id in the AppRegistry, freeing the namespace of the applications id. Default is true */
readonly resolveIframe: boolean;
/** Timeout in ms. The amount of time to wait for the DOM to resolve and clear the iframe if resolveIframe is true. Default is 5000 */
readonly timeout?: number;
/** Whether or not to hide the iframe while it waits resolve and clear the DOM. Default is true. */
readonly hideIframe?: boolean;
}
interface OptionalCustomViewsOptions {
/**
* Attaches the contact to the customviews application, can be a contact object or contactId.
* WARNING: IF YOU USE A CONTACTID OR DO NOT PROVIDE THIS PARAMETER AT ALL THEN DISABLEAUTODESTROY IS TRUE BY DEFAULT AND YOU MUST USE
* CONNECT.CORE.TERMINATECUSTOMVIEW() TO END THE LIFECYCLE OF THE CUSTOMVIEWS BEFORE CLOSING THE IFRAME.
*/
readonly contact?: Contact | string;
/**
* Designate the Step by step guide's contactFlowId that the CustomViews application will launch.
*/
readonly contactFlowId?: string
/**
* Attaches a suffix to the customviews application iframe id. This id will be formed as customviews{iframeSuffix}.
* Useful for instantiating multiple customviews applications in a single page.
*/
readonly iframeSuffix?: string;
/**
* Disables automatic teardown of the CustomViews-launched contact and the corresponding CustomViews widget
* WARNING: NOT PROPERLY TERMINATING A CUSTOMVIEW WITH CONNECT.CORE.TERMINATECUSTOMVIEW()
* BEFORE DESTROYING YOUR IFRAME CONTEXT WILL CAUSE THE CUSTOMVIEW TO COUNT AGAINST YOUR CHAT CONCURRENCY
* UNTIL IT IS TERMINATED BY THE DEFAULT CHAT TIMEOUT.
*/
readonly disableAutoDestroy?: boolean;
/**
* Options for adjusting the the auto-teardown behavior around the iframe
*/
readonly terminateCustomViewOptions?: TerminateCustomViewOptions
/** deduplicate (boolean, default: true):
* When true, enables deduplication by using the contact's current state (e.g., 'CONNECTED', 'ACW')—or 'DEFAULT' if unavailable—as the identifier
* in duplicateCustomViewsAppId. This ensures only one guide instance per contact state. When false, bypasses deduplication by assigning a special
* identifier, resulting in a fresh guide instantiation on every call.
*/
readonly deduplicate?: boolean
}
interface OptionalInitCCPOptions {
/**
* Amazon connect instance region. Only required for chat channel.
* @example "us-west-2"
*/
readonly region?: string;
/**
* Set to `false` to disable the login popup which is shown when the user's authentication expires.
* @default true
*/
readonly loginPopup?: boolean;
/**
* Options to open login popup in a new window instead of a new tab. If loginPopup is set to
* `false`, these options will be ignored.
*/
readonly loginOptions?: LoginOptions;
/**
* Set to `true` in conjunction with the `loginPopup` parameter to automatically close the login
* Popup window once the authentication step has completed. If the login page opened in a new
* tab, this parameter will also auto-close that tab.
* @default false
*/
readonly loginPopupAutoClose?: boolean;
/** Allows custom URL to be used to initiate the ccp, as in the case of SAML authentication. */
readonly loginUrl?: string;
/** Allows you to specify some settings surrounding the softphone feature of Connect. */
readonly softphone?: SoftPhoneOptions;
/** Allows you to specify ringtone settings for Chat. */
readonly chat?: ChatOptions;
/** Allows you to configure which configuration sections are displayed in the settings tab. */
readonly pageOptions?: PageOptions;
/** A timeout in ms that indicates how long streams will wait for the iframed CCP to respond to its SYNCHRONIZE event emissions. These happen continuously from the first time initCCP is called. They should only appear when there is a problem that requires a refresh or a re-login */
readonly ccpAckTimeout?: number;
/** A timeout in ms that indicates how long streams will wait to send a new SYNCHRONIZE event to the iframed CCP. These happens continuously from the first time initCCP is called. */
readonly ccpSynTimeout?: number;
/** A timeout in ms that indicates how long streams will wait for the initial ACKNOWLEDGE event from the shared worker while the CCP is still standing itself up. */
readonly ccpLoadTimeout?: number;
}
/** This enumeration lists the different types of agent states. */
enum AgentStateType {
/** The agent state hasn't been initialized yet. */
INIT = "init",
/** The agent is in a state where they can be routed contacts. */
ROUTABLE = "routable",
/** The agent is in a state where they cannot be routed contacts. */
NOT_ROUTABLE = "not_routable",
/** The agent is offline. */
OFFLINE = "offline",
/** The agent is in a system state. */
SYSTEM = "system",
/** The agent is in a error state. */
ERROR = "error",
}
enum AgentAvailStates {
INIT = "Init",
BUSY = "Busy",
AFTER_CALL_WORK = "AfterCallWork",
CALLING_CUSTOMER = "CallingCustomer",
DIALING = "Dialing",
JOINING = "Joining",
PENDING_AVAILABLE = "PendingAvailable",
PENDING_BUSY = "PendingBusy",
}
enum AgentErrorStates {
ERROR = "Error",
AGENT_HUNG_UP = "AgentHungUp",
BAD_ADDRESS_AGENT = "BadAddressAgent",
BAD_ADDRESS_CUSTOMER = "BadAddressCustomer",
DEFAULT = "Default",
FAILED_CONNECT_AGENT = "FailedConnectAgent",
FAILED_CONNECT_CUSTOMER = "FailedConnectCustomer",
INVALID_LOCALE = "InvalidLocale",
LINE_ENGAGED_AGENT = "LineEngagedAgent",
LINE_ENGAGED_CUSTOMER = "LineEngagedCustomer",
MISSED_CALL_AGENT = "MissedCallAgent",
MISSED_CALL_CUSTOMER = "MissedCallCustomer",
MULTIPLE_CCP_WINDOWS = "MultipleCcpWindows",
REALTIME_COMMUNICATION_ERROR = "RealtimeCommunicationError",
}
enum AgentEvents {
INIT = 'init',
UPDATE = 'update',
REFRESH = 'refresh',
ROUTABLE = 'routable',
NOT_ROUTABLE = 'not_routable',
PENDING = 'pending',
CONTACT_PENDING = 'contact_pending',
OFFLINE = 'offline',
ERROR = 'error',
SOFTPHONE_ERROR = 'softphone_error',
WEBSOCKET_CONNECTION_LOST = 'websocket_connection_lost',
WEBSOCKET_CONNECTION_GAINED = 'websocket_connection_gained',
STATE_CHANGE = 'state_change',
ACW = 'acw',
MUTE_TOGGLE = 'mute_toggle',
LOCAL_MEDIA_STREAM_CREATED = 'local_media_stream_created',
ENQUEUED_NEXT_STATE = 'enqueued_next_state',
}
/** This enumeration lists the different types of endpoints. */
enum EndpointType {
/** An endpoint pointing to a phone number. */
PHONE_NUMBER = "phone_number",
/** An endpoint pointing to an agent in the same instance. */
AGENT = "agent",
/** An endpoint pointing to a queue call flow in the same instance. */
QUEUE = "queue",
}
enum ReferenceType {
URL = "URL",
}
/** Lists the different types of connections. */
enum ConnectionType {
/** The agent connection. */
AGENT = "agent",
/** An inbound connection, usually representing an inbound call. */
INBOUND = "inbound",
/** An outbound connection, representing either an outbound call or additional connection added to the contact. */
OUTBOUND = "outbound",
/** A special connection type representing a manager listen-in session. */
MONITORING = "monitoring",
}
/** An enumeration listing the different states that a connection can have. */
enum ConnectionStateType {
/** The connection has not yet been initialized. */
INIT = "init",
/** The connection is being initialized. */
CONNECTING = "connecting",
/** The connection is connected to the contact. */
CONNECTED = "connected",
/** The connection is connected but on hold. */
HOLD = "hold",
/** The connection is no longer connected to the contact. */
DISCONNECTED = "disconnected",
/** The connection is in silent monitor mode */
SILENT_MONITOR = "silent_monitor",
/** The connection is in barge mode */
BARGE = "barge"
}
enum ContactEvents {
INIT = "init",
REFRESH = "refresh",
DESTROYED = "destroyed",
INCOMING = "incoming",
PENDING = "pending",
CONNECTING = "connecting",
CONNECTED = "connected",
MISSED = "missed",
ACW = "acw",
VIEW = "view",
ENDED = "ended",
ERROR = "error",
ACCEPTED = "accepted",
PAUSED = "paused"
}
/** An enumeration listing the different high-level states that a contact can have. */
enum ContactStateType {
/** Indicates the contact is being initialized. */
INIT = "init",
/**
* Indicates that the contact is incoming and is waiting for acceptance.
* This state is skipped for `ContactType.VOICE` contacts but is essential for `ContactType.QUEUE_CALLBACK` contacts.
*/
INCOMING = "incoming",
/** Indicates the contact is pending. */
PENDING = "pending",
/**
* Indicates that the contact is currently connecting.
* For `ContactType.VOICE` contacts, this is when the user will accept the incoming call.
* For all other types, the contact will be accepted during the `ContactStateType.INCOMING` state.
*/
CONNECTING = "connecting",
/** Indicates the contact is connected. */
CONNECTED = "connected",
/** Indicates the contact timed out before the agent could accept it. */
MISSED = "missed",
/** Indicates the contact is rejected */
REJECTED = "rejected",
/** Indicates the contact is in an error state. */
ERROR = "error",
/** Indicates the contact has ended. */
ENDED = "ended",
/** Indicates the contact is paused */
PAUSED = 'paused'
}
enum CONTACT_ACTIVE_STATES {
INCOMING = "incoming",
PENDING = "pending",
CONNECTING = "connecting",
CONNECTED = "connected",
}
/** This enumeration lists all of the contact types supported by Connect Streams. */
enum ContactType {
/** Normal incoming and outgoing voice calls. */
VOICE = "voice",
/**
* Special outbound voice calls which are routed to agents before being placed.
* For more information about how to setup and use queued callbacks, see the Amazon Connect user documentation.
*/
QUEUE_CALLBACK = "queue_callback",
/** Chat contact. */
CHAT = "chat",
/** Task contact. */
TASK = "task",
/** Email contact. */
EMAIL = "email",
}
/** This enumeration lists the different types of VDI Platform supported. */
enum VDIPlatformType {
/** Citrix. */
CITRIX = "CITRIX",
AWS_WORKSPACE = "AWS_WORKSPACE",
OMNISSA = "OMNISSA",
CITRIX_413 = "CITRIX_413",
AZURE = "AZURE",
}
/** This enumeration lists the different types of contact channels. */
enum ChannelType {
/** A voice contact. */
VOICE = "VOICE",
/** A chat contact. */
CHAT = "CHAT",
/** A task contact. */
TASK = "TASK",
}
enum MediaType {
SOFTPHONE = "softphone",
CHAT = "chat",
TASK = "task",
EMAIL = "email",
}
enum SoftphoneCallType {
AUDIO_VIDEO = "audio_video",
VIDEO_ONLY = "video_only",
AUDIO_ONLY = "audio_only",
NONE = "none",
}
enum SoftphoneErrorTypes {
UNSUPPORTED_BROWSER = "unsupported_browser",
MICROPHONE_NOT_SHARED = "microphone_not_shared",
SIGNALLING_HANDSHAKE_FAILURE = "signalling_handshake_failure",
SIGNALLING_CONNECTION_FAILURE = "signalling_connection_failure",
ICE_COLLECTION_TIMEOUT = "ice_collection_timeout",
USER_BUSY_ERROR = "user_busy_error",
WEBRTC_ERROR = "webrtc_error",
REALTIME_COMMUNICATION_ERROR = "realtime_communication_error",
VDI_STRATEGY_NOT_SUPPORTED = "vdi_strategy_not_supported",
VDI_REDIR_NOT_SUPPORTED = "vdi_redir_not_supported",
OTHER = "other",
}
enum ClickType {
ACCEPT = "Accept",
REJECT = "Reject",
HANGUP = "Hangup",
}
enum CTIExceptions {
ACCESS_DENIED_EXCEPTION = "AccessDeniedException",
INVALID_STATE_EXCEPTION = "InvalidStateException",
BAD_ENDPOINT_EXCEPTION = "BadEndpointException",
INVALID_AGENT_ARNEXCEPTION = "InvalidAgentARNException",
INVALID_CONFIGURATION_EXCEPTION = "InvalidConfigurationException",
INVALID_CONTACT_TYPE_EXCEPTION = "InvalidContactTypeException",
PAGINATION_EXCEPTION = "PaginationException",
REFRESH_TOKEN_EXPIRED_EXCEPTION = "RefreshTokenExpiredException",
SEND_DATA_FAILED_EXCEPTION = "SendDataFailedException",
UNAUTHORIZED_EXCEPTION = "UnauthorizedException",
}
enum MonitoringMode {
SILENT_MONITOR = "SILENT_MONITOR",
BARGE = "BARGE"
}
enum MasterTopics {
LOGIN_POPUP = 'loginPopup',
SEND_LOGS = 'sendLogs',
SOFTPHONE = 'softphone',
RINGTONE = 'ringtone',
METRICS = 'metrics',
}
enum VideoCapability {
SEND = "SEND"
}
enum ScreenShareCapability {
SEND = "SEND"
}
enum ContactInitiationMethod {
INBOUND = "inbound",
OUTBOUND = "outbound",
TRANSFER = "transfer",
QUEUE_TRANSFER = "queue_transfer",
CALLBACK = "callback",
API = "api",
DISCONNECT = "disconnect",
WEBRTC_API = "webrtc_api",
AGENT_REPLY = "agent_reply",
CAMPAIGN_PREVIEW = "campaign_preview",
EXTERNAL_OUTBOUND = "external_outbound",
MONITOR = "monitor",
FLOW = "flow",
CALLBACK_CUSTOMER_FIRST_QUEUED = "callback_customer_first_queued",
CALLBACK_CUSTOMER_FIRST_DIALED = "callback_customer_first_dialed",
}
enum MonitoringErrorTypes {
INVALID_TARGET_STATE = "invalid_target_state",
}
interface AgentPermissions {
OUTBOUND_CALL: "outboundCall";
VOICE_ID: "voiceId";
}
/*
* A callback to receive notifications of success or failure.
*/
type SuccessFailCallback<T extends any[] = []> = (...args: T) => void;
interface SuccessFailOptions {
/** A callback that starts when the operation completes successfully. */
readonly success?: SuccessFailCallback;
/** A callback that starts when the operation has an error. */
readonly failure?: SuccessFailCallback<[string]>;
}
interface AddParticipantOptions extends SuccessFailOptions {
/**
* Allows for additional parameters
*/
}
interface TransferOptions extends SuccessFailOptions {
/**
* Allows for additional parameters
*/
}
interface ConnectOptions extends SuccessFailOptions {
/** The queue ARN to associate the contact with. */
readonly queueARN?: string;
/** The related contact ID for linking contacts. */
readonly relatedContactId?: string;
}
interface AgentSetStateOptions {
/** Enables enqueuing agent state while agent is handling a live contact. */
readonly enqueueNextState?: boolean;
}
/**
* The Agent API provides event subscription methods and action methods which can be called on behalf of the agent.
* There is only ever one agent per Streams instantiation and all contacts and actions are assumed to be taken on behalf of this one agent.
*/
class Agent {
/**
* Subscribe a method to be called whenever new agent data is available.
*
* @param callback A callback to receive the `Agent` API object instance.
*/
onRefresh(callback: AgentCallback): Subscription;
/**
* Subscribe a method to be called when the agent's state changes.
*
* @param callback A callback to receive the `AgentStateChange` API object instance.
*/
onStateChange(callback: AgentStateChangeCallback): Subscription;
/**
* Subscribe a method to be called when the agent becomes routable, meaning that they can be routed incoming contacts.
*
* @param callback A callback to receive the `Agent` API object instance.
*/
onRoutable(callback: AgentCallback): Subscription;
/**
* Subscribe a method to be called when the agent becomes not-routable, meaning that they are online but cannot be routed incoming contacts.
*
* @param callback A callback to receive the `Agent` API object instance.
*/
onNotRoutable(callback: AgentCallback): Subscription;
/**
* Subscribe a method to be called when the agent goes offline.
*
* @param callback A callback to receive the `Agent` API object instance.
*/
onOffline(callback: AgentCallback): Subscription;
/**
* Subscribe a method to be called when the agent is put into an error state.
* This can occur if Streams is unable to get new agent data, or if the agent fails to accept an incoming contact, or in other error cases.
* It means that the agent is not routable, and may require that the agent switch to a routable state before being able to be routed contacts again.
*
* @param callback A callback to receive the `Agent` API object instance.
*/
onError(callback: AgentCallback): Subscription;
/**
* Subscribe a method to be called when the agent is put into an error state specific to losing a WebSocket connection.
*
* @param callback A callback to receive the `Agent` API object instance.
*/
onWebSocketConnectionLost(callback: AgentCallback): void;
/**
* Subscribe a method to be called when the agent gains a WebSocket connection.
*
* @param callback A callback to receive the `Agent` API object instance.
*/
onWebSocketConnectionGained(callback: AgentCallback): void;
/**
* Subscribe a method to be called when the agent is put into an error state specific to softphone funcionality.
*
* @param callback A callback to receive the `SoftphoneError` error.
*/
onSoftphoneError(callback: SoftphoneErrorCallback): Subscription;
/**
* Subscribe a method to be called whenever the agent's connection health state transitions.
*
* The callback fires on every state change and receives a `NetworkConnectionStatusChanged` payload
* containing the new status and the transition timestamp. Use this single subscription in place
* of piecing together lifecycle signals from lower-level APIs.
*
* @param callback A callback to receive the `NetworkConnectionStatusChanged` payload.
*/
onNetworkConnectionStatusChanged(callback: NetworkConnectionStatusChangedCallback): Subscription;
/**
* Returns the current connection health status.
*
* Use this to retrieve the latest known status when subscribing late
* (after the initial status event may have already been published).
*
* @returns The current connection status and timestamp.
*/
getNetworkConnectionStatus(): Promise<NetworkConnectionStatusChanged>;
/**
* Subscribe a method to be called when the agent enters the "After Call Work" (ACW) state.
* This is a non-routable state which exists to allow agents some time to wrap up after handling a contact before they are routed additional co