Your guide to everything Workflow.

Using If conditionals

The If action can be used to set up a workflow that checks for certain conditions and operates differently depending on which condition is met. If conditionals give you the flexibility to set up different paths for your actions to take depending on conditions that are only known when the workflow runs.

Said simply, the If action lets you express in a workflow: “If a condition is true do this, otherwise do that.”, running a different series of actions for each result.

Use If to compare inputs

Use the If action to test if content that’s passed into the action as input meets a certain condition. For example, you could use If to check if a web page that was fetched from a previous action contains the text “meatloaf”. If you’re unfamiliar with the concept of inputs and outputs, see How workflows work before continuing.

Setting up an If action

To set up If, drag it into your workflow after an action whose output you’d like to check with a conditional. Once placed in your workflow, you’ll see the action comes in three parts: If, Otherwise, and End If.

Within the If portion you can configure the “Input” and “Value” parameters. Tap the Input parameter to choose one of the four available conditions:

  • Equals, for testing if the input is an exact match to the value you’ve specified, whether text or a number.
  • Contains, for testing if the input contains the bit of text you’ve specified at least once (in a larger body of text).
  • Is Greater Than, for testing if the input is greater than a certain number.
  • Is Less Than, for testing if the input is less than a certain number.

Greater Than and Less Than are only applicable when a number is passed as input.

Since the If action has two possible outcomes – one where the condition ends up being true, and one where it ends up being false – there are two paths where you can place actions. When the workflow runs, a truthful condition will cause the input to be passed to the first action just after If, while a false condition will cause the input to be passed into the first action after Otherwise.

The last action to produce output in either the If or Otherwise cases will pass its content through the End If as output (available to retrieve as an “If Results” Magic Variable). This means that the last action in each path of the If action affects the output of the block as a whole.

Pro Tip

You can place If actions inside each other to create a more advanced tree of decisions in your workflow.

Let’s move on to Using Repeat loops.