Create workflows that start with a webhook
- All members (by default)
- Available on paid subscriptions
Workflows are automated multi-step tasks or processes that run directly in Slack. Workflows can be as simple or as complex as you like, and typically don’t require writing any code. To create a workflow that runs when an event happens in an external service, you can use a webhook.
What you’ll need to get started
- Familiarity with sending HTTP requests using the command line or another tool
- An understanding of incoming webhooks. For guidance, read the documentation on Slack API, or ask a developer on your team for help
Note: Owners and admins can restrict access to creating workflows using webhooks. If you don’t see this option in Workflow Builder, find an owner or admin to ask for help.
Webhook workflow basics
All workflows in Slack start in response to a trigger. To trigger a workflow with a webhook, you’ll configure the webhook to run your workflow when an event that you specify occurs in another service. For example, you might create a workflow that posts a message in a particular channel when there’s a problem with your website so that your engineering team can investigate.
Configure your webhook
The external service that you use to create and configure your webhook must allow you to make an HTTP POST request to Slack when certain events occur. Slack will generate a unique request URL for your workflow once you publish it, and you can configure your webhook to pass information to Slack in the HTTP request body. Any data that your webhook sends to Slack can be referenced in steps that you add to your workflow by creating variables.
Tip: If you're not sure how to configure your webhook, we recommend asking a developer on your team for help or referencing any support documentation provided by the service you’re using, like Postman or Zapier.
Create custom variables
To create a custom variable, you’ll add a key value pair in Workflow Builder as a text-based variable. Once you add a variable, you’ll see a preview of the HTTP body so you can make sure that the values match up with the JSON outputs in the other service that you’re connecting to Slack with your webhook. Please note that it’s not currently possible to use nested JSON structures in workflow variables.
In the example below, if the user, severity and incident_description were not sent with your webhook request, the workflow would fail.
Tip: If you need to add, remove or modify variables at any point, open your workflow in Workflow Builder. Then click on the pencil icon next to Starts with a webhook to make your changes. You’ll also need to make sure that any changes to variables are reflected in the external service that your webhook request is sent from.
Get your web request URL
When you publish your workflow, Slack will generate a unique request URL that you can add to your webhook to ensure it sends the POST that you set up to the correct channel. Request URLs start with https://hooks.slack.com/triggers and are followed by a randomised string of characters.
Be sure to keep your request URL secure, as anyone with the link will have the ability to trigger your workflow.
Note: Webhook workflows are limited to one request per second. Learn more about rate limits on Slack API.
Add steps to finish your workflow
Once you've configured your webhook and created any variables that you’d like to use, you're ready to add steps to your workflow.
- Open your workflow in Workflow Builder.
- Click Add step.
- Choose the type of step that you'd like to add, then follow the prompts to customise the step.
Test your workflow
Before publishing your workflow in a channel members of your workspace are actively using, you can set up the first step to post to a test channel.
- Send a POST to your workflow’s request URL and go through the steps to make sure that everything is working properly.
- Go back to Workflow Builder and update the first step of your workflow to post in your preferred channel, then publish the changes.