Sending ‘Custom Slack Notifications’ from Salesforce 💬
These custom notifications are different from Standard Slack notifications and the messages we send using ‘Custom Message Destinations’ under — ‘Slack Setup’ app> Automation Configuration — in Salesforce using Flow or Process builder. We’ll be using Flows in this blog post.
Business use case: 🛄
Many times, businesses require that the ‘messages’ Salesforce sends to Slack, on a particular event or trigger, must be defined by the business and should be configurable as per the current Salesforce record, using merge fields.
💭Let us consider a scenario where an Opportunity record is updated🔼 with Lead Source = Web having Type = New Customer to a Stage = ‘Value Proposition’, we must notify our Slack channel with a configurable, customized** notification. The sample value is given below:
** Modify this sample custom notification template as per the need.
Sample Custom Notification we need to send:
Title:
Congratulations 🎉 Opportunity <Opportunity Name> sent with Custom Slack Notifications 📝
Body:
— — — = Custom Slack Notifications 🌩️⚡ from Salesforce = — — — —
This is the perfect use of ‘Sending Custom Slack Notifications from Salesforce’ 📬
** Modify this template as per the business need ** 📝The stage of <Opportunity Name> is now <Opportunity Stage Value>.
The estimated amount of this opportunity is 💰 <Opportunity Amount Value>.
Lead Source: <value>
Type: <value>
— —— = Custom Slack Notifications 🌩️⚡ from Salesforce = — — ——
Well, let’s start building the solution now.
Custom Slack Notifications in Salesforce ⛅️
Note: Before starting building the solution, make sure to take care of the prerequisites mentioned in my another post: Initial ‘Salesforce -Slack setup’ and at least one of : Sales or Service Cloud for Slack app is configured.
Since Custom Slack notifications are distributed over a preconfigured app(Sales Cloud for Slack in this case), make sure prerequisites are taken care before proceeding to next steps.
What are Custom Slack notifications? 💬
- Create custom notifications that appear on Slack when important events occur, configured under Setup > Notifications Builder > Custom Notifications. With them, we reach our users on Slack with important, customized notifications. More details here.
- Use a flow in Flow Builder or the invocable action API to send these notifications.
- To show record-specific information in your Slack notification, include merge fields in the notification content.
Creating a Custom notification in Salesforce 🌩️
Defining the custom notification’s details, selecting which Slack app distributes these notification, and then configure the Slack message.
- Go to Setup > Notifications Builder > Custom Notifications
- Create a New ‘Custom Notifications Type’, Select Slack, and click Next
- Give it a Name, select Object as Opportunity, a meaningful Description, and click Next.
- Now, Select your Distribution app, as configured in the prerequisites. In our case, we have configured Sales Cloud for Slack already between Salesforce and Slack, so let’s select it and click Next. In case, Service Cloud for Slack is also configured, you would see both options here.
- Now define your notification content. As per our requirement, prepare the title and the body text, using merge fields.
- Optionally, you can add the Supported buttons for the selected object and click Done. In our case, we are adding Edit & View Opportunity.
Once configured, Title and Body text should look like, as below.
Title:
Congratulations 🎉 Opportunity {!Record.Name} sent with Custom Slack Notifications
Body Text:
This is the perfect use of ‘Sending Custom Slack Notifications from Salesforce’ 📬
The stage of {!Record.Name} is now {!Record.StageName}. The estimated amount of this opportunity is {!Record.Amount}.
Lead Source: {!Record.LeadSource}
Type: {!Record.Type}
Button Action: View Record
Button Label: View {!Record.Name}
Button Action: Edit Record
Button Label: Edit {!Record.Name}
— — — — — = Custom Slack Notifications 🌩️⚡ from Salesforce = — — — —
- ✅ With this, the custom notifications setup is completed. We would be using our newly created custom notification in the Flow.
Finally, prepare your Salesforce flow 🌼
- From Salesforce setup> Flows and create a new Record-Triggered flow on Opportunity object using the conditions as mentioned in the business use case and the trigger should be: a record is updated. Refer to the below screenshot for the initial flow setup. Click Done.
- 👆 Make sure you select the ‘When to Run the Flow for Updated Records’ 🏃 option carefully. The second option is the preferred choice to avoid unnecessary hits.
- Now the initial flow should be as below in the flow builder:
- Since the custom notifications are sent to a group of recipients, we need to create a new collection variable in the flow.
- Between the Start and End steps, add an assignment step and assign the current record owner Id. In actual projects, it can be your Account Team Members or Opportunity Team Members Ids.
- Now, finally, call the newly created Custom Notification action ‘Opportunity — Value Proposition — Notifications’ by adding a Flow > Action, Under Category: Notifications, type in and search your newly created custom notification ‘Opportunity — Value Proposition — Notifications’
- Give it a meaningful Label name and Description.
- Under Set Input value: Pass the collection variable recipientId to Recipient IDs & current opportunity record Id {!$Record.Id} to the Record Id input variable. Click Done.
- The final flow should look like the below. Add or Remove steps as per your business need to make the flow performant.
- Save the flow, give it a meaningful name, say, ‘Send Custom notifications From Salesforce to Slack for Oppty’, and finally Activate.
It’s time to test your Flow and Slack notification 💬
- In Salesforce, open the Sales cloud app and then any existing Opportunity record. Make sure Stage is changed to ‘Value Proposition, with Type = New Customer and Lead Source = Web, and Save the record.
and Voila 🎉🥳🎊.
Open your Slack workspace under the ‘Sales Cloud for Slack’ app, you see a new custom Slack notification, merged with Opportunity record field values.
Tip of the day: 💁♂️💁
From Setup, in the Quick Find box, enter Notification Builder, and then select Notification Delivery Settings. Select the available notification type with Slack option Selected, and select Clone from the dropdown menu to resue and quickly build using existing notifications. Refer some considerations while using them.
Congratulations, it confirms that “Sending Custom Slack Notifications from Salesforce 🌩️” is working perfectly.❤️
Related Articles:
Developer details:
- Twitter: @sombirsheoran
- LinkedIn : https://www.linkedin.com/in/sombirsheoran
Please reach out to me for any suggestions or feedback. Would love to hear them❤ If you loved this post, please applaud at the end of this post with a 👏