Is there a way to auto add a group "@" mention to a chatter post? Have a use case for when a specific business group posts, there is a chatter group that should ALWAYS be mentioned and the client wants this auto added so that there is no possibility of the user forgetting and the post gets missed.

I have tried using a Process to call a Flow to add in the "@Group" or "@[Group]" tagging to the body of the FeedItem after it is created or create a new FeedComment with the same tagging, but it just shows up as text and does not "trigger" the group to be called out.

Here is details on the Flow and what happens on the chatter post: Variable that takes the existing body and adds chatter tags in multiple attempts, using both specific text, reference to variables that hold text or ownerID as is in the example on the help article (https://help.salesforce.com/articleView?id=process_action_post_mention.htm&type=5): Screenshot of Flow Variable that merges Body variable with chatter attempts

Here is what happens on the Chatter post: Screenshot of resulting chatter post that does not have hyperlink references

1 Answer 1


I just spent ~3 hours on this and found a solution. Even am new to the chatter content, so excuse me if I miss something. The following trigger works in my dev org. You might have to add some more conditions in the code because the below code is going to update ANY post by mentioning the current group (ParentId). But this should put you in the right direction.

Find the documentation of Connect API here

trigger addToBody on FeedItem (after insert) {
    String communityId = Network.getNetworkId();

    for(FeedItem post : Trigger.new){
        ConnectApi.FeedEntityIsEditable isEditable = ConnectApi.ChatterFeeds.isFeedElementEditableByMe(communityId, post.id);
        if (isEditable.isEditableByMe == true){
            ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput();
            ConnectApi.MentionSegmentInput mentionSegmentInput = new ConnectApi.MentionSegmentInput();
            ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput();
            ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput();

            messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();

            textSegmentInput.text = post.Body.StripHtmlTags() + ' \n';

            mentionSegmentInput.id = post.ParentId; //Your business group that needs to be mentioned

            feedItemInput.body = messageBodyInput;

            ConnectApi.FeedElement editedFeedElement = ConnectApi.ChatterFeeds.updateFeedElement(communityId, post.id, feedItemInput);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .