Build a workflow: Create a workflow that starts outside of Slack
With webhooks, you can start a workflow from outside of Slack, and use custom variables to post messages to Slack containing information from external services.
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 who can create workflows with webhooks. If you don’t see this option in Workflow Builder, find an owner or admin to ask for help.
Workflow setup
Webhook workflow basics
When you choose to start a workflow with a webhook, you’ll configure the webhook to kick off your workflow when a third-party app or service sends a web request to your URL. For example, you might create a workflow that posts a message in a particular channel when there’s a problem with your website so your engineering team can investigate.
Configure your webhook
The external service 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 your webhook sends to Slack can be referenced in steps 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
You can add up to 20 variables to pass data into Slack from another service and include Slack-specific information (like display names or email addresses) in steps you add to your workflow.
To create a custom variable, you can add a key value pair to the webhook configuration in Workflow Builder by selecting one of the following data types: channel ID, user ID, user email, or text. Once you add a variable, you’ll see a preview of the HTTP body. Make sure the values in the body match up with the JSON outputs in the service 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.
Get your web request URL
Once you’ve copied the web request URL, you can add it to your webhook to ensure it sends your HTTP POST to the correct conversation. The request URLs all start with https://hooks.slack.com/triggers and are followed by a randomized string of characters.
- When you've finished creating your variables, click Done, then click Continue to generate the unique web request URL and return to Workflow Builder.
- Click the pencil icon next to From a webhook.
Be sure to keep your request URL secure, as anyone with the link will have the ability to start 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
Add steps
Once you've configured your webhook and created any variables 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 you'd like to add (for example, Send a message to a channel). Then, follow the prompts to customize the step.
- Click Insert a variable and select your variable to include data from the webhook in the message the workflow will send to the channel.
Test your workflow
Before publishing your workflow, 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 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.
- All members (by default)
- Available on paid plans