Open Navigation

Slack

Cloud base collaboration and messaging tool for companies

Overview

The Slack connector allows you to communicate with your Slack account using the Tray workflow builder. You can send messages, create channels, and react to key events that happen in your Slack account (e.g. when a channel is created).

Setting up your private Slack app

If you'd like to trigger Tray workflows from Slash commands, or use workflows to unfurl links (coming soon!), then you'll need to set up your own private Slack app for your team. This app is entirely separate from the Tray app, and will be entirely private to your organization.

  1. Go to https://api.slack.com/apps

  2. Click Create New App in the top-right of the page

Slack Create New App

  1. Specify your new app details, choosing the Slack team you use at your company. Then click Create App.

Slack Create App

Slash command trigger

Note: you'll need to set up an internal Slack app for your team (above) before you can start using slash commands.

Slash commands are a great way of triggering Tray workflows, without you ever having to leave Slack. You can set up any Slash command you like, and workflows will be triggered in real-time when you type the command in your Slack account.

The possibilities are endless, but here's a few exciting ideas:

  • List all open opportunities in Salesforce
  • Create a task for yourself in Asana
  • Send an email to a customer via your Gmail account

As an example, we'll use the first one - listing all open opportunities in Salesforce. We want to set up a Slash command called /open_opportunities.

  1. First things first, create a new workflow in Tray, using the Slack trigger. Choose the On slash command operation and enable the workflow.

On slash command

  1. Visit your internal Slack app

  2. Click Basic Information, and copy the Verification Token into the trigger connector settings. (This is how you keep things secure)

Verification Token

Security Token

  1. Open up your app, and click Slash Commands

Slash Commands

  1. Click Create New Command

Create New Command

  1. Enter the full details of the slash command, as you'd like it to appear in Slack. In this example, we don't need a usage hint.

    Full Command Details

  2. Type /open_opportunities in Slack and press enter - you should see a message appear in your Slack.

    Tray got the slash command!

  3. You'll see in the workflow logs the trigger data from Slack. With a bit of workflow building, you can adapt this workflow to do something useful, for example:

    Example of trigger in action

Interactive Messages

The Slack connector has full support for Interactive messages, which allow you to build Tray workflows for things like:

  • Approvals workflows
  • Voting
  • Getting feedback from users Approval Request

Interactive messages can be created as part of the standard Send message operation in the Slack connector. This works by using a different workflow to receive the interactions, and act accordingly.

Here's a quick example:

  1. Create a workflow with the Slack trigger. Select the On action (menu or button click) operation. Enable the workflow.

  2. Create another workflow in a new tab with a manual trigger, and a Slack connector with the Send message operation selected.

  3. Add some actions inside of a message attachment, and select the first workflow you created to handle the interactions.

Actions handler workflow

  1. Send the message with the second workflow manual trigger. You should see the buttons show in Slack.

Does it work?

  1. Try clicking one of the actions. You should see a spinner for a short period of time, but nothing else should happen. Then visit your workflow logs (the first workflow), and you'll see a new trigger, with the interaction details.

Trigger visible in logs

The details of the interaction can be found inside the action key in the data sent to the workflow. You can use this to react accordingly in your Slack trigger workflow!

Tip: it's also possible to pass any kind of data you like from the workflow that originally sends the Slack message, to the Slack triggered workflow. There is an Actions Data field that allows you to do this. Typically you'll want to pass something like a unique ID or number along.

Actions data

Events API trigger

The Tray Slack trigger connector allows you to react to key events that happen in your Slack account, including:

  • Channel creations
  • New team members
  • Message reactions

A full list of available events can be found in the Slack docs.

Tip: different events require different permissions for Slack to send them to your workflow. An error will be shown if you initialize your workflow and the required permissions haven't been provided. In this case - you'll need to re-authenticate Slack with the relevant permissions.

To give an example, let's build a workflow that is triggered when a reaction is added to a message. If the reaction is the :rage: emoji, let's send a message encouraging more positive reactions.

  1. Create a new workflow in the Tray dashboard, and add the Slack trigger with the On Slack event operation.

  2. You may need to re-authenticate your Slack account. Make sure you tick the Reactions:read permission when authenticating.

  3. Start the workflow, and wait for it to show Saved & enabled in the bottom left of the screen.

  4. Go and react with an emoji to any message in your Slack account. You'll notice that the workflow is triggered the details of the reaction.

  5. (Optional) With a bit of workflow building, set up a boolean condition to message back into the channel when the :rage: reaction is added.

Response to the emoji

Note: you'll need to set up an internal Slack app for your team (above) before you can start using link unfurls.

You can use Tray.io to automatically unfurl links in your Slack team. You can unfurl links from up to 5 different domains. Every time a link is shared in your team, Slack will trigger one of your workflows. You can then use this trigger to update the Slack message, adding in the link unfurl.

  1. Create a workflow, and pick the "On link share" operation.

  2. Enable your workflow.

  3. Open your Slack app, and click "Add features and functionality" > "Event Subscriptions"

Add features and functionality

  1. Enable Events, and then add the URL of your workflow into the "Request URL" field. The URL will validate automatically, and you should see a "Verified" tick. (If you don't see this, make sure you've enabled your workflow)

Verified

  1. Add the "link_shared" event as the event you'd like to listen for, then save your changes.

  2. Go to to the "OAuth & Permissions" page and ensure that you have the the "links:read" permission added to your app.

  3. Re-install your app to your team.

  4. Now you can add a second Slack connector to your workflow, to unfurl the link. You'll need to pass the following to to the "Unfurl links" operation:

  • Message ID
  • Channel ID
  • URL to unfurl
  • Attachment to add to append to the message
Was this article helpful?
Yes
No