amazon-connect-streams
Version:
Amazon Connect Streams Library
1,349 lines (1,138 loc) • 95.2 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;
/**
* 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;
/**
* 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 `SoftphoneError` errors.
*
* @param error A `SoftphoneError` error.
*/
type SoftphoneErrorCallback = (error: SoftphoneError) => 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]: any;
},
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;
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;
/**
* 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(): any;
/**
* 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: Function): 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: Function): 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<any[]>;
/**
* Global upstream conduit for external use.
*
*/
upstream?: object | null;
/**
* Configuration to be passed to SDK Client
*
*/
getSDKClientConfig(): { provider: any };
}
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 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 SDK support, we are currently only supporting CITRIX
* To specify that the VDI environment is Citrix, please set this value to `CITRIX` or
* `VDIPlatformType.CITRIX`
*/
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;
}
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 LoginOptions {
/*
* 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;
}
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;
/**
* 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 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 }>
}
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
}
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",
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",
}
/** This enumeration lists the different types of VDI Platform supported. */
enum VDIPlatformType {
/** Citrix. */
CITRIX = "CITRIX",
AWS_WORKSPACE = "AWS_WORKSPACE",
}
/** 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",
}
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",
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"
}
/*
* 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;
}
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 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 contacts.
*
* @param callback A callback to receive the `Agent` API object instance.
*/
onAfterCallWork(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;
/** Get the agent's current 'AgentAvailabilityState' object indicating their actual state type. */
getAvailabilityState(): AgentAvailabilityState;
/**
* @deprecated Use getAvailabilityState()
* Get the agent's current `AgentState` object indicating their availability state type.
* */
getState(): AgentState;
/**
* @deprecated Use getAvailabilityState()
* Alias for `getState()`.
* */
getStatus(): AgentState;
/**
* Get the AgentState object of the agent's enqueued next status.
* If the agent has not enqueued a next status, returns null.
*/
getNextState(): AgentState;
/**
* Get the duration of the agent's state in milliseconds relative to local time.
* This takes into account time skew between the JS client and the Amazon Connect service.
*/
getStateDuration(): number;
/**
* Mostly for internal purposes only.
* Contains strings which indicates actions that the agent can take in the CCP.
*/
getPermissions(): string[];
/**
* Gets a list of `Contact` API objects for each of the agent's current contacts.
*
* @param contactTypeFilter If provided, only contacts of the given `ContactType` enum are returned.
*/
getContacts(contactTypeFilter?: ContactType): Contact[];
/** Gets the full `AgentConfiguration` object for the agent. */
getConfiguration(): AgentConfiguration;
/**
* Gets the list of selectable `AgentState` API objects.
* These are the agent states that can be selected when the agent is not handling a live contact.
*/
getAgentStates(): AgentStateDefinition[];
/** Gets the agent's routing profile. */
getRoutingProfile(): AgentRoutingProfile;
/**
* Gets a map of channel type to 1 or 0.
* 1 represents an enabled channel.
* 0 represents a disabled channel.
*/
getChannelConcurrency(): AgentChannelConcurrencyMap;
/**
* Gets a number indicating how many concurrent contacts can an agent have on a given channel.
* 0 represents a disabled channel.
*
* @param channel The channel to get the configured concurrency.
*/
getChannelConcurrency(channel: ChannelType): number;
/** Gets the agent's ARN. */
getAgentARN(): string;
/** Gets the agent's user friendly display name. */
getName(): string;
/**
* Gets the agent's phone number.
* This is the phone number that is dialed by Amazon Connect to connect calls to the agent for incoming and outgoing calls if softphone is not enabled.
*/
getExtension(): string;
/** Returns a list of eligible countries to be dialed / deskphone redirected. */
getDialableCountries(): string[];
/** Indicates whether the agent's phone calls should route to the agent's browser-based softphone or the telephone number configured as the agent's extension. */
isSoftphoneEnabled(): boolean;
/**
* Updates the agent's configuration with the given `AgentConfiguration` object.
* The phone number specified must be in E.164 format or the update fails.
*
* @param config The desired configuration.
* @param callbacks Success and failure callbacks to determine whether the operation was successful.
*/
setConfiguration(
config: AgentConfiguration,
callbacks?: SuccessFailOptions
): void;
/**
* Set the agent's current availability state.
* Will enqueue state if the agent is handling a live contact and enqueueNextState is true.
*
* @param state The new agent state.
* @param callbacks Success and failure callbacks to determine whether the operation was successful.
* @param options
*/
setState(
state: AgentStateDefinition,
callbacks?: SuccessFailOptions,
options?: AgentSetStateOptions
): void;
/**
* Create task contact.
* Can only be performed if the agent is not handling a live contact.
*
* @param taskContact The new task contact.
* @param callbacks Success and failure callbacks to determine whether the operation was successful.
*/
createTask(taskContact: TaskContactDefinition, callbacks?: SuccessFailOptions): void;
/** Alias for `setState()`. */
setStatus(
state: AgentStateDefinition,
callbacks?: SuccessFailOptions
): void;
/**
* Creates an outbound contact to the given endpoint.
*
* @param endpoint An `Endpoint` API object to connect to.
* @param connectOptions The connection options.
*/
connect(endpoint: Endpoint, connectOptions?: ConnectOptions): void;
/** Returns a list of the ARNs associated with this agent's routing profile's queues. */
getAllQueueARNs(): string[];
/**
* Returns the endpoints associated with the queueARNs specified in `queueARNs`.
*
* @param queueARNs A single Queue ARN or a list of Queue ARNs associated with the desired queues.
* @param callbacks Success and failure callbacks to determine whether the operation was successful.
*/
getEndpoints(
queueARNs: string | string[],
callbacks: GetEndpointsCallbacks
): void;
/**
* The data behind the `Agent` API object is ephemeral and changes whenever new data is provided.
* This method provides an opportunity to create a snapshot version of the `Agent` API object and save it for future use, such as adding to a log file or posting elsewhere.
*/
toSnapshot(): Agent;
/** Sets the agent local media to mute mode. */
mute(): void;
/** Sets the agent localmedia to unmute mode. */
unmute(): void;
/**
* Sets the speaker device (output device for call audio)
*
* @param deviceId The id of the media device.
*/
setSpeakerDevice(deviceId: string): void;
/**
* Sets the microphone device (input device for call audio)
*
* @param deviceId The id of the media device.
*/
setMicrophoneDevice(deviceId: string): void;
/**
* Sets the ringer device (output device for ringtone)
*
* @param deviceId The id of the media device.
*/
setRingerDevice(deviceId: string): void;
/**
* The `agent.setCameraDevice()` API is used to broadcast a change in the camera device (input device for camera) state. However, it does not actually switch the camera device.
* Instead, it triggers the `agent.onCameraDeviceChanged()` callback to notify listeners of the updated camera device state.
* To handle the camera functionality, you would need to use either the [Amazon Chime SDK JS](https://github.com/aws/amazon-chime-sdk-js) or the [Amazon Chime SDK Component Library React](https://github.com/aws/amazon-chime-sdk-component-library-react).
*
* Specifically, you can use the following APIs:
* - [Amazon Chime SDK JS - audioVideo.startVideoInput](https://aws.github.io/amazon-chime-sdk-js/classes/defaultaudiovideofacade.html#startvideoinput)
* - [Amazon Chime SDK Component Library React - useVideoInputs](https://aws.github.io/amazon-chime-sdk-component-library-react/?path=/docs/sdk-hooks-usevideoinputs--page)
*
* After you have selected a new device using the Chime SDK, you can use `agent.setCameraDevice(deviceId)` to notify the state update, and then use the `agent.onCameraDeviceChanged()` callback to handle the state update.
*
* @param deviceId The id of the media device.
*/
setCameraDevice(deviceId: string): void;
/**
* The `agent.setBackgroundBlur()` API is used to broadcast a change in the Background Blur state. However, it does not actually enable or disable the blur effect.
* Instead, it triggers the `agent.onBackgroundBlurChanged()` callback to notify listeners of the updated blur state.
*
* To handle the Background Blur functionality, you would need to use either the [Amazon Chime SDK JS](https://github.com/aws/amazon-chime-sdk-js) or the [Amazon Chime SDK Component Library React](https://github.com/aws/amazon-chime-sdk-component-library-react).
*
* Specifically, you can use the following resources:
* - [Amazon Chime SDK JS - Adding background filters to your application](https://aws.github.io/amazon-chime-sdk-js/modules/backgroundfilter_videofx_processor.html#adding-background-filters-to-your-application)
* - [Amazon Chime SDK Component Library React - BackgroundBlurProvider](https://aws.github.io/amazon-chime-sdk-component-library-react/?path=/docs/sdk-providers-backgroundblurprovider--page)
*
* After you have changed the actual Background Blur state using the Chime SDK, you can use `agent.setBackgroundBlur(isBackgroundBlurEnabled)` to notify the state update, and then use the `agent.onBackgroundBlurChanged()` callback to handle the state update.
*
* @param isBackgroundBlurEnabled Indicates whether Background Blur is enabled
*/
setBackgroundBlur(isBackgroundBlurEnabled: boolean): void;
/**
* Subscribe a method to be called when the agent updates the mute status, meaning that agents mute/unmute APIs are called and the local media stream is successfully updated with the new status.
*
* @param callback A callback to receive updates on agent mute state
*/
onMuteToggle(callback: AgentMutedStatusCallback): Subscription;
/**
*