How to Send Messages from Salesforce in Slack? : Sparkybit

How to Send Messages from Salesforce in Slack?
by: Sparkybit
blow post content copied from  Forcetalks
click here to view original post

In this article, we will discuss how to send messages from Salesforce in Slack using Flow.

If you don't have a workspace in Slack yet, it's time to create one. Slack documentation will help with this task.

To work with Slack in Salesforce, you need to integrate Slack workspace and Salesforce org. Let's start with the Salesforce environment. In Setup, go to Slack->Initial Slack Setup. You will see the following steps to set up Salesforce for Slack:

1. Accept the terms and conditions for the Salesforce Slack Integration Service.

2. Select the programs you want to make available to users (for example, Sales Cloud for Slack).

3. Go to the Permissions Sets tab. There a new one should appear - Sales Cloud for Slack. Assign it to your Salesforce user. This step is needed to give Slack access to Salesforce. Otherwise, you will receive an error, saying “You don’t have the user permissions to access this Slack app.”

Permissions Sets tab

4. Customize access to records according to your needs.

5. Go to Slack and download the Salesforce for Slack application or just follow this link:

The cornerstone of Salesforce for Slack apps

6. If you see a Connect button, click it to integrate Slack workspace to your Salesforce organization. Sign in into your Salesforce org and click Allow.

Salesforce for Slack requesting permission
You can check whether the connection is successful in two ways:
  • In the Messages tab, type /sfhq-connect and send the message. The answer should be:

You've already connected the Salesforce for Slack app to your Salesforce instance
  • Сlick on the user icon in Salesforce and go to Settings-> Slack-> Slack User Mappings. You will see the connected Slack user there.

Slack User Mappings

Congratulations! You have set up the Slack and Salesforce integration. Now we can move on to creating the Flow. In this article, we'll take a look at how to send messages in Slack using Record-Triggered Flow and Screen Flow.

Record-triggered Flow creation

Let's say we need to send a message in Slack when an Account is updating. So, we choose the Record-Triggered Flow for updating the Account.

Since this is a Record-Triggered Flow, it is impossible to do any actions with Slack in the Run Immediately path, so let's create a Scheduled Path and select the shortest execution time - 1 minute after the record is updated. Time Source select Account: Last Modified Date.

Configure Scheduled Paths
Next, we add the Action element. In the Slack tab, select Send Slack Message.
Send Slack Message
Send Message to Channel
  1. Slack App field. Select the connected app in Slack; in our case, it is Salesforce for Slack.

  2. Slack Workspace field. Select your connected workspace.

  3. Execute Action As field. Select Slack App.

  4. Slack Message field. Write the message you want to send or create a Text Template resource.

  5. The Slack Conversation ID field. Enter the ID of the Slack channel (you can find it by right-clicking on the channel, then selecting Views channel details on the About tab at the bottom, you will find the channel ID).

The Slack Conversation ID field

Or just copy the Slack channel link. That's how it looks like:

channel_not_found error

Note: If you want to message a person personally, then the user's Channel ID will not work. If you run the Flow through Debug, you will get a channel_not_found error.

To send a message to a specific user, go to the user's Salesforce Settings, find the Slack Mapping Users tab, and copy the Slack User Id. If there is no needed user, then that user should be connected via Slack, as we did when setting up the connection.

Now check if your Flow works correctly.

send Slack message from the Salesforce environment

Congratulations, you've sent your first Slack message from the Salesforce environment!

dont miss out iconCheck out another amazing blog by Sparkybit here: CRM for FinTech: Why Choose Salesforce For Fintech Companies?

Screen Flow creation

Now let's try to create Screen Flow. In this case, we can use the Slack Workspace selector and Slack Channel Selector screen components to be able to select the workspace and channel where we want to send messages without specifying a Channel ID.

The Flow consists of three Screen elements and one Action of sending a message to Slack.

Screen Flow
Slack Workspace Selector
Slack Workspace Selector has a Slack appID field - this is the Slack application id; it can be found in the application link. Find your application here:

For example, in this article, we used the Salesforce for Slack application:

Leave the rest of the fields as default.

Slack Channel Selector
For the Slack Channel Selector element:
  1. Specify Slack app id and Slack workspace id as the selected variables from the previous screen.

  2. Use Bot Token must be GlobalConstant.True to access the channel list.

  3. Leave the rest of the fields as default.

To enter a message, add a Text element to the Screen.

Now you have finished creating screens. It remains to add Action: Send Slack Message.

Action: Send Slack Message

Save the Flow, add it to the page Layout, and check the execution.

You will got the expected result.
message from screen-flow


In this article, we discovered new opportunities for Slack and Salesforce integration. However, this is only the beginning of acquaintance. In addition to sending messages, you can do other things in Flow, for example: work with Slack channels, invite new participants, edit or attach messages, and much more. In the following articles, we will continue to explore the capabilities of Slack and Salesforce.

Sparkybit, Salesforce consulting and development company. We make Salesforce perform at its best by fitting it to Clients’ custom business needs. 9 years of sharpened expertise, 25+ successful long-term projects globally.

[email protected]

Copyright belongs to Sparkybit GmbH, Im Dörener Feld 3, 33100, Paderborn, Germany.
2023 © Sparkybit. All rights reserved.

The post How to Send Messages from Salesforce in Slack? appeared first on Forcetalks.

August 22, 2023 at 05:23PM
Click here for more details...

The original post is available in Forcetalks by Sparkybit
this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.