SlackSlack is a cloud-based platform that brings all your collaboration and messaging tool needs together, for both individuals and companies.
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.
Please bear in mind that your Tray.io-Slack authentication can be set up with various permission boundaries. With this in mind, the instructions given here are just one of many possible use cases and should be taken as a guideline, dependant on your particular project needs.
When using the Slack connector, the first thing you will need to do is make sure you are already logged into your chosen Slack account.
Once this is the case, select and drag the Slack connector to your workflow, and click on 'New Authentication' in the step editor:
You will be shown a pop up similar to what is displayed below. Name the connector as appropriate and bare in mind that there are several options pre-selected for you, and numerous permissions available to choose from.
Depending on your usage, you may not need all or any of these permissions. What is being given here is the most commonly requested/ used.
Make sure you select or un-tick as necessary. If you are unsure of your own needs, use the pre-selected settings for now. You can always create a new authentication later if need be:
After you have clicked 'Add authentication' you will get a secondary popup screen, where you will need to confirm your permissions settings:
Once complete, your Tray.io authentication option should be pre-populated with your completed auth:
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.
- On action (button or menu click)
- On Slack event
- On slash command
When creating a new workflow choose Slack as your trigger at the 'Create new workflow' section and wait to be redirected to your new workflow.
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:
Full list of operations can be found HERE
- Add reminder
- Channel exists?
- Get user
- List channels in team
- Send Ephemeral Message
- Set Profile
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:
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 this 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.
For our beginner tutorial we will be demoing the 'Send message' operation as it is one of our most popular use cases. When a user joins a Slack channel, they will automatically have a welcome message displayed.
This example will demonstrate a use case involving Slack's Interactive messaging feature and how it can be used in a query /response scenario, in this case about tea (because tea is wonderful), over two workflows.
The advanced example will involve using another 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.
In this example we imagaine a scenario whereupon whenever a new user joins a particular channel a welcome message will 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:
First go to your Tray.io dashboard, click on the 'Create new workflow' button in the top right corner and name your project workflow. Select Slack as your trigger.
Make sure you have your Slack authentication set up before continuing. Follow the tutorial above for more details.
Select your Slack authentication in your Settings -> 'Authentication' field.
Set your operation as 'On Slack event' and in your 'Event' input field, choose 'User joined a channel (public or private)'.
This setup means that once a user joins a new channel, it will literally trigger the workflow.
Make sure you clink on the green "Enable workflow" button in the bottom right hand corner. Once it turns red, it means your workflow is "listening" out for an event to trigger its processes.
Select the Slack connector from the connector panel on the left hand side of your workflow dashboard. Place it on the next step of your workflow. Select your Slack authentication.
Set your operation to 'Get user' and your 'User id' to the following:
$.steps.trigger.event.user. MAKE SURE your type selector is set to 'jsonpath' else your workflow will fail at this step.
The icon on the top right corner of your input field should change as a result of this selection change. See the image below for more details.
While the jasonpath given above is not immediately obvious, even when using the connector-snake, this is a path available which is made clear once output is generated/ your workflow is triggered.
Take a look in your debug panel for more details:
Once more add a Slack connector to your workflow. Your operation this time will be set to 'Send Message'. Select your Slack authentication.
In your Channel input field, you should have an automated dropdown list of channels available as a result of the Slack domain you have setup with your authentication account. Choose an appropriate option for your workflow.
In the message section, we have an example of a written message that includes Tray.io's Interpolation.
INTERPOLATION: When you wish to include JSON generated data within another input/ output/ result, use our Interpolation method as described here.
This is a technique that can pull in data from our previous steps, and display the output accordingly. In this case, we have used it to get our message to display the new users name:
As an added extra, we have also included a Slack icon to display with our message. You can get this by copying and pasting an icon from the Slack app itself, and dropping it in the 'Icon emoji' input field. Despite it appearing as an image when it is copied, the text version will display here (but don't worry, the icon will show as normal once generated as you can see below!):
BEST PRACTICES: Whenever you do decide to use create your own workflow, please make sure you take a look at our Managing data best practices guide.