function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Matt Brown 71Matt Brown 71 

OmniRouted Chat Ended Callback In Lightning

Is there a way to detect in realtime (or near realtime) when a chat routed in omni (lightning) ends?

Current solutions we've explored / tried:
  1. Leveraging the Live Agent API, there is no method to get the current status of a chat or anything for us to see if chat has ended.
  2. Looking at LiveChatTranscript Status field, this doesn't get updated until after the agent closes the chat tab.
  3. Looking at LiveChatTranscriptEvent object, this too doesn't get written until after the chat tab is closed.
  4. Looking at tab info, we noticed a blue asterisk that appears in the tab when a chat is in progress, that goes away after it ends.  We thought to look in tab info for a boolean that gets flipped, but that turned up nothing.  There was no changes in the tab info from during the chat, to after it ended.  Nothing we could use here.
In case it was missed above, we're using omni routing in the "lightning experience", which pretty much wipes out all of the normal methods we'd use to tackle this, such as the `onChatEnd` method for classic console.  Can't use any of that in lightning.

You may be asking yourself "why don't you just wait until agent closes their tab".  Well, we'd love to, but the requirement is for us to leverage the omni api (specifically closeAgentWork) to clear the chat work item from omni BEFORE they cose their tab.  We have issues with agents leaving their tabs open by mistake and not getting routed new chats because of it.  So we need to clear omni work items for them as soon as the chat ends, but before they close their tab.

We've got the clearing of agent work worked out OK, we just need to automate it to a chat ending now.  Our organizations switch to lightning is depending on getting this sorted, so any ideas (even the obtuse ones) would be genuinely appreciated.
Best Answer chosen by Matt Brown 71
Matt Brown 71Matt Brown 71
Found a resolution for this.  Our salesforce rep was able to talk to some engineers / developers and some new callbacks for a chat ended event are being added shortly.  It looks something like this:
<!-- Lightning Component -->
<aura:handler event="lightning:conversationChatEnded" action="{!c.onChatEnded}" />
<lightning:conversationToolkitAPI aura:id="conversationKit" />

<!-- Lightning Controller -->
onChatEnded : function(cmp, evt, hlp) {

    var conversation = cmp.find('conversationKit');

    var obj = {
      recordId: evt.getParam('recordId'),

    // handle chat ended logic here

This is currently available in sandbox instances and according to our rep, is set to be release with the Summer '18 push.  I'd link to documentation for this ... but at the time of this writing, there is none.