# Slack

SUMMARY

  • The Slack connector integrates Slack with other apps, automating tasks within the Slack workspace.
  • Workato supports both the Slack connector for workspace-level automation, and Workbot for Slack for complex chat interactions.
  • The Slack connector uses the Slack Web API and works with both Slack for teams and Slack Enterprise Grid.
  • Connection to Slack is through OAuth 2.0, with functionalities like posting messages or using Slack buttons.

Slack (opens new window) is a team collaboration platform that consolidates your team's communication and resources.

Workato allows you to connect Slack with the enterprise and productivity apps used across your organization. Transform your team's conversations into automated tasks in those apps - all without leaving your Slack workspace.

# Slack connector VS Workbot for Slack connector

Workato supports both the Slack connector and the Workbot for Slack connector.

If you're a Slack administrator (or part of an administrative team) that needs to automate workflows on a workspace-level, then the Slack connector is what you need. Using the Slack connector, you can subscribe to workspace-level events and manage channels, groups, and more. For example, you can automate the creation, naming, purpose, and invitees of private Slack channels (typically between members from Customer Success and customers), triggered by a ticket escalation in Jira.

Workbot for Slack allows you to design complex chat interactions on any Slack surface (messages, modals, app homes) using Slack's block kit. With Workbot, you can build rich, interactive chat flows by giving you complete control over interactive elements such as buttons, select menus, radio buttons, date pickers, checkboxes, and more. Your bot's messages, modals, app home, Shortcuts, and slash commands can chain fluidly into one another, using Workbot commands. Dynamically-rendered menus, buttons, and blocks are also easily built using Workbot.

If you envision a virtual assistant for your team that can perform complex tasks like approval workflows involving several steps, displaying dynamic menus & interactive elements, go for Workbot.

A functional comparison table for both the Slack connector and the Workbot for Slack connector can be found here.

# API version

The Slack connector uses the Slack Web API (opens new window) with the endpoint URLs https://slack.com/api/METHOD.

# Supported editions and versions

Workato connects to both Slack for teams (for single workspaces) and Slack Enterprise Grid (for multiple workspaces).

# How to connect to Slack on Workato

Authorize Workato to access your Slack organization via the OAuth 2.0 standard. This will require you to log in to Slack and authorize the permissions that Workato requests.

Configuring Slack connection Setting up the Slack connection

# Working with the Slack connector

# Using the post message action

The Post message action can be used to post a message to a channel or a direct message to a Slack user. By default, the message will be posted as the authenticated user.

# Example message with attachment

Learn how to format Slack messages in this video tutorial

The following shows an example of how the different fields show up in Slack. As the Post message as and Icon image URL input fields have not been configured, the message displays as being posted by the Workato app.

Post message example with attachment Basic example of the post message action with attachment

The corresponding configuration of the action step can be seen below. Also, the Message type has been configured to Good.

Post message basic configuration 1

Post message basic configuration 2 Post message action configuration - message with attachment. Example recipe (opens new window)

# Using Slack message buttons

You can interact with messages in Slack via Slack buttons (opens new window). To use Slack buttons in Slack, you need:

  1. A recipe with a Post message action that has buttons configured. This recipe needs to specifically refer to the second recipe below in its button configuration.

  2. A button action handler recipe - a recipe with a New button action trigger, which picks up button clicks. In the actions, there should be recipe logic that carries out actions depending on which button has been clicked.

There are 2 ways we can build interactive Slack buttons recipes, either via IF conditions, or via the Slack action Respond to button.

# Using IF conditions to build interactive Slack buttons recipes

Possible use cases for building your recipe via IF conditional recipe steps would be scenarios whereby you're okay with multiple clicks of the buttons, such as team polls.

# Example recipe #1A: recipe with a post message action with buttons configured

We're going to add buttons configuration to the basic recipe (opens new window) we had above. The recipe we will be using can be found here (opens new window).

The buttons configured in this recipe show up in Slack as follows.

Button display Corresponding buttons generated from the above configuration

# Button styles: danger and non-danger

There are two available styles for buttons - non-danger and danger style. The non-danger styled buttons, once clicked, records the button click immediately and triggers the second recipe with the New button action trigger.

Interacting with non-danger style button Interacting with non-danger styled button

The danger styled buttons, when clicked, generates a popup prompt that asks the Slack user for confirmation of their click.

Interacting with danger style button Interacting with danger styled button

The prompt that pops up can be completely configured in the button configuration in the Slack action Post message.

Popup prompt example Popup prompt

# Button definitions

The button configuration for both button styles is in the following screenshot. We're calling a recipe we have pre-built: New Salesforce account button response recipe - Notify BizDev & Notify Sales (opens new window). All recipes with the Slack trigger New button action should show up in this picklist - select the recipe you have built to respond to this particular set of buttons.

Button configuration for action Button configuration for post message action step

The following is the button configuration we used in the recipe. For non-danger styled actions, only the first 2 parameters need to be filled in, as there is no popup prompt generated. For danger styled actions, all 7 parameters need to be filled in.

Notify BizDev, bd, , , , ,
Notify Sales, sales, danger, Confirm, Are you sure?, Yes, Cancel

The above button configuration follows this format for button actions:

action name, action ID, style, confirmation title, confirmation text, ok button title, dismiss button title

The following is an elaboration on each field in the definition of a button.

Button definition input fields Description
Action name Button label visible to Slack user interacting with the buttons.
Action ID Internal value of the button. This needs to be unique. Not visible on Slack to anyone.
Style Leave this field as well as the remaining 4 fields blank for non-danger styled actions since no pop-up will be generated.
Otherwise, put danger to generate a red button with a pop-up prompt, requiring the user to confirm the button click. You will then need to fill up the rest of the fields too.
Confirmation title Shows up in the popup prompt as the header.
Confirmation text Shows up in the popup prompt as the body text.
Ok button title Button label in the popup prompt to confirm the button click.
Dismiss button title Button label in the popup prompt to cancel the button click.
# Example recipe 1B: button action handler recipe - recipe with a new button action trigger with IF conditional logic defining the actions to carry out upon each button click

The following recipe has been built for the above scenario. It posts different messages as a thread under the first Salesforce account notification message, depending on which button has been clicked. Using IF conditions is more versatile than using the Slack action Respond to button, because you can carry out multiple steps in the IF condition and in multiple apps.

In this recipe, to check which button has been clicked, we use the IF condition to check the button name. If it matches "Notify BizDev", we post a message for the business development team, and if it matches "Notify Sales", we post a message for the sales team.

Button action example recipe Button response using IF conditions. Example recipe (opens new window)

# Output of the Slack trigger - new button action

The datapills used in the IF conditions come from the Slack trigger New button action. The following screenshot shows the output datatree from the Slack trigger New button action. The datapills are variables that the recipe builder can use while building the recipe actions.

Button action datatree output Output datatree of the new button trigger

The following table elaborates upon these datapill variables and what they can be used for.

New button click trigger output datapills Description
Action name Button label visible to Slack user interacting with the buttons.
Action ID Internal value of the button. This needs to be unique. Not visible on Slack to anyone.
Channel The channel where the button click occurred. You can obtain both the channel internal Slack ID and the channel name.
User The user who clicked the button. You can obtain both the user internal Slack ID and the username.
Team The Slack team where the button click occurred. You can obtain both the unique domain and the internal team ID.
Action timestamp The epoch time when the button click occurred.
Message ID The epoch time when the message with buttons was sent. Can be used to populate Thread ID input fields to create a thread under this message.
Attachment ID ID of the attachment sent with the initial Slack message with buttons, if any.
Response URL Used by Workato to respond to the button click. Also used in Slack action Respond to button.

An example of the values can be viewed in the job output, as follows.

Button action data output Button action data output

# Using Slack respond to button action to build interactive Slack buttons recipes

Possible use cases for building your recipe in this way would be scenarios whereby you only wish the button to be clicked once, such as approval workflows, for example, approving leave, approving expenses.

# Example recipe #2A: recipe with 2 post message actions with buttons configured

We're going to use almost exactly the same recipe as example recipe #1A, except that we're breaking up the single Slack action Post message into 2 separate Post message actions. The first action will post notification information (in this case, my Salesforce account information), while the second action will only post button data. The recipe we will be using can be found here (opens new window).

The buttons configured in this recipe show up in Slack as follows.

Salesforce account information and button posted via separate actions Salesforce account information and button posted via separate actions

When the button is clicked on, it is immediately replaced by a message notifying either the business development or the sales team.

Salesforce account information and button posted via separate actions

This is because the input field Replace original? has been marked as true in the Respond to button action configuration. We will cover this action in the following section. This allows us to remove the buttons from the Slack channel once they have been clicked on - to prevent multiple clicks on the buttons. This is also why the first recipe breaks up the notification information and the buttons data into 2 separate actions - we want to replace only the buttons with the new message, and not replace the notification information.

# Example recipe #2B: button action handler recipe - recipe with a new button action trigger with Slack action Respond to button that responds to each button click with a Slack message

The following recipe is an alternative way we can build the interactive scenario on Slack. Similarly, it posts different messages back in the channel depending on which button has been clicked. We use the Slack action Respond to button to immediately post a message back onto the channel.

Respond to button action example recipe Respond to button action. Example recipe (opens new window)

With the Respond to button action, we can simply pass in the button response URL, and the recipe will know, at run-time, which button has been clicked. Therefore, if we wish to do something like post a generic message that tells the channel which button has been clicked, this action is suited to handle that easily.

Respond to button action configuration Respond to button action configuration

# Input of the Slack action - respond to button action

The following are the new input fields that the Slack action Respond to button introduces to the usual input fields in the Post message action.

Respond to button action input field Description
Button response URL Provide this from the output datatree of the Slack trigger New button action. This tells the action what button click to respond to.
Response type In channel will post the message like a normal chat message. Ephemeral will post the message in grayed out text.
Replace original If yes, the new message will overwrite the original message with buttons and be posted in the same position in the channel.

If no, the original message with buttons will remain in the same position in the channel. The new message will be added to the end of the channel conversation.

Delete original If yes, the original message with buttons will be removed from the channel. The new The new message will be added to the end of the channel conversation.

If no, the original message with buttons will remain in the same position in the channel. The new message will be added to the end of the channel conversation.

# Using Slack threads

Slack threads (opens new window) allow you to group related messages together, making it easier to follow conversations in Slack channels or groups. To use Slack threads, you can either:

  1. continue a conversation by replying to a message ID and starting a thread,
  2. continue a conversation by replying to the parent message ID (the very first message of the thread), or
  3. continue an existing thread by replying to the thread ID.

You need to specify the message ID, parent message ID, or thread ID in the Thread ID input field to start or continue a thread.

# Example recipe #1: recipe that replies to a message ID and starts a thread

Let us relook at the preceding example recipe that responds to a button click.

Button action example recipe Button response example recipe (opens new window)

If a Slack user clicks on the Notify BizDev button, we can see that it creates a new thread by posting under the original message,

Notify BD thread example Thread created and message posted if Slack user clicks on the Notify BizDev button

The configuration in the recipe is as follows. We're passing the message ID of the original Slack message into the Thread ID input field. As the message has no thread currently, it will create a new thread.

Notify BD thread configuration Action configuration for the Notify BizDev action. Message ID is used in the Thread ID input field.

Correspondingly, if a Slack user clicks on the Notify Sales button, we can see that it creates a new thread by posting under the original message.

Notify sales thread example Thread created and message posted if Slack user clicks on the Notify Sales button

The configuration in the recipe is as follows. We're passing the message ID of the original Slack message into the Thread ID input field. As the message has no thread currently, it will create a new thread.

Notify sales thread configuration Action configuration for the Notify Sales action. Message ID is used in the Thread ID input field.

# Example recipe #2: recipe that replies to a parent message ID and continues a thread

Using the same recipe (opens new window) as above, we can see that putting the parent message ID also works to post to an existing thread.

Button action example recipe Button response example recipe (opens new window)

For example, when I select the Notify BizDev button for the second time, it posts to the same thread.

Messages are posted under the same thread via parent message ID Messages are posted under the same thread via parent message ID

Referring back to the action's thread configuration, we see that we're specifying the parent message ID in the Thread ID input field, which is the initial message that the thread is under.

Notify BD thread configuration Action configuration for the Notify BizDev action. Message ID is used in the Thread ID input field.


Last updated: 2/28/2024, 11:02:12 PM