Class

WebsocketConnection

WebsocketConnection()

A connection via websockets

Constructor

# new WebsocketConnection()

View Source connection/connection-websocket.js, line 65

Methods

# async _closeDialog(conversationId, dialogId, dialogCloseReason, cause) → {Promise.<void>}

Close the dialog. Conversation stage will remain open as long as it has open dialogs.

Parameters:
Name Type Default Description
conversationId string
dialogId string
dialogCloseReason DialogCloseReason null

"AGENT", "CONSUMER", or "SYSTEM"

cause string null

View Source connection/connection-websocket.js, line 1159

Promise.<void>

# async _connectWithRetry()

Establishes or initializes a websocket connection to UMS Will continue to retry until connected if maintainConnection = true

View Source connection/connection-websocket.js, line 261

# async abstract _getWebsocketUrl() → {Promise.<String>}

Returns a websocket URL. Must be implemented by child classes.

View Source connection/connection-websocket.js, line 660

Promise.<String>

# async abstract protected _initToken()

Generates an auth token based on the UserType

View Source connection/connection-websocket.js, line 728

# async _joinDialog(conversationId, dialogId, participantRole)

Attempt to join the current conversation as the given role

Parameters:
Name Type Description
conversationId string
dialogId string
participantRole ParticipantRole

View Source connection/connection-websocket.js, line 1182

# async _leaveDialog(conversationId, dialogId, participantRole)

Attempt to leave the current conversation as the given role

Parameters:
Name Type Description
conversationId string
dialogId string
participantRole ParticipantRole

View Source connection/connection-websocket.js, line 1204

# protected _onAuthInvalidError()

Clear the current auth token, forces a reauth when ._connect() is called again

View Source connection/connection-websocket.js, line 736

# protected _onUMSMessage(data)

handles message packets from UMS, will either pass to handleResponse or handleNotification

Parameters:
Name Type Description
data string

The json packet received from UMS, to be parsed. Must include "kind" attribute.

View Source connection/connection-websocket.js, line 745

# async protected _requestConversationSubscription() → {Promise.<uuid>}

Makes the websocket call to UMS to create a subscription. Overrides the abstract method above, called from createConversationSubscription

View Source connection/connection-websocket.js, line 1228

Promise.<uuid>

# async protected _transferConversation(transferDetailsopt)

Transfers a conversation to another agent, skill, or both. Removes the ASSIGNED_AGENT from the conversation.

Parameters:
Name Type Attributes Description
transferDetails object <optional>

Object containing details for conversation transfer. Defaults to an empty Object.

conversationId string
skillId string <optional>

Transfers this conversation to the specified skillId

agentId string <optional>

Transfers this conversation to the specified agentId

removeFromExistingRole string <optional>

The role of the agentId in this conversation, if any (e.g. READER)

removeAgentId string <optional>

The agentId of the ASSIGNED_AGENT to be removed during transfer

View Source connection/connection-websocket.js, line 1111

Error

void

# async closeConversation(conversationId) → {Promise.<void>}

Attempts to close a given conversation.

Parameters:
Name Type Description
conversationId string

View Source connection/connection-websocket.js, line 1140

Promise.<void>

# async getClock() → {Promise.<number>}

Makes a get clock request, previously used as a keep alive signal

Deprecated:
  • Yes

View Source connection/connection-websocket.js, line 1019

  • The current time in milliseconds from the UMS server's system clock
Promise.<number>

# async abstract getToken()

Returns the token from this connection

View Source connection/connection-websocket.js, line 156

# async open()

Establishes or initializes a websocket connection to UMS

View Source connection/connection-websocket.js, line 138

# async send(request) → {Promise.<*>}

Sends a request over the websocket, awaits the response

Parameters:
Name Type Attributes Description
request Object

The request information

type string
body Object
headers Array.<String> <optional>
metadata Array.<Object> <optional>

array of metadata to be attached to this request

View Source connection/connection-websocket.js, line 821

  • A promise that will resolve when a success response is received, it will reject if there is an error, a timeout, or the connection is disconnected before the response is received.
Promise.<*>

# async abstract setAgentState(agentId, agentState)

Changes the availability of an agent, only supported by BrandWebsocketConnection

Parameters:
Name Type Description
agentId string

{accountId.userId} - Defaults to the agentId for the current connection

agentState string

represents availability states of the agent: ONLINE, OFFLINE, AWAY, BACK_SOON

View Source connection/connection-websocket.js, line 1348

void