Wow, it’s been a REALLY long time since I’ve posted on the blog! What a year 2020 was, and what a year 2021 is shaping up to be already. I really really want to focus on the blog this year and add more real use cases that help people solve their issues. I’ve got a lot of those because that’s what I do all day! Over the last few months, after talking about it for YEARS, my company finally has made the jump to Salesforce Communities. I was SO PSYCHED to implement this, and especially to implement a self-service support community, because Service is a big deal to me. It actually only took about a day to implement the community using the Customer Service template, but its a bunch of little stuff that is taking more time. Stuff that you would assume should be out of the box but just isn’t unfortunately. In this post I’m going to focus on one of the biggest head scratchers I’ve found: when you add a new post to the case using Chatter, the customer is not notified. And likewise, if the customer adds a new post to the case using Chatter, the case owner is not notified. Say what now?
I was SUPER confused about this at first. We are all so used to the behavior of Case Comments, I must have just been missing something. I frantically searched all the Community settings, Support settings, Chatter settings… I googled, I forumed, I communitied… and it’s just not a thing. It seems so crazy that this is not an out of the box feature, but it’s okay, because with the power of the Platform we can build this out ourselves. All those Chatter posts are actually part of an object called FeedItem, and we are able to access this in a Flow to do everything we need to do. So, let’s get started!
Flows for the Win!
I love Flow, and it seems Salesforce is pushing more and more into Flow instead of say Process Builder. You can also access the Feed Item object from Process Builder, and could probably get to the same solution there. But… Flow! To get started, create a new Flow. I chose to set this as a Record-Triggered flow, and am setting it as After Save. This way we don’t need to use Process Builder or anything else to launch our flow, it does this all by itself and behaves more like an Apex Trigger. For the object, you’ll select Feed Item, and since I’m setting this up specifically for my customer support community, I only want this to run on cases so I need to create a condition for that. I added a condition where the ParentId (the record the Feed Item is attached to) starts with 500, which is what all Case Id’s start with.
Next we’ll do a Get Records so that we can reference fields from our Case downstream and know things… like who the case owner is and stuff. So you’ll set the Object as Case and then we want to find the Case whose Id matches the ParentId of the record that triggered the flow. We’ll only want to save the first record, and I have it set to automatically save all fields because I wasn’t sure what I would want in the end, but you could probably get away with just saving the Contact and the Case Owner.
Okay, so now we have our record that triggered the flow and also all the case information that we need. Next, we’re going to do a decision. We may or may not need this. I chose to do different email templates depending on if it was the case owner posting or the customer, but if you were going to use the same email template for both cases then you wouldn’t need this step. But I did, so here it is! To determine is the Post was created by a Customer, I’m checking the Created By Id, and more specifically the Profile of that person and setting it to the name of my Community profile. I’m also doing a check here to make sure the Case has an Owner that is a User, not a Queue. I don’t want to send this email to a Queue. If you want to do that, just omit that second condition and continue on.
To check if it came from an internal person, I’m using similar criteria but just saying that the Profile does not equal that Community Profile. I’m also checking here to see if the Post was made public. That is set on the Feed Item record and is easily checked.
Now we just need to send our email notification!
Send Better Email
Just a side not here, that I am not using the core Send Email action that comes with Flow. I’m using this amazing Send Better Email package from UnofficialSF.com. Without it, you can only send text emails and they are ugly and plain and boring. With it, I’m able to send HTML emails and take advantage of the Text Template resources from within Flow, and you can also use it to send Classic or Lightning Email Templates. So I recommend getting that for sure!
I used a Text Template with rich text to create my email body, and a plain text Text Template for my Subject Line. And here’s what the final Flow looks like. Its short, simple, and gives me just what I need to keep everyone productive and best: Posts don’t fall off the face of the Earth because no one knows they exist.
I hope this helps you or someone else as much as it helped me! Setting up Communities has been a blast and I really hope I can expand on this new knowledge this year to do more cool stuff with them! This Flow could also be used as a starting point for all Feed Item notifications. Instead of checking that the ParentId is a case in the entrance criteria, maybe make it the first decision – that way you can build out notifications for more objects and do other cool stuff! With Flow, the possibilities are nearly endless.