# Slack triggers

# Requirements

Before using Slack triggers, you'll first need to create a Slack app. The app also needs to be installed to your workspace. This should be your first step before building Slack recipes.

Fortunately, Slack has made it really easy to create an app. Head over to https://api.slack.com/apps (opens new window) and select Create New App. Choose a name for your Slack app and as well as your workspace, to create your app.

Creating a Slack app Creating a Slack app

Before you can install it to your workspace, you'll need to define at least 1 permission scope — but we'll go through that later.

# Enabling event subscriptions

For the trigger to pick up events, your Slack app needs to know where to send these events to. That's why the New event trigger comes with a target URL, generated once you've entered an Event name. Once your app is sending events to your recipe's target URL, the recipe can take over and execute your recipe's actions.

Target URL Target URL for your app to send events to

Event names don't have to be unique in your Workato workspace — this means that you can use same event name in multiple Slack recipes. This allows you to trigger those recipes using a single event, if it suits your use case.

To enable event subscriptions, go to your Slack app's page (it should look something like 'https://api.slack.com/apps/{your_app_id} (opens new window)' — your app ID is unique to your app). Under Event Subscriptions, turn on 'Enable Events', then paste the URL from your New event trigger into the Request URL field and click Save.

Event subscriptions Enabling event subscriptions

# Subscribing to workspace events

Slack provides an entire list of workspace events that you can subscribe to — any of these events can kick-start your recipe.

In this example, customer success users are given the option to create a private channel between themselves & their customers whenever messages containing the word 'resolve' are posted in certain channels and direct messages (DMs). Hence, the events message.channels, message.groups and message.im were chosen as triggers.

Event subscription example Whenever a message is posted to a channel, a private channel, or a DM, an event is sent to the recipe

Event subscriptions require permission scopes to be defined for your Slack app, but fret not — once events are subscribed, Slack automatically adds the required scopes.

# Installing your app

Once you've subscribed to at least 1 workspace event, a permission scope is automatically added, allowing you to install the app to your workspace.

# New event trigger (real-time)

The New event trigger picks up all workspace events in your connected Slack instance. Each new event trigger comes with a target URL, generated once you've entered an Event name. As explained above, this target URL is used to enable event subscriptions.

# Input fields

# Event name

Key in an Event name to generate a unique target URL for subscribing to workspace events. This should be descriptive of the events you're subscribing to.

Event name Keying in the event name generates the target URL used for subscribing to workspace events

# Output fields

Input fields Description
Team ID ID of Slack workspace.
API app ID ID of your Slack app that's subscribed to the workspace event.
Event ID ID of event.
Event time Timestamp of event.
Event Type Type of event.
User User ID of user who triggered the event.
Text Message content of text.
Ts Timestamp of event.
Channel Channel ID where event occurred.
Event ts Timestamp of event.

# Button click (real-time)

The button click trigger handles button clicks. These button clicks come from another recipe that posts a message with buttons to the user. Learn more about using buttons in our Using Slack message buttons document.

# Input fields

There are no input fields.

# Output fields

Output fields Description
Action name Button label visible to Slack user interacting with the buttons.
Action ID Internal value of the button.
Channel ID ID of channel where button was clicked.
Name Name of channel.
User ID User ID of user who clicked the button.
Name Name of user who clicked the button.
Team ID ID of Slack workspace.
Domain Domain of Slack workspace.
Action timestamp Timestamp when button was clicked.
Message ID ID of message that contained the button that was clicked.
Attachment ID ID of the button that was clicked. Buttons are a form of message attachments in the context of Slack.
Response URL URL for responding to button clicks, used in the Respond to button click action.

Last updated: 7/2/2021, 8:43:36 AM