Ends a chat in which an agent is currently engaged. This method works only in Lightning console apps.
Arguments
| Name | Type | Description |
|---|---|---|
argumentObj |
Object | An object containing all the arguments to be passed into this method. |
argumentObj
| Name | Type | Description |
|---|---|---|
recordId |
String | The ID of the chat that you want to end. |
Sample Code
This example ends the chat and logs the result.
Component Code:
<aura:component implements="flexipage:availableForAllPageTypes" access="global" description="Conversation toolkit api sample">
<aura:attribute name="recordId" type="String" />
<lightning:conversationToolkitAPI aura:id="conversationKit" />
<ui:button label="endChat" press="{!c.endChat}" />
</aura:component>
Controller Code:
({
endChat: function(cmp, evt, helper) {
var conversationKit = cmp.find("conversationKit");
var recordId = cmp.get("v.recordId");
conversationKit.endChat({
recordId: recordId
})
.then(function(result){
if (result) {
console.log("Successfully ended chat");
} else {
console.log("Failed to end chat");
}
});
}
})
Response
Returns a Promise. Success resolves to true. The Promise is rejected if there's an error.