The latest from Workflow Builder
By: Jim Ray
Tags: Apps, Slack, Automation, Developer, Bots

The latest from Workflow Builder

Illustration and design by Giacomo Bagnara.

Slack is where people, tools, and data come together in one centralized place, so you can stay focused, productive, and informed— like receiving an alert for a new support ticket or tracking a project status.

Usually that means installing a Slack app from the App Directory or building a custom app using Slack APIs. If you need a simple, but impactful way to connect external systems to Slack, you can now accomplish this with Workflow Builder.

Introducing webhook triggers in Workflow Builder

A webhook can now trigger a series of steps tailored to your work. Webhooks allow disparate systems to exchange information by sending a POST request to a standard URL with key-value pairs; Slack uses JSON to encode those key-value pairs.

This means information across various systems of record (like employee data, project trackers, or “to do” lists) can be sent to Slack when something happens you’d like to take action on.

Creating an incoming webhook trigger

If you’ve never used Workflow Builder before, it’s a visual tool for automating routine processes directly in Slack. Each workflow begins with a trigger, such as someone joining a channel. Then, a series of steps follow, like sending a message or displaying a form.

To kick off a workflow with a webhook, create a new workflow, give it a name, then choose Webhook from the trigger options.

Next, you’ll define the variables that your webhook will accept. Each variable can be named anything you’d like, it just needs to be a string. These variables will then be used in the steps of your workflow.

Webhook variables can be one of three data types:

1. Text, just a string (numbers and other ID’s will be treated as a string)

2. A Slack user email, which is the email address corresponding to a member of your workspace, such as sadie@example.com

3. A Slack user ID, which is the encoded ID uniquely assigned to every Slack user, such as U2665FE0F

Setting up a webhook’s variables

Text variables are plain text strings — nothing more, nothing less. However, the Slack user email and Slack user ID are unique, since they allow you to direct message or mention specific people in channels.

Imagine you’re creating an approval workflow — when someone requests PTO in your company’s HR tool, their manager receives a notification in Slack. Since the HR database hosts email addresses, you’ll set up the HR system to post to a webhook that has defined a variable for manager_email with a data type of Slack user email. The next step of the workflow sends a direct message to the value of manager_email . Slack automatically identifies the person based on their email address, so you’re all set.

Tips for working with webhooks

After you save your first webhook triggered workflow, Slack will generate a unique URL, which you will use to send data from your other system. You’ll need to encode the key-value pair(s) as JSON, set a header of Content-Type: application/json , and send them as an HTTP POST .

For example:

Your payload must include each webhook variable (though the value can be empty), and any extra variables that are sent but not expected are simply ignored. So, if you’re using a third party system that has a predefined webhook sending pattern, you can define your own variables to match.

Workflows that use webhook triggers support Slack message formatting — so you can *bold*, _italicize_, or ~strikethrough~ text, add newlines, link text, and (of course) express yourself with emojis :hearts: .

If you include a variable in a message that’s sent to a Slack user email or Slack user ID, we’ll automatically interpolate and display it as a linked username, just like when you reference a teammate by their username.

If your workflow includes a step that sends a direct message, the message will come from Slackbot, but will appear as your workflow’s name and icon.

Finally, you can regenerate the URL for your webhook at any time, which will invalidate the previous URL.

Using your webhook workflow

Webhooks are handy for connecting various systems without getting into the technicalities of app permissions and authentication. Here are some other ideas for how you might want to use webhook triggered workflows:

Set up basic triaging protocols when a piece of infrastructure hits a critical load or is behaving erratically. Because webhooks can be invoked with nothing more than a command line tool, this is a quick and simple way to set up an alert system.

Send notifications between external tools— especially for teams that use DevOps practices to manage their deploy pipelines. Using a git hook, a custom script could notify a channel that new code is ready to be reviewed. Once a suite of integration tests pass, another notification could alert a channel that the code is ready to deploy.

Track metrics for marketing campaigns, like reaching referral traffic goals or social media impressions; or for sales pipeline trends.

Though webhooks are currently limited to triggers from other systems, workflows don’t have to stop at notifications. Webhooks could trigger a form that cross-posts to a triage channel, where a separate workflow is watching for emoji reactions. The possibilities are endless!

Getting started with webhook triggers

Webhook triggers are one of the latest enhancements to Workflow Builder — so your work (and automation) is simpler, more pleasant, and more productive.

Need some inspiration? Check out the workflow example library for pre-built, customizable workflows. If you have an idea for a webhook triggered workflow, tweet it our way at @SlackAPI. We can’t wait to see you what you build.