Create A Slack Channel Using Flow

Create A Slack Channel Using Flow

Last Updated on May 30, 2022 by Rakesh Gupta

Big Idea or Enduring Question:

  • How do you create a Slack Channel using Salesforce Flow?

Slack Channels bring order and clarity to work — you can create them for every project, topic, or team. When there’s a channel for everything, you can focus on the conversations and work that matters most to you.

I have written a few articles on Slack and Flow. Why not check them out while you are at it?

  1. Post a Message to a Slack Channel using Flow
  2. Send A Direct Slack Message Using Flow

Objectives:

After reading this blog, you’ll be able to: 

  • Understand when to use Run Asynchronous path
  • Make external callouts via Flow
  • Work with SUBSTITUTE, LOWER, and LEFT formulas in the flow  
  • Create a Slack Channel using the flow
  • and much more

Business Use Case

Martin Jones is working as a System Administrator at Gurukul on Cloud (GoC). GoC wants to create a new slack channel when an account is created with rating Hot. GoC wants to follow the naming convention for the Slack channel:

  • account-{use the first 20 characters of the account name) 
    • For example, if the account name is the University of Arizona, then the channel name must be account-account-university-of-arizon

Pre-requisites:

  1. The first step is to complete Salesforce for Slack integration.
  2. The second step is to install Sales Cloud for Slack in your Slack workspaces.
  3. Substitutes formula is used to replace old text in a text string with new text.
  4. The left formula returns the specified number of characters from the beginning of a text string.
  5. The lower formula converts all letters in the specified text string to lowercase.
  6. Channel names must be lowercase, without spaces or periods, and can’t exceed 80 characters.

Automation Champion Approach (I-do):

Add an asynchronous path to an After-save Record-Triggered Flow flow to integrate with an external system and update external objects without writing code. The asynchronous path runs after the original transaction for the triggering record is successfully committed. For example, use an asynchronous path to post a message to Slack, update a record in Heroku, or place an order using a third-party fulfillment system.

Before discussing the solution, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes going through the following Flow diagram and understanding it.

Let’s begin building this automation process.

Guided Practice (We-do):

There are 3 steps to solve Martin’s business requirement using Record-triggered Flow. We must:

  1. Define flow properties for record-triggered flow
  2. Create a formula to construct the slack channel name
  3. Add Create Slack Channel (Beta) action – to create a Slack Channel  

Step 1: Define Flow Properties

  1. Click Setup.
  2. In the Quick Find box, type Flows.
  3. Select Flows, then click on the New Flow.
  4. Select the Record-Triggered Flow option, click on Create 
    1. Object: Account
    2. Trigger Opportunity Flow When: A record is created
    3. Set Entry Criteria
      1. Condition Requirements: All Conditions Are Met (AND)
        1. Row 1
          1. Field: Rating
          2. Operator: Equals 
          3. Value: Hot
    4. Optimize the Flow For Action and Related Records
    5. Choose the Option to Include a Run Asynchronously path to access an external system after the original transaction for the triggering record is successfully committed.
  5. Click Done.

Remember
  1. Asynchronous paths are available for record-triggered flows that run after the record is saved.
  2. Asynchronous paths options are only available for flow those are configured to run only when a record is updated to meet the condition requirements or select the Is Changed operator in a condition. 
  3. When a new or updated record triggers your flow to run, an asynchronous path is queued until it runs. You can monitor an asynchronous path on the Time-Based Workflow page in Setup.

Step 2: Formula to Construct the Slack Channel Name

  1. Under Toolbox, select Manager, then click New Resource to construct the opportunity name using concatenate formula. 
  2. Input the following information:
    1. Resource Type: Formula
    2. API Name: forT_ChannelName
    3. Data Type: Text
    4. Formula: “account” & “-” & SUBSTITUTE(LOWER(LEFT({!$Record.Name}, 20)), ” “, “-“)
  3. Click Done.

Step 3: Add Create Slack Channel (Beta) – to create a Slack Channel 

Now we will use the Create Slack Channel (Beta) action to create a new Slack channel. 

  1. On Flow Designer, click on the +icon and select the Action element.
  2. Search and select the Create Slack Channel (Beta) from the dropdown menu
  3. Enter a name in the Label field; the API Name will auto-populate.
  4. Set Connection Values for Slack
    1. Slack App: Essentials Runtime Starter
    2. Slack Workspace: Automation Champion
    3. Execute Action As: Slack App
  5. Set Slack Channel Details
    1. Slack Channel Name: {!forT_ChannelName}
    2. Channel Type: Public
    3. Slack Workspace ID for Channel: Automation Champion
  6. Click Done.

In the end, Martin’s Flow will look like the following screenshot:

Once everything looks good, perform the steps below: 

  1. Click Save.
  2. Enter Flow Label; the API Name will auto-populate.
  3. Click Show Advanced.
  4. API Version for Running the Flow: 55
  5. Interview Label: Create A Slack Channel Using Flow  {!$Flow.CurrentDateTime}
  6. Click Save.

Almost there! Once everything looks good, click the Activate button.

Proof of Concept

Now onwards, if a business user creates a new account with a rating hot, record-triggered after-save will automatically create a new Slack channel.

  1. Navigate to the Account a new account Universal Health Services, as shown in the following screenshot:
  2. Now login to Slack and check out the Slack channel.

Formative Assessment:

I want to hear from you!

What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? Feel free to share in the comments below.

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

2 thoughts on “Create A Slack Channel Using Flow

  1. Hi thank you for this amazing article
    is it possible to automate a slack workspace creation? or only a channel?

    thanks

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.