Cloudy in a Slackstar suit.

How Admins Can Connect Salesforce and Slack

By

With the Salesforce acquisition of Slack, Salesforce is realizing a major goal: to help people work from anywhere in this new all-digital world. Salesforce Admins have the opportunity to be at the forefront of this world by using Slack to surface the information their customers need when they need it.

Salesforce Admins are well-positioned to help their colleagues and companies work from anywhere by connecting the data and business processes they use in Salesforce with the contextual communication tools in Slack. Let’s dig in to understand what Slack is and how we, as admins, can help bring collaboration everywhere in our organizations.

What is Slack?

Slack is a messaging app for businesses that connects people to the information they need. By bringing people together to work as one unified team, Slack transforms the way organizations communicate.

In Slack, a workspace is made up of channels (which I’ll cover in a bit) where team members can collaborate. I say collaborate because it’s more than just messages. Channels are where Slack organizes conversations. So, as an admin, you could have a channel for the team you’re on, a project, or even an event. Channels can be private — meaning not open to all members of a workspace — or public, where anyone can join.

Think of Slack like a hub. You can connect tools from and explore the Slack App Directory, automate tasks with Workflow Builder, and create custom apps. Sound familiar?

And with Slack, collaboration is just the beginning. Like Salesforce, Slack is a platform with almost limitless potential for custom integrations, automated workflows, and solutions. In short, Slack is where the future works.

Connecting to Slack from Salesforce

Using the free Salesforce for Slack app from the AppExchange, you can:

  • View Slack messages associated with a record.
  • Send Salesforce records to Slack.
  • Set up record alerts in Slack channels.

Pro-tip: As a best practice, we recommend that you install this in a sandbox first to test-drive the features before installing in Production.

Salesforce for Slack app on the AppExchange

Follow the steps in the Configure Salesforce for use with Slack help article to configure the integration between Salesforce and Slack.

Once the package is installed, it creates a Slack Setup app in your org. This is where you configure the connection to Slack, enable custom objects, create custom alerts, and customize pages where Slack components are displayed. You can also configure the messageId destination used in the Slack invocable action called in Flow or a process.

Note: If you choose to have Slack interact with Custom Objects, additional configuration is needed. The automated activation creates a test class and trigger for you. For the manual activation step, you’ll need to create your own test class and trigger.

Slack Setup app in Salesforce.

You can send messages from Salesforce to Slack — using clicks, not code — in one of two ways.

  • Add the Send to Slack action on a Lightning record page. This allows the user to choose when to send a message to a Slack channel or user.
  • Create automation using either Flow Builder or Process Builder. This allows Salesforce to send a message to a Slack channel or user systematically based on a triggered event.

There are three ways that you can send a message to Slack from Salesforce by adding the action to the page layout:

  1. Send to Slack detail page action, with object pre-selected.
  2. Send to Slack detail page action, with no object pre-selected.
  3. Send to Slack action calling a Lightning component.

The three ways to send a message to Slack, and the message posted in Slack.

We’ll do a quick, high-level overview of how to configure Flow to send a message to Slack. Let’s introduce you to Addison Dogster, admin for Sunshine Cupcakes. Addison needs to send a message to Slack based on CSAT results manually entered into Salesforce. If the scores are all 1’s, she needs to send a DM to the district manager. Anything below all 5’s is posted to the customer-support Slack channel. Sunshine Cupcakes recently purchased a CSAT system that isn’t currently integrated with Salesforce. Hence, the manual entry. Addison, being the Flow superstar that she is and knowing that Flow Builder is the end-state declarative automation tool, configures the automation to Slack using Flow.

In order to use the Slack invocable action in Flow, you need to set up the Automation Configuration in the Slack Setup app first. In the Automation Configuration section, you set up a new message destination for every Slack user or channel you wish to use in automation to identify the message identification Id.

Here, Addison configured the message destination for Jared Dunn, the district manager, and the customer-support channel.

Configuring the message destination.

While Addison could take the easy way out and hard code the message destination Ids in her flow, she’s an #AwesomeAdmin and follows best practices, which includes no hard coding. Plus, if she builds multiple flows that reference the same message destination Ids, she wants to reference them in one place and not hard code each reference. She creates a custom metadata type (CMDT) that her flow will reference. For more on why you should avoid hard coding Ids, check out the blog post Why You Should Avoid Hard Coding and Three Alternative Solutions.

The configured custom metadata type storing the Slack message destination Ids.

Addison created a flow that gets the information on the cupcake order associated with the CSAT survey, gets the Slack message destination Ids from the CMDT, and determines based on CSAT results whether to send a DM to the district manager or post to the Slack channel, using the Slack: Post Message invocable Apex action.

The configured flow.

It’s pretty easy to configure the Slack: Post Message Apex action attributes: message destination Id, record Id, and message.

The Apex action used to send the DM to the district manager is configured as such:

  • For the message destination Id, instead of hard coding, Addison referenced Jared Dunn’s message destination Id from the CMDT record.
  • For the record Id, Addison referenced the $Record.Id.
  • Addison decided to include a message and referenced a text template Flow resource, DMSlackMessage.

The Apex action used to post to the customer-support Slack channel is configured as such:

  • For the message destination Id, instead of hard coding, Addison referenced Customer Support’s message destination Id from the CMDT record.
  • For the record Id, Addison referenced the $Record.Id.
  • Addison decided to include a message and referenced a text template Flow resource, ChannelSlackMessage.

 The configuration of the two invocable Apex actions.

For your reference, here are the two text templates Addison configured for the Slack message.

Pro-tip: Make sure the text template is set to ‘View as Plain Text’ to avoid showing HTML tags in Slack.

Configured DMSlackMessage text template Flow element.

Configured ChannelSlackMessage text template Flow element.

And just like that, when a new CSAT survey result is created in Salesforce, based on the survey results, it either creates a DM to the district manager or a post to the customer-support Slack channel.

Animated gif that shows CSAT record creation and resulting DM and post to Slack.

Connecting Salesforce data to Slack with MuleSoft Composer

MuleSoft Composer for Salesforce is a no-code solution that allows admins to build integrations easily without developer resources, connecting apps and data — all inside Salesforce — using a growing library of prebuilt connectors. You can use MuleSoft Composer for Salesforce to take an event in another system — such as Jira, Google Sheets, and ServiceNow, along with data from Salesforce — and create messages in Slack.

Note: MuleSoft Composer for Salesforce is not free. To learn more about MuleSoft Composer for Salesforce and its pricing, please contact your Account Executive.

We’re going to do a quick, high-level overview of how to configure a Composer flow to connect Salesforce data to Slack. In our scenario, our awesome admin, Addison Dogster, takes CSAT information from Google Sheets, creates a record in Salesforce, retrieves data from Salesforce, and depending on if/then logic, either posts a DM or message to a channel in Slack.

First, specify the system where an event will trigger your Composer flow.

Starting setup for a new Composer flow — selecting the system that triggers the flow.

Addison connects to Google Sheets (only output provided by her purchased CSAT system) as the system trigger.

Configured Google Sheets connection.

Next, we add a system event by choosing a system where the action occurs and establishing the connection. Then, select the action you wish to take. For a Salesforce system event, you have the following actions available: create record, update record, get records, create or update record, and delete record.

Actions available for a Salesforce system event.

In our case, Addison selects Salesforce and establishes the connection to the Sunshine Cupcakes Salesforce org. Then, she configures the ‘Create record’ action using the data from Google Sheets, and then configures the ‘Get records’ action using the cupcake order number from the Google Sheets survey information.

Pro-tip: To use the data from the ‘Get records’ action, you need a For Each (or Loop element) to loop through a list of items, even if you’re only looking for one record. This is currently the only way for you to access the data from the record found.

Configured Create records, Get records actions with a Loop element.

Now, to connect to Slack, you need to set up Slack as a system event and connect to your Slack workspace. Then, for actions, you can send a direct message to a user, post to a Slack channel, or get user by email. For the DM or channel post, you can customize the message using information from the system that triggered the Composer flow or any system events. Optionally, for a DM and channel post, you can configure the Bot Name and Bot Icon URL as well.

Options for configuring a Slack system event.

You can also get a bit fancy and use the If/Then Block to specify conditions that must be true before the Composer flow performs the action. For those who build flows, this is similar to your Decision element.

Example of the "If/then" block.

In our scenario, Addison needs to send a DM to the district manager if the scores are 1’s across the board, and anything below 5’s will be sent to the customer-support Slack channel. She’s able to customize the message to dynamically pull in data from Google Sheets and Salesforce using merge fields.

Configuration using If/Then Block and Slack system events to send a DM and channel post.

And just like that, with a few clicks, you can create an integration that interacts with Salesforce and Slack — using clicks, not code!

End to end experience — survey result in Google Sheets, record creation in Salesforce, and Slack DM and channel post.

What admins can do next

Admins can start integrating Salesforce with Slack TODAY with clicks, not code. Look for those departments that collaborate a lot in Slack already, and imagine them being able to work with the whole company!

Give these a test drive today by setting up the integration with a sandbox to perform your testing of the configuration before doing this for real in Production.

And don’t forget about yourself! Setting up admin-specific collaboration channels is a great way to brainstorm on a new feature with your power users or swarm an issue with colleagues. We can’t wait to see how you innovate with Slack!

Resources

Strategic Slack Channel Management.

Strategic Slack Channel Management for Salesforce Admins

As a Salesforce Admin, a good portion of our daily job is to be a functional leader within your organization. When you think about it, many of the users you support don’t report directly to you, yet they often benefit from your leadership and direction. So, apart from being a direct leader or managing people, […]

READ MORE
Season 2 "How I Solved It" Trailblazers

How I Solved It Season 2 Is Coming Soon to Salesforce+!

Cue the confetti—we’ve got a BIG announcement for our #AwesomeAdmin community! We are very excited to announce the launch of Season 2 of the popular Salesforce+ series, “How I Solved It”! Hosted by Principal Admin Evangelist Gillian Bruce, this series explores how Salesforce Admins solve business problems using automation, data, and design tools. In each […]

READ MORE
Greenery and text that says "Use MuleSoft Composer to Integrate Salesforce Orgs and Slack."

Use MuleSoft Composer to Integrate Salesforce Orgs and Slack

As admins, once we gather and understand business requirements, we want to get building! Have you ever been in a situation where you could build a solution yourself BUT it required an integration? You would be dependent on a developer resource to complete your solution, which adds time and cost to your project. What if […]

READ MORE