Flows | How to Send Custom Notifications from Flow

In this post we will see how to use or Send Custom Notifications from Flows in Salesforce. We will combine two new and powerful features of Salesforce i.e. Record Triggered Flows and Custom Notification Builder to make life easier for End Users so that they are able to keep a track of important events/notifications/updates on records that they are working on. 

Salesforce Flow Custom Notifications can be achieved by using Flow Core Action : Send Custom Notification which we will see later in this article.

We will also see one Important and Tricky Technique : How to get ID of Custom Notification Type in a Flow directly? 

Don't worry if you are not familiar with the concept of Custom Notification Id as we will see this in the article later.

How to Use Salesforce Flow to Send Custom Notifications?

How to Use Salesforce Flow to Send Custom Notifications?

In Simple words we can use a Flow Core Action : Send Custom Notification. We will see later in Article how to use this. Let's first see an example Scenario and Use Case.

Use Case: In this article, I will use a simple and a common use case where we need to Notify Case Owners about New or Incoming Emails on Cases. Basically, Case Owners should be able to Track any New Emails on any of the Cases they are working on directly from their Salesforce Notification Icon. This is one of the most common requirements in Service Cloud Implementations in Salesforce so here I am presenting one of a way to achieve this using Flow with Custom Notifications.

Note: Checkout my Previous Article about another approach related to this same Use Case here: Use Flow to Track New Incoming Emails on Cases

Main Takeaways from this Article:

1. How to create a New Custom Notification in Salesforce?
2. How to create a Simple Record Triggered Flow on Email Message Object?
3. How to Use or Send Custom Notifications from Record Triggered Flows in Salesforce?
4. How to Get Id of Custom Notification Type in Flows?
5. How to Notify Case Owners or about New Incoming Emails on Cases using Custom Notifications?

Why and When to Use Custom Notifications in Salesforce?

1. Reduces dependency on Notification Emails : Let's face it, nobody likes to be spammed with 100s of Emails daily. And also there is a very huge chance that users miss some of them or don't even bother to see Email notifications messages. Also, if we use email notifications, we need to jump screens from Email Inbox/Client to Salesforce which is not always desirable.
2. User Friendly and Easy to Manage: No need to switch Apps and everything resides within Salesforce Screen. No Screen Refresh Required as this notification appears automatically on any current Salesforce Page that you are logged in.
3. Mobile Push Notifications: If using Salesforce Mobile App, it can be used to show Push Notifications on Mobile Screens similar to other apps like Twitter, Instagram etc. 

How to Create a New Custom Notification in Salesforce using Notification Builder?

1. Go to Settings > Notification Builder > Custom Notifications
2. Click New
3. Provide a Name and Desired Channels and Save the record.
Custom Notification in Salesforce

Things to Remember for LateR Use:
1. Name of the Custom Notification : "Case Email Notification" 
2. API Name/Developer Name: "Email_Notification"  - This is more Important as we are going to use this Later in our Flow.

How to Send Custom Notifications from Salesforce Record Triggered Flows?

We are designing this Flow for our use case where we need to Notify Case Owners about New or Incoming Emails on Cases. Let's first take a look at our Flow Design and how it will look like once completed. See closely which different Flow Elements are used here as we will see how to use them individually later.

I have added all the Steps later to create this Flow. Also, I have added a Short Video at the end to show all steps in detail.
Send Custom Notifications from Flows in salesforce
Steps to Create this Flow and Implement our Use Case ( Steps Video Also at the End)

1. Create a Record Triggered Flow on Email Message Object

We will create an After Insert Record Triggered Flow on Email Message Object. We need to use After Trigger and not Before Trigger because we need to send this custom notification after the Email Message is created.
Salesforce Flow Custom Notification
Conditions/Criteria to Fire this for After Insert Record Triggered Flow on Email Message:
Incoming = True
Send Notifications from Flow

This criteria is a minimum essential criteria because we need to fire this Flow only if the Email Message was created for an Incoming Email into Salesforce and not any outgoing Email.

Note: Email Message is created in Salesforce for any Outgoing as well as Incoming Email into Salesforce. So that's why we use Incoming (which is a boolean field on Email Message Object) as a way to filter only incoming Emails in Salesforce.

This is how the Element will Look Like after this.
Send Custom Notifications Flows

2. How to Use Flow Core Action : Send Custom Notification ?

Before we move forward, I want to discuss how to use Send Custom Notification Core Action in Flows. 
This is an Out of Box Core Action Available for use in the Flows. It has many Input Values that are required in order to configure and Use it. Let's see how to use these values and where to get their Data from.

The Required Input Values are as shown in Screen Shot Below:
Send Custom Notification from Flow

We will go through all of them but The most Important and Tricky one is Custom Notification Type ID. Let's first see about the Custom Notification Type Id.

How to Get Custom Notification Type Id or ID of Custom Notification Type in Flows?

This a small gap in Salesforce Custom Notification Builder Functionality. The Problem is that we cannot find out directly the Id of the Custom Notification Record. And it's a problem because this ID is required in Send Custom Notification Action from Flows or any other place in Salesforce.

For example, I created the Custom Notification : "Case Email Notification" above in the article. But there is now way to find/know the Id of this Custom Notification directly as we can do for other Salesforce features like Records, Record Types, Profiles directly from the URL.

Here are some great Articles from Narender Singh : forcePanda Blog and Parul Singh about ways to get Custom Notification Type Id in Salesforce.

1. From forcePanda: Get Custom Notification Type Id

But in Flows, we can get the Custom Notification Type Id directly too. It is up to you on how you want to fetch and use this ID.

Let's see how to get this Id in a Flow directly using a Get Record Element.

We just need to query on Object Named "Custom Notification Type"

Condition : Developer Name = API Name of Custom Notification which in our case is "Email_Notification" as seen earlier.

Note: As we need only one Id and it is a single record, just use the option "Get only the First Record " in Get Element. Checkout below Screen Shot.
Custom Notification Id in Flows
ID of Custom Notification Type in Flows

Important : Since we are querying on the object, we will get all the Field Values (including Custom Notification Id) of this Record after the Get Record Element and all the Field values will be stored in the Variable "Get Custom Notification Id " which is the Name of our Get Element.

Note: To fetch the Custom Notification Id field value from this Record Variable we just need to do {!Get _Custom_ Notification _Id.Id} which we will see later.

So, till now we have managed to get the Id of the Custom Notification we created within The Flow. This Id we will use directly in our Send Notification Flow Core Action later.

Now we need some other values to provide to the Send Notification Flow Core Action. First we will see about the Recipients Ids which is also a required Field in this Action.

3. Assign Recipient Ids using Assignment Element

This is needed in order to determine and tell the Flow to which users should the Custom Notifications be sent to. 

Important: We can provide Recipients ID value in Flow Action : Send Custom Notification only by using a Variable and Assigning a value to that Variable using Assignment Element and not through hardcoding the value into the Action directly. 

Basically, you can Hardcode Ids in a new Variable using an Assignment Element but cannot hardcode directly in the Flow Action 

As per Salesforce Official Documentation : 

  • To add recipients, define Recipient ID as a resource. Then add values to your Recipient ID collection by adding the Assignment element to your flow.
Also, these are the valid Id types: 

Salesforce Flows Notifications

In our case, I am using only User Id as a Recipient which is the Owner Id of Parent Case of the Email Message. 

Note: Email Message has a Master Field named Parent which is the Case Id on which the Email is received. 

Step 1: Create New Collection Variable of Type Text to hold Recipient Ids. (Click on Allow multiple values(collection)
Flow Custom Notifications
Step 2: Use Assignment Element to add Ids to Recipient Ids Collection Variable created

We can use "Add" operator in Assignment Element to add multiple values of same or different types. The variable name is "NotificationRecepients" {!NotificationRecepients} as we created in Last Step. I am just using one row of Add operator just to assign the value of the Email Message's Parent Cases's Owner Id

Note: You can assign multiple owners or other Ids (Example Queue Ids or Group Ids) as per the table I shared above to send this notification to. But I am only using one in my case. To add other Ids, just use the Add operator again in next row and provide the hardcoded Id or from any variable. We can even provide hardcoded Ids here using Add operator.
Salesforce Flow Custom Notification Builder
Important: Since this is a Record Triggered Flow, we have all the field values of the Record that Triggered this Flow in the variable $Record. This variable is available to use anywhere in the Flow. So I am using $Record.Parent.OwnerId here to get the Related Case Record's Owner Id since Parent here is the Case Record on which Email Message is received. 
See Image for better clarity or representation.
Flow Notification Builder
So till now we have got Custom Notification Id and Recipients Ids which we need to provide in the Flow Action as we saw earlier.

But there are Two more Required Fields left as per the screen shot I shared earlier. They are Notification Title and Notification Body. 

We can directly hardcode or provide a message directly in these fields but I am creating a new Formula Type Variable to show a message with Case Number which will be dynamically populated based on the Case Number of the Parent Case Record of the Email Message that fired this Record Triggered Flow.

ScreenShot below
Flow Custom Notifications Salesforce
{!$Record.Parent.CaseNumber} is the formula to get the Case Number from the Email Message Record.

I will use this same Variable for both Notification Title and Notification Body.

Finally, Let's Configure the Flow Action : Send Custom Notification

4. Configure Send Custom Notification Custom Action

We now have all the required Field Values to provide to this action from the steps above.

Also, apart from this we will provide one more value "Target ID" in this action.
This will be just the Record Id of the Email Message that Fired this Flow {!Record.Id}

See the ScreenShot Below with all the values provided into this Action.
Salesforce Flow Custom Notifications
Checkout a Short Video with all the steps done above in the article for a Quick Recap and better clarity.

Flow Builder Video and Steps:

That's it! Save the Flow and Activate it.
 
Now whenever an Email is received on a Case, Case owner will be notified through a notification on the Bell Icon. 
Flow Custom Notifications Salesforce

 
Flow Custom Notifications Builder

This is a very basic example to show this capability. This powerful feature can be used in many ways to deliver custom notification messages to Users in many different scenarios. 

Hope this Helps! Reach out to me here or on LinkedIn for any questions, issues or suggestions. Happy to Help!

Don't Miss Latest Posts :  CLICK HERE TO SUBSCRIBE TO THIS BLOG

Checkout this Article for all Flow Related Scenarios : All Flow Examples

See you next time..

Comments


Never Miss Latest Posts