From Gerald: Using Flow to Create a Synchronized ‘Co-Work’ Chat Session

Gerald Ehret-Franck is a Salesforce Principle Solution Engineer (previously he came from Rivia) who has crafted a powerful combination of extensions that enable flows to be inserted into chat sessions and used to managed those same chat sessions. The pinnacle of his achievement, though, is this surprisingly easy-to-implement synchronized coworking solution, where agents can see and assist their users in real time.

Why doing so? This will help you create great experience from both the Customer and Agent perspective in order to :

  • Improve Customer Satisfaction and Loyalty
  • Improve Agent efficiency and Reduce Average Handle Time
  • Improve Quality by reducing copy/paste error


Overall Architecture


This example describe the configuration used for the demo above


You will need to install the packages from these three extensions:

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

More information about Platform Event on Salesforce Help.

How does the id get used? Let’s say you’re having two customers (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 want 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’s 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 be 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 Permission

You need to create a permission set to allow users to create and read the Platform Event created. A platform event is a Salesforce Object and will appear as any other objects in the “Object Settings” section of your permission set. You should assign the proper permission to both internal and external users.

More information about Permission Set on Salesforce Help.

Step 3 – 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 4 – Create a lightning component to listen to the platform event

Refer to following post.

Step 5 – 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.