Using Flow to Create a Synchronized Co-Work Chat Session

It’s easy to insert screen flows into Salesforce chat sessions, but you can go far beyond that, enabling agents to co-work with customers on the same process in real-time.

Demo

Video created and available internally here : https://drive.google.com/file/d/1yLPK-ElSpHOEOQa_hXCqsMJdTVUUAqPt/view?usp=sharing

Overall Architecture

Configure

This example describe the configuration used for the demo above

Prerequisite

You will need to install several components:

Step 1 – Create a platform event

This platform event will be used to synchronise the customer flow with the agent flow. the platform event has two fields

  • id => to identify the platform event between agent and customer
  • use_of_fund_reason => to store the customer’s answer and share it with the agent

How does the id get used? Let’s say you’re having two customer (A & B) having a chat session at the same time with two different agents (A & B) and both of them running the “synchronized” flow. When customer A is filling his form you want only the agent A’s running flow to react to the platform event created by customer A. You don’t the agent B’s running flow to react. That’s exactly what this id is for. Customer A will create a platform event with an id and agent A is reacting to only platform events with that id.

How does Agent A and customer A knows which id to use? In the demo you may have notice that customer A flow has been initiated by Agent A. When Agent A initiates a flow on the customer side for customer A, agent A initiates this customer side flow with one parameter : the id customer A must use to create platform events. This id can be auto-generated and unique, it can the ChatTranscriptId or the CaseId (assuming the same customer is not discussing with two different agents for the same case!).

If you need more data to synchronise between customer and agent, just add more fields to the platform event

 

Step 2 – Create the Customer side flow

This flow demonstrates the key elements necessary to create a Synchronized Co-Working chat session.

The first node is a screen that will display the question in the form

The second node is a create record node and will create the platform event

The third node is a screen that will display the results

Step 3 – Create a lightning component to listen to the platform event

Refer to following article.

Step 4 – Create the Agent side flow

Remember that in the demonstration, the flow was initiated from the Case and not the Live Chat Transcript

The first node is a Get Record node in order to retrieve the LivechatTranscriptId from the Case Id. The Case Id will be passed in a variable named recordId

The second node is a Screen that will:

  • Display the question in the form
  • FlowManageChatSessionSC : Send an administrative message to launch the customer side flow in the customer chat window. The message we are sending is a formula fields: “lwc:flow:Use_of_Funds_Customer&recordId=”+{!recordId}. The Chat Lightning Web Component Pack we have installed will react to this message and instead of displaying the message, it will launch the flow 
  • FlowManageChatSessionSC: Send the script message automatically in the chat window which is “A form regarding the use of funds must be completed, I am sending you the form in the chat window”
  • FlowEventListener: Listen to the platform event.
    • Input: we use the Case Id as the id
    • Ouput : we store the data in a variable named UseOfFund

The third node is a screen that will:

  • FlowManageChatSessionSC: Send the script message automatically in the chat window which is “Thank you for completing the questionnaire 😃, we have noted that the use of funds concerns “+{!UseOfFund}. In the demo the value for the variable UseOfFund is 🛠Renovation Work
  • Display Image
  • Display the result

We can then store the value in the Case

694 reads