On conversation end

  • Messaging

You can leverage a Function as a Service (FaaS) function to implement any functionality when a conversation is finished. This advanced approach allows for tailored event customization to enhance your bot's capabilities.

Through Automatic Messages, you can create functions triggered based on selected events. A payload is sent to a function containing metadata related to the specific conversation and based on the selected event during the invocation. 

Enable the automatic messages feature and Create a new function using the 'Messaging conversation end' messaging events. You can select one of the available templates for the chosen event. Currently, you can create only one function per template type for these conversational events. A deployed function on a specific messaging event can be invoked on multiple conversation events.

Create the FaaS Function

Navigate to the "Functions" section in LivePerson Conversational Builder. 

Screenshot 2024-02-19 at 1.42.04 PM.png

Click Automate > Functions. The Functions page appears.

Screenshot 2024-02-19 at 1.51.53 PM.png

Click Confirm to agree to the Terms of Use and GDPR Agreement.

Screenshot 2024-02-19 at 1.54.26 PM.png

Click the icon to open the LivePerson Functions page.

Screenshot 2024-02-19 at 1.57.45 PM.png

Click Create a Function. The Create a new function wizard appears.

Screenshot 2024-02-20 at 1.04.17 PM.png

Provide the following information:

  1. Runtime: Select your runtime.
  2. Event: Select the event that the FaaS function will track, in this case new conversation events. Select an event to see its available templates. 
  3. Skill trigger: Select skills which trigger to which this function reacts. It is not necessary to select any skill, since this option was managed on the Automatic Messages section.
  4. Greeting Template: Select a template to start your implementation. Select the code template that the FaaS function will have, which can vary depending on the event you selected.
  5. Access to external domains required: Enable this option if you plan to call external APIs, including the API's domain. Disable it if no external API calls are required.
  6. Code: Displays the code for the template selected.

Click Continue. The next page appears.

Screenshot 2024-02-20 at 1.18.26 PM.png

By default, access to external domains is blocked. Adding domains to the allowlist allows functions to send requests to them. If required, add domains to the field and click Continue. The next page appears.

Screenshot 2024-02-19 at 2.08.41 PM.png

Provide the function name and description in the fields. 

Screenshot 2024-02-19 at 2.08.41 PM.png

Click Create function the function is added. Once the function is open you can edit the code to implement any logic needed.

Screenshot 2024-02-20 at 2.15.42 PM.png

With Automatic Messages selected as the trigger, you can utilize the input.payload variable, containing conversation data, within your function code. 

This data contains:

1. Level2. Level3. LevelDescriptionTypeExample
endcloseReason
which role closed conversationSTRINGAGENT/CONSUMER/SYSTEM
generalcbotEventType
Original conversation event typeSTRINGCONSUMER_OPEN_NEW_CONVERSATION_FIRST_TIME_OFF_HOURS
generaltype
notification typeSTRINGUPSERT
generalconvId
ID of conversationSTRINGc840e51e-5f65-4ad4-8d34-5c82b99a2200
generaldialogId
ID of dialogSTRINGc840e51e-5f65-4ad4-8d34-5c82b99a2200
generalsessionId
ID of sessionNUMBER1528463744580
generalstartTs
conversation start time as timestampNUMBER1528463744663
generaleffectiveTTR
timestamp when agent should be availableNUMBER1528464044687
generaloldConvState
previous state of the dialogSTRINGCLOSE
generalnewConvState
current state of the dialogSTRINGOPEN
generalcontexttype
type of cotextSTRINGSharkContext
generalcampaignInfoidID of campaignNUMBER2327699812
generalcampaignInfoengangementIdID of engangementNUMBER2327699912
generalclientLanguage
language of the client deviceSTRINGen-US
generalclientFeatures
list of supported client featuresARRAY["AUTO_MESSAGES", "MULTI_DIALOG"]
generalinOffHours
shift-status of the contact centerBOOLEANTRUE/FALSE
generalvisitorId
ID of visitorNUMBER1528463744580
generaloriginatorId
ID of originatorNUMBER37607275.23
generaloriginatorPid
Pid of originatorSTRINGf39fbc5f-da77-5417-8bc7-7584efdd1a5e
generaloriginatorMetadataidPid of originator of metadata changeSTRINGf39fbc5f-da77-5417-8bc7-7584efdd1a5e
generaloriginatorMetadataroleRole of originator of metadata changeSTRINGCONTROLLER
generalserverTimestamp
timestamp of the serverNUMBER1528463781807
generalclientIpAdress
IP Address of clientSTRING172.26.138.38
generalmanualETTR
time to response manually updated by agentSTRING1541152938069
generallastMessageComposer
the role of the last composerSTRINGCONSUMER
generallastMessageTs
timestamp of last messageNUMBER1541152938069
generallastAgentMsgTs
timestamp of last agent messageNUMBER1541152938069
generalbackToQueueTs
timestamp when the conversation was returned to queueNUMBER1541152938069
idlelastConsumerMsgTs
timestamp of last consumer messageNUMBER1541152938069
idleagentNonResponsivetimetime that should pass after consumer's last message in order the agent to be non-responsiveNUMBER30
idleagentNonResponsivetimeUnitstime units in which agent non-responsive time should be calculatedSTRINGminutes
idleconsumserNonResponsivetimetime that should pass after agent's last message in order the consumer to be non-responsiveNUMBER30
idleconsumserNonResponsivetimeUnitstime units in which consumer non-responsive time should be calculatedSTRINGminutes
idleconvNotTakenTimetimetime units in which conversation idle time should be calculatedSTRINGminutes
idleconvNotTakenTimetimeUnitshow long should the conversation stay in queue in order to be idleNUMBER30
midopenedInOffHours
indicator if the conversation was opened in off hoursBOOLEANTRUE/FALSE
participantChangeoldParticipants
array of the participants of the previous stateARRAY[{"id": "f9d58c57-c489-45f5-bae4-c5ebd52b3972","role": "ASSIGNED_AGENT"}]
participantChangenewParticipants
array of the participants of the current stateARRAY[{"id": "f9d58c57-c489-45f5-bae4-c5ebd52b3972","role": "ASSIGNED_AGENT"}, {"id": "f9d58c57-c489-45f5-bae4-c5ebd52b3972","role": "AGENT"}]
routingoldSkillId
previous skillId of conversationSTRING563268
routingnewSkillId
current skillId of conversationSTRING563267
startfirstConversation
if this is the first conversation of the consumer everBOOLEANTRUE/ FALSE
ttroldTtrttrTypetype of ttr of the previous stateSTRINGNORMAL
ttroldTtrvaluevalue of ttr of the previous stateNUMBER600
ttrnewTtrttrTypetype of ttr of the new stateSTRINGURGENT
ttrnewTtrvaluevalue of ttr of the new state (after change for example to URGENT)NUMBER300

The cbotEventType property in the invocation payload distinguishes conversation event types. Below is the mapping of conversation event types to messaging events on functions:

Event TypeMapped to
AGENT_END_CONVERSATIONMessaging conversation end
CONSUMER_END_CONVERSATIONMessaging conversation end
SYSTEM_END_CONVERSATIONMessaging conversation end

Deploy the Function:

Click the 3 dot menu on the created function.

Screenshot 2024-02-19 at 2.15.53 PM.png

Click Deploy function. The Create a deployment page appears.

Screenshot 2024-02-19 at 2.18.17 PM.png

Click Approve & Deploy. The function is deployed.

Screenshot 2024-02-19 at 2.20.18 PM.png

Your function is now deployed and ready for use. By utilizing FaaS functions, you can seamlessly customize events and enhance the functionality of your bot in Conversational Builder.

An idea of using FaaS with an end event, is to store conversation info into the Context Service when conversation is finished. This information will be available for the next time when the customer starts a new conversation.

For example, a function deployed on the Messaging conversation end event will fire when one of these events occurs during a conversation: AGENT_END_CONVERSATION, CONSUMER_END_CONVERSATION and SYSTEM_END_CONVERSATION. 

For more information see, here.