Your guide to everything Workflow.

Using variables

The most powerful way to expand your workflows’ capabilities is by using variables.

What are variables?

At the most basic level, a variable allows you to save some content and access it later in your workflow as many times as you want. Variables are vessels for storing any type of content, whether it’s a bit of text, a bunch of images, a web page, or a dictionary of data.

Variables are represented by a small token, like Text Magic Variable, Ask When Run variable, or Clipboard variable. You place variables throughout the workflow to mark where you’d like to set and retrieve content each time the workflow is run.

By allowing content to weave in and out of the workflow at different points, you can build workflows with actions that don’t have to follow a direct linear path of inputs and outputs. You can store content at one point, perform an entire independent set of actions, and then grab that original content to use it again later.

Variables are a key concept in taking Workflow to a new level, allowing you to set up dynamic templates for content that fills in each time you use the workflow. When the workflow is actually run and progressing through actions, it looks for any variables, retrieves the content for each, and places it inline, producing consistent results every time.

Making variables

Workflow allows you to create variables either automatically with Magic Variables or manually with the Set Variable and Add to Variable actions. In most cases, using Magic Variables is preferred over manually creating variables.

Magic Variables

Throughout your workflow, each action’s output is automatically available as what’s called a Magic Variable. With Magic Variables, you can switch to a special view of the workflow composer that shows all of the outputs of the actions in your workflow as variables that you can select. This makes building workflows a breeze, as any action further down in a workflow can decide to pull an arbitrary output of an action earlier in the workflow.

Manual variables

If you want to manually create a variable, you can place a Set Variable or Add to Variable action after the action whose output you want to store, and give it a name to refer to later. Set Variable allows you to set a new variable for the first time or overwrite a previously-stored variable.

Add to Variable lets you add multiple pieces of content to the same variable by appending to the variable each time, storing the data as an ordered list.

While it’s possible to set variables manually, doing so tends to lengthen workflows and make them harder to read. More often than not, manual variables are unnecessary as Magic Variables do much of the same work more concisely. For example, you can replicate most of Add to Variable functionality by placing variables into a List action and retrieving the “List Items” variable later.

Using variables

When you want to use variables in your workflow, you can either put them in a text field, pass one as input to an action, or use one to replace an action’s parameter.

Adding to a text field

To add a variable in a text field, tap on any text field to bring up the keyboard and variable bar. You’ll see a button for “Variables” that expands the bar into a full tray, a magic wand for selecting Magic Variables, and up to four special variables for Ask When Run, Clipboard, Current Date, and Workflow Input, depending on the context.

To pick a Magic Variable, tap the wand icon in the variables bar (or tap the “Variables” button to expand the tray, and tap “Select Magic Variable”). The workflow composer will switch to an alternate view that show each action’s output, available for you to select.

Tap the variable that you want to add and its token will be placed inline in the text field where your cursor originally was, telling Workflow where you want the variable to place its stored data when the workflow is run.

The variable bar and tray will provide shortcuts to Magic Variables that you may want to use next based on recently added actions and variables you’ve named previously. Plus, there are four types of special variables, which appear in green in the variables bar:

  • Ask When Run, which prompts you to enter text in its place when the workflow is run,
  • Clipboard, which will insert what you’ve most recently copied at the time the workflow runs,
  • Current Date, which will insert today’s date and time, formatted to your preference,
  • and Workflow Input, which will grab the input that was passed into the beginning of the workflow (applicable for Action Extension workflows).

Using the Get Variable action

If you want to pass the contents of a variable as input into another action, you can use the Get Variable action.

Place a Get Variable action above the action you want to receive the input. Then tap “Choose”, and you’ll be presented with options to select a Magic Variable or pick from any variables you’ve set manually, if there are any. When the workflow is run, the contents of that variable will be retrieved and passed as input into the next action.

Replacing a parameter with a variable

You can also replace one of an action’s parameters with a variable, allowing you to dynamically toggle the settings of an action in the course of running a workflow. Tap on any blank space in the parameter area, and a variable picker will appear to choose a replacement variable.

For this to work, your variable will need contain the correct content. For example, to place a variable as the parameter on Get Trello Items, your variable needs to have a value of either “Boards”, “Lists”, or “Cards”. For parameters that are an on/off toggle, pass a 1 or 0 to set it as active or inactive, respectively.

Adjusting variables

Variables are powerful not only because they let you reuse content, but also because they have the ability to store rich metadata about that content and extract any of those details you want.

Once you’ve placed a variable in your workflow, you can tap on the variable to edit it. From here, you can set the content type, choose which details of the content to extract, rename the variable, or reveal the action that generated the variable.

Changing a variable’s content type

Workflow automatically detects the type of content that will be stored in a variable and use that as the variable’s default content type. In the variable editor, the button named “as ---” indicates the content type that will be used.

If you want force the variable to transform its content to a different type, tap the button and you’ll be taken to a menu that displays all of the content types supported in Workflow via the Content Graph. From here you can select a new type for the variable.

If you choose a custom content type, Workflow will use its Content Graph technology to attempt to coerce the content of the variable to the type you selected. For example, if you have a variable that stores a URL, you could change its content type from URL to Article. Workflow will then automatically fetch details about the article at that URL.

Choosing which details to get

Underneath the variable’s title and content type is a list of the properties offered by that content type. This list represents all of the available metadata associated with your content, allowing you to choose one to use as the output of the variable.

Every content type has a default property that will automatically be extracted if nothing else is chosen. However, if you do choose a specific detail to retrieve, the token for the variable will update to indicate your preference.

For example, an Image variable offers properties such as Width, Height, Date Taken, Location, and Camera Make. Each content type offers its own set of properties.

Pro Tip

It’s also possible to manually grab properties from any action’s output by using the Get Details actions like Get Details of Web Page or Get Details of Image. Browsing these actions is also a helpful way to explore the possible details to extract for each content type.

Renaming a variable

Once you’ve placed a Magic Variable, it’s also possible to rename the variable so that it more properly reflects how you intend to use it. Tap on a variable to edit it, then tap the “Rename Variable” button. You’ll be prompted with an alert where you can enter a new title for the variable. Once you’ve hit OK, all instances of the variable will be renamed, which can be helpful with longer workflows where you need to distinguish between the results of similar actions.

Reveal Action

In longer workflows with multiple variables, it can be easy to lose track of the original action that produced a variable. For that, there’s a “Reveal Action” button. When you tap on a variable, you’ll see a button at the top called “Reveal Action” that you can tap to scroll the workflow composer back up to the original source of the variable. When you’re done checking out the action, there’s a “Go Back” button at the bottom to return to where you left off.

Once you’ve grasped how to add, place, and adjust variables, you’ll start to see how variables make your workflows much more dynamic. You can reuse content multiple times, pull out particular details from the content with ease, and place that content anywhere in your workflow.

Variables let you make workflows that are capable of adapting to, well, a variety of situations, adjusting content on the fly while still getting things done exactly how you want.

Pro Tip

If you’re just getting started with variables, try heading over to the Gallery and browsing workflows there that take advantage of variables. Then try downloading one and testing it out. Moving the actions around or placing new variables affects the rest of the workflow – you’ll get the hang of it with a little trial and error.

Next, let’s move on to Using Choose from List.