Post Rich Content to Chatter with the ‘PostRichChatter2’ Action

This action posts content to Chatter in a way similar to the built-in Post to Chatter action. It supports the subset of rich text that Chatter supports. You can pass it a Text Template with rich text formatting, or simply provide it with some HTML text.

This is an invocable action that runs in Flow Builder, Process Builder, Bot Builder, and Strategy Builder.

HTML is handled as follows:

Bold, Underline, List (Bullets and Numbers), Italics get displayed in Chatter as you would expect.

URLs get displayed in Chatter but are rendered in Chatter as clickable links

Images can be displayed inline, following this guidance courtesy of Dave Ries:

In your flow Text Template, you need to put {img:069x00000000D7m:Any Text You Want}. The ID needs to be the ID of a “ContentDocument” (File) in Salesforce, which starts with 069. The Text afterwards is optional an can be anything you want displayed as a hover-over on the image.
It’s important that there are NO spaces between img: and the ID number. I had a space in there, and it failed.

As of version 2.0:

<BR> html, which Chatter doesn’t process, gets converted to <p>, which Chatter can handle.

<strong> html, which Chatter doesn’t process, gets converted to <b>, which Chatter can handle.

Formatting Support

The following rich text formatting elements available in Flow are not supported in Chatter, so they get stripped out:

  • Indenting
  • Font Size
  • Font Family
  • Font Color

bodyStringCan be HTML, which also means a Flow Text Template with formatting. See documentation for information on how various formatting is affected.
targetIdStringCan be the id of a User or Group, the string ‘me’ (which represents the current user) or the name of a user or group. The action will first try and match this value to a known name and then assume it’s an Id.
communityIdStringIf null, the user’s current community is used.

Support for @Mentions

This action will attempt to convert any recordId it sees in the Body that is in braces to an @mention. So if you put this in a Flow Text Template:

Hey! {{!curGroup}}

and curGroup is a flow variable of type Text that contains a recordId, you’ll get an @mention in the Chatter:

Support for Images


Notes: The latest version of this action uses our modern packaging approach, whereas the original PostChatter V1.0 used an older approach. As a result, you can’t upgrade from V1.0. So the current V2 solution will install itself alongside the original version, and the files will all have a ‘2’ suffix (i.e. PostRichChatter2.cls). You do not need to keep the V1.0 around in order to use V2.

Version 2.0 7/22

Older Versions

Unmanaged Package V1.0

Source Code

View Source


This action makes extensive use of ConnectionApiHelper.