Send Chatter Extension Payload

lightning:sendChatterExtensionPayload

For Chatter Rich Publisher Apps only. Sends the payload and metadata that needs to be saved for the extension with the feed item.

For Use In

Experience Builder Sites

lightning:sendChatterExtensionPayload is a component event that sends your custom component’s payload into a Chatter feed. You must use this event with the lightning:availableForChatterExtensionComposer and lightning:availableForChatterExtensionRenderer interface to make your component available to the Chatter publisher.

Rich Publisher Apps are available to Experience Builder sites in topics, group, and profile feeds and in direct messages.

For example, you can create a custom component that generates a random quote in the Chatter feed.

1<aura:component implements="lightning:availableForChatterExtensionComposer">
2  <aura:handler name="init" value="{!this}" action="{!c.init}" />
3  <div class="container">
4    <span class="quote" aura:id="quote"></span>
5    <span class="author" aura:id="author"></span>
6    <lightning:button label="Get next Quote" onclick="{!c.getQuote}" />
7  </div>
8</aura:component>

In your client-side controller, fire the lightning:sendChatterExtensionPayload event with your payload.

1({
2  getQuote: function (cmp, event, helper) {
3    // get quote from the source
4    var compEvent = cmp.getEvent("sendChatterExtensionPayload");
5    compEvent.setParams({
6      payload: "<payload object>",
7      extensionTitle: "<title to use when extension is rendered>",
8      extensionDescription: "<description to use when extension is rendered>",
9    });
10    compEvent.fire();
11  },
12});

Next, create a custom component that implements the lightning:availableForChatterExtensionRenderer interface to determine how the quote is displayed in the Chatter feed.

1<aura:component implements="lightning:availableForChatterExtensionRenderer">
2  <aura:attribute name="_quote" type="String" />
3  <aura:attribute name="_author" type="String" />
4  <aura:handler name="init" value="{!this}" action="{!c.init}" />
5
6  <div class="container">
7    <span class="quote" aura:id="quote">{!v._quote}</span>
8    <span class="author" aura:id="author">--- {!v._author} ---</span>
9  </div>
10</aura:component>

Finally, create a ChatterExtension object in your org and make the components available in the Chatter Publisher via the Administration page in Experience Workspaces.

For more information, see the Lightning Aura Components Developer Guide.

Attributes 

NameDescriptionTypeDefaultRequired
extensionDescriptionThe description for the extension to be saved with the feed item.stringYes
extensionThumbnailUrlThe thumbnail URL for the extension to be saved with the feed item.string
extensionTitleThe title for the extension to be saved with the feed item.stringYes
payloadThe payload data to be saved with the feed item.objectYes