Connectors / Service / Slack

Slack brings all your communication together in one place. It's real-time messaging, archiving and search for modern teams. (updated: 1657714894977)

Slack

Slack is a cloud-based platform that brings all your collaboration and messaging tool needs together, for both individuals and companies.

Overview

Slack is a single tool for messaging and sharing components and files; where you can create channels, react to key events and potentially configure Slack specifically for your team’s unique needs or tech stack via the Slack API. Their directory has over 1500 integrable apps, and data protection expectations are key.

API INFO: The Base URL used for the Slack connector is https://slack.com/api. More information can be found on their main API documentation (v1.0) site. This is where users will also be able to find the API Limitations page.

Slack templates

Please note that we have the following Slack templates available:

These will give you pre-configured best practice ways of working with Slack and integrating it with other connectors.

However, please continue to at least read the Authentication and Trigger setup instructions on this page to enable you to get started with using Slack.

Authentication

Within the builder, click on the Slack connector to display the connector properties panel. Select the 'Auth' tab and click the 'New authentication' button.

slack-new-authentication

In the Tray.io authentication pop-up modal, name the authentication in a way that will easily identify it within a potentially large list. For example, whether it is a Sandbox or Production auth, etc.

Consider who/ how many people will need access to this authentication when choosing where to create this authentication ('Personal' or 'Organisational').

The next page asks you for 'Slash command signing secret'.

Slash command signing secret is an optional field but is required when working with Slash commands. 

You can skip adding the value for this field in your auth if you will not work with slash commands.

slack-new-auth-slash-command-signing-secret

To get value for this field, go to the Slack api page and click the 'Your apps' tab from the top right corner.

slack-auth-your-apps

On the next page, select your app from the available list.

slack-auth-select-your-app

You will be redirected to the 'Basic Information' page of your App. On this page, scroll down to the 'App Credentials' section. Here you will get value for the Signing Secret.

slack-auth-signing-secret

The next step is to select permissions.

There is a list of permissions that you can select based on your usage. You may need all or a few of these permissions.

For your convenience, basic permissions are already selected. Feel free to check or un-check the permissions based on your use case.

If unsure about the required permissions, you can always start with the pre-selected settings.

slack-auth2

Once you select the permissions, click the 'Create authentication' button.

You will be redirected to a popup screen, where you will be asked to confirm the access you are granting to Tray.io. Once you have reviewed the permissions, click the 'Allow' button.

slack-auth-request-permission-to-access-slack-workspace

Your connector authentication setup should now be complete.

Slack Trigger

If you wish your workflow to be kicked off by a particular action in Slack, you can use the Slack Trigger.

The Slack trigger allows you to receive notifications and trigger workflows when given events occur associated with the selected trigger operation.

Trigger Operations Available:

  • On action (button or menu click)

  • On Slack event

  • On slash command

Webhook Setup

Select the Slack trigger. This can be done either at the create new workflow stage or updated within the workflow builder itself.

Use the instructions above to authenticate your trigger, and select from the options available the event you want your trigger to listen to, in order to set off the workflow itself.

slack-trigger-options

Available Operations

The examples below show one or two of the available connector operations in use.

Please see the Full Operations Reference at the end of this page for details on all available operations for this connector.

Notes on using Slack

Reference schema

When creating a message for Slack to display there are a couple of characters that you may need to use in order to display your message correctly while using Tray.io's interpolation feature.

  • Links: Use triangular brackets <>

  • Names: Include the symbol @ and <> so that the name is linked as usual

  • Markdown formatting is also interpreted such as *bold*

slack-schema-demo

Pagination

Note that there is a limit of 1000 results per response.

Building Apps for Slack

For certain purposes (such as creating slash commands) you will need to create a Slack app by following the steps below:

You have successfully created your Slack app, which is ready to use.

Creating a slash command

Slash commands act as shortcuts for specific actions in Slack. There are three types of slash commands that you may be able to use in your workspace:

  • Built-in slash commands: created by Slack

  • App slash commands: created by developers

  • Customised slash commands: created by members of your organisation

In this section we are going to learn how to create App slash commands. You can create slash commands by following the steps below:

Before you start creating your Slash command, make sure you have your Slack App in place. If you don't already have a Slack App, refer to our Building Apps for Slack section above.

While working with Slash command make sure you have added Slash command signing secret to your Slack authentication.

Refer to the Authentication section for more details.

Slack Block Kit

Slack Block Kit is a UI framework for designing Slack app components like modal, message format, etc.

Block kit uses visual components like "blocks" that can be stacked and arranged to create application layouts.

Building an app using blocks automatically generates a JSON object which you can copy and paste into your connector. 

Before you start working with Slack Block Kit, make sure you have your Slack App in place. If you don't already have a Slack App, refer to our Building Apps for Slack section above.

The Modal generated using Slack Block Kit can be used in various ways. If you wish to simply share certain information over Slack using the modals, you can use the Slack connector.

If you wish to work with interactive modals that allow users to respond, you need to use an HTTP client connector instead of the Slack connector.

For example, if you wish to open a modal in Slack when a /survey command is triggered, then you need to run POST https://slack.com/api/views.open using the HTTP client connector with the following information:

  • URL: https://slack.com/api/views.open

  • Header:

    • Key: Content-Type

    • Value: application/json; charset=utf-8

  • Body Type: raw

    • raw: paste the JSON object for your modal here.

For a better understanding of working with modals using the HTTP client connector refer our detailed template example.

You can create a modal by following the steps below:

Best Practice: Add a WF URL

It is a good practice to add a link to the Workflow URL so that users will know from where the bot/ automated message came from.

This is a great way to troubleshoot quickly as an organisation may have multiple workflows involving Slack Connector automations.

We recommend adding the URL using the $.env.execution_log_url jsonpath and adding it to the Footer section in the properties panel.

So your final Footer would be: <{$.env.execution_log_url}|Sent via tray.io>

When doing this make sure you do not add or reveal any workflow URLs which could contain sensitive information.

Slack > Best Practice: Add a WF URL > footer
slack > Best Practice: Add a WF URL > final-sc

Example use cases

BEST PRACTICES: Whenever you do decide to create your own workflow, be sure to check out some of our key articles such as:

TRAY POTENTIAL: Tray.io is extremely flexible. By design there is no fixed way of working with it - you can pull whatever data you need from other services and work with it using our core and helper connectors. This demo which follows shows only one possible way of working with Tray.io and the Slack connector. Once you've finished working through this example please see our Introduction to working with data and jsonpaths page and Data Guide for more details.

Due to the number of possibilities within Slack, we have created two use case scenarios for the purposes of this tutorial. A beginners and an advanced example as demonstrated below.

  • Beginner: Send message

    • Here we demo the Send message operation as it is one of our most popular use cases. Basically when a user joins a Slack channel they will automatically have a welcome message displayed.

  • Advanced: Slash command

    • This tutorial involves using the Airtable connector plus additional Slack application setup. This is a complicated use case which has been built to show users how to set up Slash commands within a more likely usage scenario.

Beginner: Send message

This example demonstrates a workflow that is triggered whenever a new user joins a particular channel. A welcome message will then be displayed automatically.

This is a good use case as it is a more public notification to the channel at large that a new "team member" has joined our group.

The steps will be as follows:

  • Set up the Slack trigger to react to a new user joining a channel.

  • Get the new user's details.

  • Respond with an automated message to the channel at large.

The completed workflows looks like this:

slack-beginner-result

Advanced: Slash command

Slash Commands allow users to invoke their app by typing a string into the message box. A submitted command will cause a payload of data to be sent from Slack to the associated app. The app will then respond using the context provided by that payload.

This workflow is triggered by a /contact-details <slack-user-name> slash command. Where the <slack-user-name> is the name of a slack user whose contacts are to be fetched from a database.

To fetch these contact details from a database the workflow uses the unique ID/ Name of a Slack user which is received through the trigger.

Based on if the contact details were found or not an appropriate message is then sent to the user (the one who initiated the Slash command).

Before continuing please read through the Pre-requisites section as there are several requirements.

Results:

slack-slash-command-sc

Prerequisites:

Before you start working on the example below make sure:

Completed workflow:

slack-advanced-complete-wf

All Operations

Latest version:

9.1

Add reminder

This method creates a reminder.

Archive conversation

Archive a conversation in your Slack account.

Conversation exists?

Checks to see whether a conversation exists in Slack.

Create conversation

Create a public or private channel-based conversation.

Create pin

Pin a message, file, or file comment to a channel.

Delete scheduled message

Delete a pending scheduled message from the queue.

Generate channel name

Given a piece of text (e.g. an Account name in Salesforce), generate a Slack friendly channel name in the format "my-channel-name". You can then pass this directly to the "Create Channel" operation.

Get conversation info

Retrieve information about a conversation.

Get user

Get details of a user in your Slack channel, using their unique ID.

Get user by email

Get a user by their email address.

Invite user to conversation

Invite a user to a conversation in your Slack account. The calling user must be a member of the channel.

Leave conversation

Remove yourself (the authenticated user) from a conversation.

List conversations

List of all channel-like conversations in a workspace.

List conversations DDL

List conversations non archived DDL

List filetypes DDL

List scheduled messages

Returns a list of pending scheduled messages.

List scheduled messages DDL

List users

Get a list of all of the users in your Slack team.

List users DDL

List users actual DDL

List users and conversations DDL

List users conversations

List conversations the calling user may access

Send ephemeral message

Send a message that only a certain user can see in a public or private channel.

Send ephemeral response

Send an ephemeral response message using the response_url parameter provided by Slack slash commands and actions. This will only be visible by the user.

Send message

Send a message to a user or channel.

Set conversation purpose

Set the purpose for a conversation. The calling user must be a member of the conversation. Not all conversation types may have a purpose set.

Set conversation topic

Set the topic for a conversation. The calling user must be a member of the conversation. Not all conversation types may have a purpose set.

Set profile

Set the user's presence and status.

Unfurl message links

Unfurl one or more links in a Slack message, adding "attachments" that contain additional context to the message.

Update message

Update a message that's previously been sent. Useful when reacting to actions like buttons and menus.

Upload file

Uploads or creates a file. Optionally share to users or channels. This operation requires a scope to be enabled in your authentication, either files:write (for new Slack apps) or files:write:user.