Salesforce Chatter enables Salesforce users to connect, share information, and collaborate in real-time. It functions as a social media-like newsfeed with interactive threads for each post. Users can post updates to Chatter and other Salesforce users can comment, like, or share it. Moreover, it is possible to mention other users and put links to records too. This makes Chatter a very useful tool for the users. Although users can manually post to Chatter, it is possible to automate this process too.
Here are different ways of posting to Chatter from Salesforce Flow.
1- Using the Standard Post to Chatter Action
This standard action lets the users post a message to a specified feed, such as a Chatter group or an opportunity record. It supports having mentions and topics in the message. However, posts must be plain text, it doesn't support posting rich text.
In order to use this action, add an Action element and choose Post to Chatter.
Input Values
- Message: It is the text that you want to post to Chatter. You can provide any type of single-value resource. The limit is 10,000 characters.
- Target Name or ID: It is a reference to the user, Chatter group, or record whose feed you want to post to. It is possible to provide any type of single-value resource.
- In order to post to a user’s feed, enter the user’s ID or username. For instance: [email protected]
- In order to post to a Chatter group, enter the group’s name or ID. For instance: US Sales
- In order to post to a record, enter the ID of the record. For instance: 5001n000021diorAAA - Community ID: It is the ID of an Experience Cloud site to post to. If you are posting to a user or Chatter group that belongs to an Experience Cloud site, this parameter becomes mandatory. It is possible to provide any type of single-value resource.
- Target Type: This parameter becomes mandatory only if Target Name or ID is set to a username or a Chatter group name. Valid values are "User" or "Group".
- Visibility: This parameter makes the feed item available to Experience Cloud site users. In order to make it visible only to internal users, set it to internalUsers. Valid values are "allUsers" or "internalUsers".
This action returns the Chatter post's ID as the output.
The best practice is to create a text template for the message. Here is the format that you should follow.
- Use @[reference] in order to mention a user or group. Replace the reference with the ID of the user or group that you want to mention. For instance: @[{!$Record.OwnerId}].
- Use #[string] in order to add a topic. Replace the string with the topic that you want to add. For instance: #[Product Support].
It is not possible to use "/" to add a link to a record. However, you can create a record link and add it to the message.
At the end, it creates a Chatter post like this.
2- Using the Create Records Element
In order to post to Chatter, add a Create Records element and select Feed Item as the object.
Parent Id means the Target Id (user, group, or record ID) and Body means the message that you want to post. It is possible to post a rich text as well. In order to do so, prepare a text template with HTML tags and set IsRichText to true. However, in this option, it is not possible to mention users.
This object has a few more fields. Read this official article to learn more about them.
Here is a plain text template with HTML tags. This way, you can post a rich text to the Chatter. Pay attention that only a limited number of HTML tags are available.
At the end, it creates a Chatter post like this.
Summary
There are two different standard ways to post to Chatter using Salesforce Flow. Although the second option with Create Records element allows posting a rich text, it has some limitations. Therefore, unless you really need to post a rich text, it is recommended to use the standard Post to Chatter action.
Leave a Reply