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

::::::tabset{tabs='[ "Develop", "Specifications"]'}

:::::tab

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.

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

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

({
  getQuote: function (cmp, event, helper) {
    // get quote from the source
    var compEvent = cmp.getEvent("sendChatterExtensionPayload");
    compEvent.setParams({
      payload: "<payload object>",
      extensionTitle: "<title to use when extension is rendered>",
      extensionDescription: "<description to use when extension is rendered>",
    });
    compEvent.fire();
  },
});

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

<aura:component implements="lightning:availableForChatterExtensionRenderer">
  <aura:attribute name="_quote" type="String" />
  <aura:attribute name="_author" type="String" />
  <aura:handler name="init" value="{!this}" action="{!c.init}" />

  <div class="container">
    <span class="quote" aura:id="quote">{!v._quote}</span>
    <span class="author" aura:id="author">--- {!v._author} ---</span>
  </div>
</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.

:::::

:::::tab

Attributes

Name Description Type Default Required
extensionDescription The description for the extension to be saved with the feed item. string Yes
extensionThumbnailUrl The thumbnail URL for the extension to be saved with the feed item. string
extensionTitle The title for the extension to be saved with the feed item. string Yes
payload The payload data to be saved with the feed item. object Yes

:::::

::::::