Interfaces

This document contains the documentation for the interfaces available in the Toolbelt.


ICache<K, V>

Type Parameters

K

K

V

V

Methods

clear()

clear(): void

Returns

void


delete()

delete(key): boolean

Parameters
Name Type
key K
Returns

boolean


get()

get(key): V | null

Parameters
Name Type
key K
Returns

V | null


getAll()

getAll(): V[]

Returns

V[]


has()

has(key): boolean

Parameters
Name Type
key K
Returns

boolean


set()

set(key, value, ttl?): void

Parameters
Name Type
key K
value V
ttl? number
Returns

void


setDefaultTtl()

setDefaultTtl(newTtl): void

Parameters
Name Type
newTtl number
Returns

void


size()

size(): number

Returns

number


IConversationUtil

Methods

getConversationById()

getConversationById(conversationId, contentToRetrieve?): Promise<Conversation>

Will retrieve a conversation Object from the Live-Engage Messaging Interaction API

Parameters
Name Type Description
conversationId string ID of the conversation which should be retrieved
contentToRetrieve? ConversationContentTypes[] Array which can be used to define which contents of the conversation should be retrieved. Use 'import { ConversationContentTypes } from "core-functions-toolbelt";' to get an overview of possible options.
Returns

Promise<Conversation>


scanConversationForKeywords()

scanConversationForKeywords(conversation, keywords): KeywordScannerResult[]

Will scan a conversation Object for messages containing the provided keywords and collect them. Also it enriches them with additional information, about when the message was sent, who it was sent by and because of which keyword it was selected.

Parameters
Name Type Description
conversation Conversation Conversation Object that has been retrieved with .getConversationById(conversationId).
keywords string[] Array of keywords which the conversation will be scanned for.
Returns

KeywordScannerResult[]


ICsdsClient

Methods

get()

get(service): Promise<string>

Get the host for a CSDS service name. The CsdsClient will get all hosts for the account and cache them as configured in ttInSeconds (see constructor).

Parameters
Name Type
service string
Returns

Promise<string>


getAll()

getAll(): Promise<Record<string, string>[]>

Returns all the available services domains per account

Returns

Promise<Record<string, string>[]>


IFaaSContextServiceClient

Methods

createNamespace()

createNamespace(namespace, options?): Promise<Namespace>

Creates a custom namespace with the specified name for the provided account. Given the namespace exists it will not recreate it or throw an error. However there are built-in namespaces that will yield an error.

Parameters
Name Type Description
namespace string -
options? NamespaceOptions that should be applied to the namespace. For example TTL.
Returns

Promise<Namespace>

Throws

SDK Error when API returned non successful status code

Throws

SDK Error when provided namespace is built-in

Throws

SDK Error when provided namespace is null, undefined or empty string


deleteNamespace()

deleteNamespace(namespace): Promise<void>

Deletes a custom namespace with the specified name. Given the namespace was already deleted it will not throw an error.

Parameters
Name Type
namespace string
Returns

Promise<void>

Throws

SDK Error when API returned non successful status code

Throws

SDK Error when provided namespace is built-in

Throws

SDK Error when provided namespace is null, undefined or empty string


deletePropertyInSession()

deletePropertyInSession(namespace, propertyName, sessionId?): Promise<void>

Deletes the specified property on the defined session. Given no session was provided it will fallback to default session of the namespace. Given the property was already deleted it will not throw an error.

Parameters
Name Type Description
namespace string -
propertyName string -
sessionId? string Optional if not provided will use default session
Returns

Promise<void>

Throws

SDK Error when API returned non successful status code


deleteSession()

deleteSession(namespace, sessionId?): Promise<void>

Deletes the specified session in the defined namespace. Given no session was provided it will fallback to default session of the namespace. Given the session was already deleted it will not throw an error.

Parameters
Name Type Description
namespace string -
sessionId? string Optional if not provided will use default session
Returns

Promise<void>

Throws

SDK Error when API returned non successful status code


getAllPropertiesInSession()

getAllPropertiesInSession(namespace, sessionId?): Promise<Entity>

Returns the specified session containing all of it's properties. Given no session was provided it will fallback to the default session of the namespace.

Parameters
Name Type Description
namespace string -
sessionId? string Optional if not provided will use default session
Returns

Promise<Entity>

Throws

SDK Error when API returned non successful status code


getListOfNamespaces()

getListOfNamespaces(): Promise<Namespace[]>

Returns a list containing all custom namespaces for the account the client was initialised for. Please be aware that built-in namespaces won't show up with exception to the default namespace.

Returns

Promise<Namespace[]>

Throws

SDK Error when API returned non successful status code


getListOfSessions()

getListOfSessions(namespace): Promise<string[]>

Returns a list containing all session in the specified namespaces.

Parameters
Name Type
namespace string
Returns

Promise<string[]>

Throws

SDK Error when API returned non successful status code


getPropertyInSession()

getPropertyInSession(namespace, propertyName, sessionId?): Promise<unknown>

Get the value of the specified property on the defined session. Given no session was provided it will fallback to default session of the namespace.

Parameters
Name Type Description
namespace string -
propertyName string -
sessionId? string Optional if not provided will use default session
Returns

Promise<unknown>

Throws

SDK Error when API returned non successful status code


getSelectedPropertiesInSession()

getSelectedPropertiesInSession(namespace, propertyNames, sessionId?): Promise<Entity>

Returns the specified session containing all of the defined properties. Given a property does not exist it will be ignored. Given no session was provided it will fallback to default session of the namespace.

Parameters
Name Type Description
namespace string -
propertyNames string[] that should be included
sessionId? string Optional if not provided will use default session
Returns

Promise<Entity>

Throws

SDK Error when API returned non successful status code


setPropertiesInNamespace()

setPropertiesInNamespace(namespace, properties, sessionId?): Promise<Entity>

Will set properties on the specified session in the defined namespace. Given no session was provided it will fallback to the default session of the namespace. All values will be stored in their JSON serialized version. Given a property/properties already exist they will be updated.

Parameters
Name Type Description
namespace string -
properties Entity -
sessionId? string Optional if not provided will use default session
Returns

Promise<Entity>

Throws

SDK Error when API returned non successful status code


updatePropertiesInNamespace()

updatePropertiesInNamespace(namespace, properties, sessionId?): Promise<Entity>

Will update properties on the specified session in the defined namespace. Given no session was provided it will fallback to the default session of the namespace. All values will be stored in their JSON serialized version. Given a property/properties does not exist they will be created.

Parameters
Name Type Description
namespace string -
properties Entity -
sessionId? string Optional if not provided will use default session
Returns

Promise<Entity>

Throws

SDK Error when API returned non successful status code


IGDPRUtil

GDPR related functionality

Methods

replaceConversationFiles()

replaceConversationFiles(conversation, credentials, shouldReplace?, replacementFile?): Promise<FilesReplaced>

WARNING: This will remove all files of a permanently! Ask you account manager for permissions.

Parameters
Name Type Description
conversation Conversation Conversation for which the files should be replaced.
credentials ObjectStoreCredentials Credentials for the object store where files are stored.
shouldReplace? ReplacePredicate Matcher function that can be used to filter files.
replacementFile? ReplacementFile File that is used to replace current files. By default a 1x1 black png.
Returns

Promise<FilesReplaced>

Promise of files that have been replaced.


ILpMtlsClient

Interface definition for the LP powered MTLS Service

Methods

get()

get(url, headers?, body?, options?): Promise<LPMtlsResponse>

Perform a Get Call via the LP MTLS Service. Please make sure you performed the necessary onboarding and configuration of domain <=> cert mappings before attempting to use the client.

Parameters
Name Type Description
url string -
headers? Record<string, string> -
body? Record<string, unknown> | BodyInit -
options? LPMtlsOptions Request specific options
Returns

Promise<LPMtlsResponse>


post()

post(url, headers?, body?, options?): Promise<LPMtlsResponse>

Perform a Post Call via the LP MTLS Service. Please make sure you performed the necessary onboarding and configuration of domain <=> cert mappings before attempting to use the client.

Parameters
Name Type Description
url string -
headers? Record<string, string> -
body? Record<string, unknown> | BodyInit -
options? LPMtlsOptions Request specific options
Returns

Promise<LPMtlsResponse>


IMtlsClient

Interface definition for the MTLS Client.

Methods

delete()

delete(url, headers?, body?, options?): Promise<MTLSResponse>

Performing a MTLS delete request using the configured client certificate + key.

Parameters
Name Type Description
url string -
headers? Record<string, string> -
body? Record<string, unknown> | BodyInit -
options? MTLSOptions Request specific options
Returns

Promise<MTLSResponse>


get()

get(url, headers?, body?, options?): Promise<MTLSResponse>

Performing a MTLS get request using the configured client certificate + key

Parameters
Name Type Description
url string -
headers? Record<string, string> -
body? Record<string, unknown> | BodyInit -
options? MTLSOptions Request specific options
Returns

Promise<MTLSResponse>


head(url, headers?, options?): Promise<MTLSResponse>

Performing a MTLS head request using the configured client certificate + key. Any body returned by the endpoint will be ignored and forcefully overridden with undefined.

Parameters
Name Type Description
url string -
headers? Record<string, string> -
options? MTLSOptions Request specific options
Returns

Promise<MTLSResponse>


options()

options(url, headers?, options?): Promise<MTLSResponse>

Performing a MTLS options request using the configured client certificate + key. Any body returned by the endpoint will be ignored and forcefully overridden with undefined.

Parameters
Name Type Description
url string -
headers? Record<string, string> -
options? MTLSOptions Request specific options
Returns

Promise<MTLSResponse>


patch()

patch(url, headers?, body?, options?): Promise<MTLSResponse>

Performing a MTLS put request using the configured client certificate + key.

Parameters
Name Type Description
url string -
headers? Record<string, string> -
body? Record<string, unknown> | BodyInit -
options? MTLSOptions Request specific options
Returns

Promise<MTLSResponse>


post()

post(url, headers?, body?, options?): Promise<MTLSResponse>

Performing a MTLS post request using the configured client certificate + key.

Parameters
Name Type Description
url string -
headers? Record<string, string> -
body? Record<string, unknown> | BodyInit -
options? MTLSOptions Request specific options
Returns

Promise<MTLSResponse>


put()

put(url, headers?, body?, options?): Promise<MTLSResponse>

Performing a MTLS put request using the configured client certificate + key.

Parameters
Name Type Description
url string -
headers? Record<string, string> -
body? Record<string, unknown> | BodyInit -
options? MTLSOptions Request specific options
Returns

Promise<MTLSResponse>


IOrchestratorClient

Methods

invoke()

invoke(invocations, deadline, options?): Promise<OrchestratorResponse[]>

Parameters
Name Type Description
invocations OrchestratorInvocation[] contains the UUIDs of the functions which will be invoked with their respective information
deadline number gives the maximum time the orchestrator function is waiting for an answer (max 25s)
options? OrchestratorOptions Orchestrator invoke options: timeout, parallel invocation and error strategy
Returns

Promise<OrchestratorResponse[]>

Throws

if "errorStrategy" option is "ExitOnError" and there is an invocation error, it will cancel other requests


ISDEUtil

Interacts with Engagement Attributes API Docs: https://developers.liveperson.com/engagement-attributes-api-overview.html

Methods

addSDEs()

addSDEs(sdes, visitorId, sessionId): Promise<void>

Will set or update SDEs to/of an Engagement via the Engagement Attributes API.

Parameters
Name Type Description
sdes SDE[] Array with the SDEs that should be set/ updated. See Engagement Attributes API-Documentation for more Information on how to structure it.
visitorId string The ID of the visitor.
sessionId string The ID of the session.
Returns

Promise<void>


getSDEsFromConv()

getSDEsFromConv(conversation): ConversationSDEs

Will extract all SDEs (authenticated and unauthenticated if existing) from a provided conversation and order its events by the server-timestamp. The last event is the most recent one.

Parameters
Name Type Description
conversation Conversation the conversation of which the SDEs should be extracted.
Returns

ConversationSDEs


ISecretClient

Client that will handle the communication with the Secret Storage.

Methods

readSecret()

readSecret(key, options?): Promise<SecretEntry>

Searches the Secret that belong to the provided key. Will raise an SecretError if there is no secret for the provided key.

Parameters
Name Type Description
key string Name of the Secret
options? Partial<SecretRequestOptions> Optional settings for timeout and cache useage
Returns

Promise<SecretEntry>

Secret in Key-Value Format


updateSecret()

updateSecret(updatedSecret, options?): Promise<SecretEntry>

Updates the Secret with the provided update-entry. Will raise an SecretError if there is no secret with the specified key.

Parameters
Name Type Description
updatedSecret SecretEntry Secret in Key-Value Format
options? Partial<SecretRequestOptions> Optional settings for timeout and cache useage
Returns

Promise<SecretEntry>

Updated Version of the Secret in Key-Value Format