Use If actions in Shortcuts
Use the If action (also known as a conditional) to set up a shortcut that checks for certain conditions and operates differently depending on which condition is met. If actions give you the flexibility to set up different paths that your actions can take depending on conditions that are known only when the shortcut runs.
Simply put, the If action lets you express the following in a shortcut: If a condition is true do this; otherwise do that. A different series of actions is run for each result.
You can use the If action to test whether content that’s passed into the action as input meets a certain condition. For example, you could use the If action to verify that a webpage fetched from a previous action contains the word “goetta.”
Note: If you’re unfamiliar with the concept of inputs and outputs, see Intro to how shortcuts work.
Once placed in your shortcut, the If action includes three markers (tags in the shortcut editor): If, Otherwise, and End If.
In the If marker, you can configure the Input and Value parameters. Tap the Input parameter to choose a condition. The available conditions are dependent on the type of input. Text inputs have conditions such as: is, is not, and contains. Number inputs have conditions such as: is greater than, is less than, or is between.
Because the If action has two possible outcomes—the condition is true or the condition is false—you can place actions in two paths. When the shortcut runs, a true condition causes the input to be passed to the first action just after If, while a false condition causes the input to be passed into the first action after the Otherwise marker.
The last action to produce output in the If case or Otherwise case passes its content through the End If marker 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 action as a whole.
Tip: You can place If actions inside each other to create a more advanced tree of decisions in your shortcut: In the shortcut editor, drag a second If action so that it overlaps the lower portion of the first If action. The second If action is nested (indented) under the first If action.