0

E.g., release the capacity on the Chat end while the tab stays active?

1 Answer 1

0

The trick is to add an Aura component to the Utility bar (to ensure it oversees all chats and tabs) that uses omniToolkitApi method to release capacity after receiving the lightning:conversationChatEnded event.

HTML:

<aura:component implements="flexipage:availableForAllPageTypes,force:appHostable" access="global">
<lightning:omniToolkitAPI aura:id="omniToolkit" />
<aura:handler
  event="lightning:conversationChatEnded"
  action="{!c.onChatEnded}"
/>
</aura:component>

JS:

({
  onChatEnded: function (cmp, evt) {
  const recordId = evt.getParam("recordId");
  const omniAPI = cmp.find("omniToolkit");
  omniAPI
    .getAgentWorks()
    .then(function (result) {
      const works = JSON.parse(result.works);
      for (const work of works) {
        if (work.workItemId === recordId) {
          omniAPI
            .closeAgentWork({ workId: work.workId })
        }
      }
    })
    .catch(function(error) {
      console.error(error);
    });    
  }
});

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .