Enabling Slack Webhook Workflows

Recently, a customer reached out with an interesting question: “Is there a way to automatically add a member to our Slack workspace whenever we create a new contact in Salesforce?” Initially unsure, I remembered a helpful blog series by Andy Engin Utkan, which provided valuable insights.

SurveyVista: Effortless Data Collection to Action

Following this, I realized and implemented the solution of combining Salesforce HTTP callouts with Slack for automating tasks through its API. It also got me thinking, “Could I trigger a Slack workflow builder via webhook directly from a Salesforce flow using an HTTP callout?” The answer, as it turned out, was a resounding yes!

Enabling Slack Webhook Workflows

In this blog post, I’ll guide you through the steps to accomplish this integration and outline a specific use case.

If you’re new to HTTP callouts and unsure how they function, I again suggest checking out Andy Engin Utkan’s blog post here for some really helpful guidance. Similarly, if you’re not familiar with Slack webhooks and how they operate, taking a look at the documentation here can provide you with a clearer understanding of their functionality. Understanding both HTTP callouts and Slack webhooks will be important, as there is configuration required on both Slack and Salesforce to ensure this integration works properly.

1️⃣ Salesforce Setup

First, we need to configure the Salesforce Setup side, which involves setting up three key components: (1) external credentials, (2) named credentials, and (3) permission sets, granting access to the principal.

External Credential

“Authentication Protocol” is set to “No Authentication” and establishes a principle named “token” (or any preferred identifier).

Free Mentorship With Talent Stacker
Enabling Slack Webhook Workflows

Named Credential

For “URL,” add the Slack webhook you’d like to hit and remove any callout checkbox options selected. If you haven’t created a Slack webhook yet, no worries; we can come back to this. Be sure to set the external credential to the one created in the last step

Enabling Slack Webhook Workflows

Permission Set

Generate a permission set, such as “Slack Webhook Callouts,” and grant “External Credential Principal Access” to the previously mentioned “token” for the external credential.

Enabling Slack Webhook Workflows - Permission Set

2️⃣ Slack Setup

So here’s where things get exciting! If you’re not up to speed with Slack’s updated workflow builder, it boasts 28 native workflow steps and 54 application connectors, each featuring at least one workflow step. What this means is that we can activate Slack workflows, leveraging this capability, via a Salesforce flow that hits a Slack webhook.

Let’s explore a practical scenario we implemented at 21b for the same client.

Workspaces run projects within their Slack individual workspaces within the grid instance. When new projects are requested via Slack form to Salesforce through Centro, a new project record is generated in Salesforce. This fires a record-triggered Salesforce flow, automating the creation of the Slack project channel, inviting members, and sending notifications. It’s a seamless automated process, with Salesforce serving as the central data repository.

Enabling Slack Webhook Workflows - Create contact

One of those notifications was sent to an alert-only project management channel, informing the team there that a new project channel had been created and to manually create its channel canvas. Team members would then manually duplicate a canvas “template” they had. They copy its contents and pasting them into the new project channel. With the introduction of canvas steps in the workflow builder, there is availability of custom canvas templates and variables within those custom templates. I recognized an opportunity to fully automate this manual process and deprecate that channel.

Canvas template

To get started, create a canvas template and add variables as you’d like. If you do not have Enterprise, you cannot create custom templates or variables, but you can achieve the same functionality using out-of-the-box Slack canvas templates (of which there are 10+). In the case of this customer, we created a template project workbook canvas that contained four variables: project name, project category, start date, and team lead.

Enabling Slack Webhook Workflows

Slack webhook workflow

Next, create a webhook workflow that contains variables that you will send from Salesforce. This can be things like channel_id or, which can be used in the workflow itself, and/or things that you will map to variables that flow into Canvas. In our case, we created five variables:

{
"team_lead": "U123456789",
"channel_id": "C123456789",
"start_date": "Example text",
"project_category": "Example text",
"project_name": "Example text"
}

Choose how to start the workflow

Then add the steps to your Slack workflow for your particular use case. Now, a new project channel auto-generates and shares a standalone workbook canvas directly in it. Channel members can bookmark, pin, save, or add it to the channel canvas as desired.

Enabling Slack Webhook Workflows

3️⃣ Salesforce Flow

Now we can make the magic happen and put all the pieces together.

Record-Triggered Flow

We created a flow to fetch the Slack Channel ID for the webhook one minute after the last project update. The flow below triggers the webhook and associated workflow steps above.

Enabling Slack Webhook Workflows

The flow is simple: it retrieves project information, assigns the HTTP callout body, and sends the payload to the Slack webhook.

The Magic

With this active flow in place, we unlocked an even greater level of automation in the project process. From channel creation to member invites and notifications, a personalized project workbook canvas is now posted directly in the channel.

So, what are you going to create? Let me know in the comments!

This guest post was penned by Daniel Sanchez, the co-founder of 21b.

Read more on Slack here:

How to Build a Screen Flow to Complete Virtual Standup on Slack

Slack and Flows

Post to Slack from Flow in 6 Easy Steps

Join the Flownatic Slack Workspace with the invitation on this page:

Flownatic Slack Workspace

daniel21b

Hello! My name is Daniel Sanchez, and I am a co-founder of 21b. We help companies do all things related to Slack, including initial launches and implementations, migrations, integrations with external systems (like Salesforce!), and automating their business processes.
Back to top button

Discover more from Salesforce Break

Subscribe now to keep reading and get access to the full archive.

Continue reading