Class

Connection

Connection()

Represents a connection to UMS.

Constructor

# new Connection()

Properties:
Name Type Description
connectionId string

A unique local id for this connection.

state ConnectionState

The current state of this connection

View Source connection/connection.js, line 28

Methods

# static createConnection(args) → {Connection}

A factory method that returns an appropriate connection object based on parameters. Script must then call .open() to establish connection.

Parameters:
Name Type Attributes Default Description
args Object
accountId string

the brand's accountId

connectionType ConnectionType <optional>
WEBSOCKET

Specifies the mode of transport: WEBSOCKET, REST, or SEND_API

userType UserType

The type of user this connection will be used for: BRAND or CONSUMER

authData Object <optional>
null

Required if this is an agent or authenticated consumer

clientProperties Object <optional>
null

Connection metadata for consumer connections

jwtClaimsSet Object <optional>
null

A jwt claims set for authenticated consumers

authConnectorId Object <optional>
null

An authenticated connector id, required for auth consumer flow

maintainConnection boolean <optional>
true

If true, the SDK will always attempt to reconnect

useExtendedReconnectSchedule boolean <optional>

If false, the max time between reconnect attempts will be 10 minutes; if true it will be 4 hours

createDefaultSubscription boolean <optional>
true

If true, the connection will subscribe to receive conversations matching the defaultSubscriptionQuery below

defaultSubscriptionQuery Object <optional>
null

Defaults to stage:["OPEN"] for brand connections and stage:["OPEN", "CLOSE"] for consumer connections. May be overridden

waitForReady boolean <optional>

If true, the default subscription will wait for all conversations to load before allowing open to resolve

getAllMessages boolean <optional>

If true, new conversations will have all messages populated for the active dialog

appId string <optional>

Optional application identifier for clients consuming the sdk.

appVersion string <optional>

Optional application version for clients consuming the sdk

limitBreakEnabled boolean <optional>

determines whether or not the 1001 conversation subscription limit break is active

View Source connection/connection.js, line 73

  • A connection object of the appropriate type, ready for connection
Connection
Examples
const connection = Connection.createConnection({
  accountId:'12345678',
  userType: lpm.UserType.CONSUMER
});
await connection.open();
const connection = Connection.createConnection({
  accountId: '12345678',
  userType: lpm.UserType.BRAND,
  authData: {
    username: 'agent001@liveperson.com',
    password: 'password123'
  }
});
await connection.open();

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

Makes a request to UMS to create a conversation, only supported by ConsumerWebsocketConnection

View Source connection/connection.js, line 586

conversationId of the created conversation

Promise.<uuid>

# async protected _onConversation()

Called just before a subscription emits a previously unseen conversation

View Source connection/connection.js, line 450

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

Makes a request to UMS to create a subscription, must be implemented at the transport layer

View Source connection/connection.js, line 346

subscriptionId of the created subscription

Promise.<uuid>

# async abstract protected _subscribeRoutingTasks(accountId, agentId)

Makes the websocket call to Agent Matching to subscribe for rings.

Parameters:
Name Type Description
accountId
agentId

View Source connection/connection.js, line 694

# async abstract protected _updateRingState(ringId, ringState)

Updates the state of a ring. If state is accepted, the agent will be assigned to the conversation.

Parameters:
Name Type Description
ringId
ringState

View Source connection/connection.js, line 705

# async close()

Start the closing process

View Source connection/connection.js, line 269

void

# async createConversation(args) → {Promise.<Conversation>}

Makes a request to UMS for a new conversation. Constructs a conversation object with the response information.

Parameters:
Name Type Attributes Description
args object
skillId string <optional>

creates this conversation in the specified skillId

context object <optional>

this data will be passed back in the notifications as conversationDetails.context

campaignInfo object <optional>

Contains the campaignId and engagementId

campaignInfo.campaignId string <optional>

The campaignId retrieved by the Engagement Monitoring API endpoint

campaignInfo.engagementId string <optional>

The engagementId retrieved by the Engagement Monitoring API endpoint

View Source connection/connection.js, line 537

Promise.<Conversation>

# async createConversationSubscription(args) → {Promise.<ConversationSubscription>}

Creates a conversation subscription in UMS based on the input criteria.

Parameters:
Name Type Attributes Description
args object
waitForReady boolean <optional>

If true, wait for all the conversations to load before resolving

query object <optional>
query.accountId string <optional>
query.agentId string <optional>
query.consumerId string <optional>
query.conversationId string <optional>
query.state string <optional>
query.stage string <optional>
query.dialogType DialogType <optional>

View Source connection/connection.js, line 322

Promise.<ConversationSubscription>

# async createRoutingTaskSubscription(args) → {Promise.<RoutingTaskSubscription>}

Creates a routing task subscription in UMS based on the input criteria.

Parameters:
Name Type Attributes Description
args object
query object <optional>

Optional query

query.accountId string <optional>

Optional accountId(default to connection.accountId)

query.agentId string <optional>

Optional agentId(defaults to connection.agentId)

View Source connection/connection.js, line 719

Promise.<RoutingTaskSubscription>

# getAllKnownConversations() → {Array.<Conversation>}

Get an array of conversations known to the connection.

View Source connection/connection.js, line 831

Array.<Conversation>

# getConversationById(conversationId) → {Conversation|null}

Get a conversation from the connection by conversationId. Returns null if not found.

Parameters:
Name Type Description
conversationId

View Source connection/connection.js, line 818

Conversation | null

# async abstract getToken() → {Promise.<string>}

Returns the token from this connection

View Source connection/connection.js, line 302

Token

Promise.<string>

# loadConversation(serializedConversationData) → {Conversation}

Takes serialized conversation data, deserializes it, and adds it to the connection's conversation pool.

Parameters:
Name Type Description
serializedConversationData

View Source connection/connection.js, line 368

Conversation

# async abstract open()

Establishes or initializes a connection to UMS

View Source connection/connection.js, line 259

# async processWebhooksNotification(notification)

Processes a notification received through a webhook request. This should not be used in combination with conversation subscriptions

Parameters:
Name Type Description
notification

The notification received through webhooks

View Source connection/connection.js, line 355

# 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.js, line 615

void

# async setUserProfile(body) → {Promise.<void>}

Allows user to set certain fields that get returned from getUserProfile

Note: SDEs can only be set through authenticated user flow and do not use this function

Parameters:
Name Type Description
body
firstName string
lastName string
nickName string

View Source connection/connection.js, line 629

Promise.<void>