endChat() for Lightning Experience

Ends a chat in which an agent is currently engaged. This method works only in Lightning console apps.

Arguments 

NameTypeDescription
argumentObjObjectAn object containing all the arguments to be passed into this method.

argumentObj 

NameTypeDescription
recordIdStringThe ID of the chat that you want to end.

Sample Code 

This example ends the chat and logs the result.

Component Code:

1<aura:component implements="flexipage:availableForAllPageTypes" access="global" description="Conversation toolkit api sample">
2  <aura:attribute name="recordId" type="String" />
3  <lightning:conversationToolkitAPI aura:id="conversationKit" />
4  <ui:button label="endChat" press="{!c.endChat}" />
5</aura:component>

Controller Code:

1({
2    endChat: function(cmp, evt, helper) {
3        var conversationKit = cmp.find("conversationKit");
4        var recordId = cmp.get("v.recordId");
5        conversationKit.endChat({
6            recordId: recordId
7        })
8        .then(function(result){
9            if (result) {
10                    console.log("Successfully ended chat");
11                } else {
12                    console.log("Failed to end chat");
13                }
14        });
15    }
16})

Response 

Returns a Promise. Success resolves to true. The Promise is rejected if there’s an error.