SlackCloud base collaboration and messaging tool for companies
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.
Click Create New App in the top-right of the page
- Specify your new app details, choosing the Slack team you use at your company. Then click 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.
- First things first, create a new workflow in Tray, using the Slack trigger. Choose the On slash command operation and enable the workflow.
Visit your internal Slack app
Click Basic Information, and copy the Verification Token into the trigger connector settings. (This is how you keep things secure)
- Open up your app, and click Slash Commands
- Click Create New Command
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.
Type /open_opportunities in Slack and press enter - you should see a message appear in your Slack.
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:
The Slack connector has full support for Interactive messages, which allow you to build Tray workflows for things like:
- Approvals workflows
- Getting feedback from users
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:
Create a workflow with the Slack trigger. Select the On action (menu or button click) operation. Enable the workflow.
Create another workflow in a new tab with a manual trigger, and a Slack connector with the Send message operation selected.
Add some actions inside of a message attachment, and select the first workflow you created to handle the interactions.
- Send the message with the second workflow manual trigger. You should see the buttons show in Slack.
- 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.
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.
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.
Create a new workflow in the Tray dashboard, and add the Slack trigger with the On Slack event operation.
You may need to re-authenticate your Slack account. Make sure you tick the Reactions:read permission when authenticating.
Start the workflow, and wait for it to show Saved & enabled in the bottom left of the screen.
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.
(Optional) With a bit of workflow building, set up a boolean condition to message back into the channel when the :rage: reaction is added.
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.
Create a workflow, and pick the "On link share" operation.
Enable your workflow.
Open your Slack app, and click "Add features and functionality" > "Event Subscriptions"
- 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)
Add the "link_shared" event as the event you'd like to listen for, then save your changes.
Go to to the "OAuth & Permissions" page and ensure that you have the the "links:read" permission added to your app.
Re-install your app to your team.
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