Integrate Slack using Flow Actions

Slack invocable actions provide portable functionality that can be invoked via REST or used as point-and-click building blocks in Flow Builder, Bot Builder, and Strategy Builder.

  • Create Slack Channel
  • Invite User to Slack Channel (up to 1000 user ID’s)
  • Kick User from Slack Channel
  • Post to Slack (both plain text and full Slack markdown)
  • Archive Slack Channel
  • Get All Slack Channels
  • Get Slack Channel Members

There are many use cases for these actions:

  1. You can use Flow to streamline Slack administration. The package comes with a flow called Slack Administrator that streamlines the management of Slack channels and shows how these actions can be combined together.

Here’s what this flow looks like in the Flow Builder:

Watch this video to see it in action:

Use Case 2

Trigger on a Schedule or a Record Change using Flow Builder and use these actions to do something in Slack. Note that you currently have to use the dynamic technique shown here. Basically, you put the trigger in flow 1 and have it dynamically launch flow 2, where you put your Slack actions. (There are plans in the works for improving this situation)

Use Case 3

Spinning up channels for particular circumstances, such as the creation of a case or a deal opportunity. Your flow can create the channel and invite the right group of people. For this, you’ll probably want to have a User field that contains the user’s Slack Id.

How It Works

To learn about the different inputs, take a look at api pages like this one: https://api.slack.com/methods/chat.postMessage

To create rich Slack messages, you assemble JSON strings in the Slack format, which they call Block Kit. You then pass the strings into these actions. You can construct them here (https://app.slack.com/block-kit-builder/) and then copy and paste the json (everything inside the [ ]) into a Text Template or action input. You can insert merge fields (references that look like {!this}) and Flow will replace the merge fields with the appropriate values when the flow is executed. If you don’t want to deal with blocks, you can send plain text in the ‘text’ input. Note that the ‘text’ input is used in notification pop ups.

thread_ts is used when you want to instruct Slack that the message you’re posting is a response to a previous message. If you know the thread_ts value for the previous message (it’s basically a message id) and you provide it, Slack will make the new message a child of the old message.

Install

Step 1) Install Required Package Dependencies

Target orgs need to have the following package dependencies installed, in order:
Install: Flow Actions Base Pack
Install: Flow Screen Components Base Pack
Install: Datatable

Note however that these dependencies are only used for the sample harness flow “Salesforce Slack Administrator”. (If you’d rather have a package that doesn’t include this flow and require these dependencies, let us know.)

Step 2) Install the Slack Actions

Version 1.1.1 Unlocked 7/22/22 (better error reporting fix)

Step 3) Obtain an Authentication Token from your Slack Workspace

In order for your Slack Actions to be allowed to interact with your Slack workspace, you need to generate an authentication token. They look like this:

Notice the picklist in the upper left. It is set to a specific Slack Action (in this case, the app is called ‘InvocableActionBridge’. If you have sufficient permission to create an app on the workspace you’re targeting, you can generate a token by creating your own Slack App from here:

https://api.slack.com/apps

“Creating an App” may sound intimidating, but this isn’t a situation where you need to write code or create logic. A Slack App can be as simple as what we’re needing here: a simple token generator that gives you a token that you can use to access Slack.

In addition to generating your Bot User OAuth token on the Oauth and Permission page, as shown above, you need to scroll down on that page and add scopes to that token. Each scope allows the token to be used for a different chunk of apis. For example, here are the scopes I’ve assigned to my current Bot User OAuth token:

If you find yourself getting errors like this:

An Apex error occurred: CreateSlackChannel.InvocableActionException: error Creating Slack Channel: Error from Slack: missing_scope”

…return to this page and add the appropriate scope.

Reference: Post to Slack

Inputs

text
stringthis is plain text. if you don’t specify a ‘blocks’ value, this will be used.
blocksstringthis is used for text formatted using Slack Block Kit.
channelIdstringrequired.
tokenstring
thread_ts;stringthis is a timestamp that can be used as a thread Id. You receive them back on initial posts and can resubmit them with additional posts to maintain a thread.
usernamestring
attachmentsstring
unfurl_linksstring

Outputs

okstring
errorMessagestring
timeStampstring

View Source

Source

Old version

Version 1.1.0 Unlocked 3/8 (bug fixes)

Version 1.0.0 Unlocked 3/1