Triggers are wonderful things!
Triggers are 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 kick off 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.
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.
Triggers can be added to workflows in two ways:
You can add triggers with the CLI. These static triggers are created only once. You attach them to your app's workflow, create them with the Slack CLI, 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.
Triggers created for a locally-running app (with the slack run
command) are distinct from triggers created for an app in a production environment (with the slack deploy
command).
There are four types of triggers, each one having its own specific implementation.
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 |
Get a quick rundown of the four different trigger types in this video:
Each type of trigger has a guide where you will learn how to create that type of trigger. Choose one to move forward:
➡️ To learn more about link triggers, read the link triggers documentation or explore the Give Kudos sample app. This sample app uses a link trigger to allow users to open up a form to give a compliment to a user.
✨To learn more about scheduled triggers, read the scheduled triggers documentation or explore the Virtual Running Buddies sample app. This app uses a scheduled trigger to post a weekly message to a channel about people's running activity.
✨To learn more about event triggers, read the event triggers documentation or explore the Welcome Bot sample app. This app uses an event trigger to send a message to a user when they join a channel.
✨To learn more about webhook triggers, read the webhook triggers documentation.