Newer Version Available
sendCustomEvent() for Lightning Experience
Sends a custom event to the client-side chat window for a chat with a specific chat
key. 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 event that you want to customize. |
| type | String | The name of the custom event type. |
| data | String | The data attached to the custom event. |
Sample Code
This example publishes a custom event 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="sendCustomEvent" press="{!c.sendCustomEvent}" />
5</aura:component>Controller Code:
1({
2 sendCustomEvent: function(cmp, evt, helper) {
3 var conversationKit = cmp.find("conversationKit");
4 var recordId = cmp.get("v.recordId");
5 var type = "myCustomEventType";
6 var data = "myCustomEventData";
7 conversationKit.sendCustomEvent({
8 recordId: recordId,
9 type:type,
10 data: data
11 })
12 .then(function(result){
13 if (result) {
14 console.log("Successfully sent custom event");
15 } else {
16 console.log("Failed to send custom event");
17 }
18 });
19 }
20})Response
Returns a Promise. Success is indicated if the promise is fulfilled. Failure is indicated if the catch clause is invoked.