End Chat in Salesforce Service Cloud Web Chat

Pranjal Gangrade
3 min readFeb 11, 2022

Scenario: Add custom action/intervention post End Chat in the Service Cloud Web Chat functionality.

Background:

In Web Chat, the salesforce maintains all the conversation in the standard object known as LiveChatTranscript. Also, to maintain any activity on the same, those details are getting stored in another standard object known as LiveChatTranscriptEvent.

The event object can be very useful when we need to track the activities on any particular chat such as Chat Acceptance, Conference, End chat, etc. Sadly, this object will only be helpful if we need some operations to be initiated in the background.

To include certain actions based on the chat agent/visitors interactions in the UI, salesforce has provided some events in the AURA components under the lightning namespace.

Out of the box, Salesforce doesn’t allow Agent/Visitor to End the chat with an additional validation/action like update related records fields, etc.

As part of the current Scenario, the helpful event is conversationChatEnded. This event gets fired when the Agent/Visitor requests for the End Chat.

Approach:

Please find below-mentioned the steps to achieve the use case.

  1. Create a Lightning Aura Component that will register the event handler for lightning:conversationChatEnded
  2. Based on the fired event, the controller handler method will help the use case to execute.
  3. Add the component on the Lightning record page of the Chat Transcript object.

Example: Let’s say I want the service agent to update the linked Case Reason field after ending the chat.

Solution:

  1. Create a lightning Aura Component named webChatEndComponent. Please refer to the below code snippet.
webChatEndComponent.cmp

2. Create a LWC/Aura Component webChatPostEndChat for building the UI. Note: Here we can add the UI code in the webChatEndComponent AURA component as well. Please refer to the below code snippet.

webChatPostEndChat.html

--

--