Triggers are wonderful things!
Triggers are but one of the three building blocks that make up next-generation Slack apps. You will encounter all three as you navigate the path of building your Slack app:
Since triggers are what trigger your workflows, you need to have a workflow before you can create a trigger. Acquaint yourself with the documentation on workflows, then head back here. We'll wait!
With the knowledge of workflows within your noggin, let's take a look at how you can implement triggers into your new app.
Triggers can be added to workflows in two ways:
You can add triggers with the CLI. These static triggers are created only once. You create them with the Slack CLI, attach them to your app's workflow, and that's that.
You can add triggers at runtime. These dynamic triggers are created at any step of a workflow so they can incorporate data acquired from other workflow steps.
You will come to many forks in this metaphorical road that is trigger implementation. There are no wrong choices; all roads lead to your own next-generation Slack app. The first choice is which type of trigger you want to use.
There are four types of triggers, each one having its own specific implementation. Below you will find a guide for each type of trigger. Within each guide you will learn how to create, update, and delete that type of trigger.
In a hurry? You can create a basic link trigger with a single Slack CLI command!
Trigger type | Use case |
---|---|
Link triggers | Invoke a workflow from a public channel in Slack |
Scheduled triggers | Invoke a workflow at specific time intervals |
Event triggers | Invoke a workflow when a specific event happens in Slack |
Webhook triggers | Invoke a workflow when a specific URL receives a POST request |
Triggers created for a locally running app (with slack run
) are distinct from triggers created for an app in a production environment (with slack deploy
). It's important to keep this in mind when trying to view your app's triggers.
You can view triggers created in your local development environment with the slack run --show-triggers
command. Triggers created in the deployed environment will not be returned.
You can use the slack triggers list
command to view information about your app's triggers, including the trigger ID, name, type, creation, and last updated time. When you use that command, you'll be prompted to select the workspace and then the environment (either local or deployed) for the triggers to list.