# new Connection()
Properties:
Name | Type | Description |
---|---|---|
connectionId |
string | A unique local id for this connection. |
state |
ConnectionState | The current state of this connection |
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 |
- A connection object of the appropriate type, ready for 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
conversationId of the created conversation
# async protected _onConversation()
Called just before a subscription emits a previously unseen conversation
# async abstract protected _requestConversationSubscription() → {Promise.<uuid>}
Makes a request to UMS to create a subscription, must be implemented at the transport layer
subscriptionId of the created subscription
# async abstract protected _subscribeRoutingTasks(accountId, agentId)
Makes the websocket call to Agent Matching to subscribe for rings.
Parameters:
Name | Type | Description |
---|---|---|
accountId |
||
agentId |
# 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 |
# 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 |
# 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> |
# 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) |
# getAllKnownConversations() → {Array.<Conversation>}
Get an array of conversations known to the connection.
# getConversationById(conversationId) → {Conversation|null}
Get a conversation from the connection by conversationId. Returns null if not found.
Parameters:
Name | Type | Description |
---|---|---|
conversationId |
# async abstract getToken() → {Promise.<string>}
Returns the token from this connection
Token
# loadConversation(serializedConversationData) → {Conversation}
Takes serialized conversation data, deserializes it, and adds it to the connection's conversation pool.
Parameters:
Name | Type | Description |
---|---|---|
serializedConversationData |
# async abstract open()
Establishes or initializes a connection to UMS
# 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 |
# 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 |
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 |