This Week's Sponsor:

Listen Later

Listen to Articles as Podcasts

Workflow 1.7 Introduces Magic Variables for Easier, More Powerful Visual Automation

Magic Variables in Workflow 1.7.

Magic Variables in Workflow 1.7.

At its core, Workflow is a visual programming app that deals with variables. Data flows through actions and is altered by the user until it has to be stored in a variable – a local reference that can be recalled in subsequent steps.

Since the app’s original release, the Workflow team has done a commendable job at abstracting the complexity behind variable creation and management, but the feature itself is a vestige of traditional programming languages. The manually-saved variable is fundamentally ill-suited for Workflow’s visual approach predicated on direct manipulation of actions. Workflow revolutionized several automation concepts, yet it was always anchored in the common practice of declaring variables between actions.

For the past year, I’ve been lamenting the sluggishness involved with setting variables and extracting additional details from them. Anyone who’s ever created complex workflows has likely come across the same problem:

  • There’s a “master variable” that contains rich metadata (such as an iTunes song or an App Store app);
  • You want to extract details from the master variable – e.g. an app’s name, icon, or price;
  • Each of the variable’s sub-items has to be extracted by repeating a combination of ‘Get Variable-Get Details of Variable-Set Variable’ over and over.

Not only did this limitation make workflows slower to create – it also made variables difficult to explain and workflows harder to read for people who aren’t proficient in iOS automation.

As someone who writes about iOS workflows on a weekly basis, I’ve been thinking about this issue for a while. Every time I had to explain the inner workings and shortcomings of variables, I kept going back to the same idea: Workflow needed to get rid of its clunky variable management altogether.

Here’s what I proposed when Workflow 1.5 launched in May 2016:

“Instant Variables” to get details of a macro variable without doing the Get Variable-Get Details-Set Variable dance every time. You could save a lot of time if instead of fetching details of a variable multiple times you could use a single master variable and only specify where necessary which sub-details to use;

With today’s 1.7 update, the Workflow team isn’t introducing Instant Variables. Instead, they’ve rebuilt the engine behind variables on a new system called Magic Variables, which completely reimagines how you can create workflows and connect actions for even more powerful automations.

More than a mere tweak for power users, Magic Variables are the next step in Workflow’s goal to enable everyone to automate their iOS devices. By making workflows easier to create and read, Magic Variables are the app’s most important transformation to date, and the result far exceeds my expectations.

It’s a Kind of Magic

Magic Variables mostly remove the need to manually save variables. They leverage Workflow’s Content Graph engine to automatically keep track of variables in the background, allowing you to access them at any time with the ability to change their type (format). It’s a novel idea, and it’ll take a few minutes to fully grasp, but it’s drastically superior to Workflow’s old variables. Magic Variables will change how you build workflows.

Each action in Workflow accepts an input and produces an output of a certain type. By default, a ‘Text’ action generates a string of text, while a screenshot from the photo library generates a PNG image. With Magic Variables, you no longer need to save the output of an action into a named variable. Instead, when you need to use a variable, you can tap a new “magic wand” button above the iOS keyboard to pick the output of any previous action and use it as a variable. Even if you didn’t save that action’s output into a variable, Workflow now tracks it at runtime to reuse it in other actions later. So, while in the old Workflow you would have had to set and recall variables with this familiar flow…

Manually setting variables in Workflow.

Manually setting variables in Workflow.

…in Workflow 1.7, you can forget about manually setting variables and let the app take care of it:

The new Magic Variables in Workflow 1.7.

The new Magic Variables in Workflow 1.7.

The feature may seem more complex than the old system, but Workflow communicates the new functionality with an intuitive design that behaves as you’d expect it to. When you tap the Magic Variable button, the app dims actions and brings up a selection screen where you can scroll the workflow and view action outputs as blue buttons. Here, you can see and understand how action outputs work.

Picking a Magic Variable from the new full-screen editor.

Picking a Magic Variable from the new full-screen editor.

While in previous versions of Workflow the output of each action would only be passed to the next one and lost if not saved into a variable, Workflow 1.7 remembers every action and its relative output while a workflow is running. Thus, you can tap a blue Magic Variable (which wasn’t saved by you) and use it in any other action.

On the surface, this change alone sounds like a sensible addition to the app that can reduce the steps required to remix data and chain actions. But the Workflow team didn’t stop at an easier way to pick automatically generated variables.

The true nature of Magic Variables – what makes them somewhat magical – lies in how you can transform them without additional actions. The Workflow team has devised a way to change the format of a variable as well as extract its details directly from the variable’s UI. Once you see how it works, you wouldn’t be able to go back to the old Workflow.

Unlike normal variables, Magic Variables carry the icon of the action that generated them. In addition to being a visual aid, the icon indicates the default type of a Magic Variable: one containing text has a yellow text icon, while a Magic Variable resulting from a ‘Search App Store’ action carries the App Store’s logo next to its name. Tap on a Magic Variable, and you’ll open an inline menu where you can alter the type of the variable and pick which of its details to use.

Tap a Magic Variable to edit it and change its type.

Tap a Magic Variable to edit it and change its type.

If you, like me, spent hours creating workflows that iterated on variables to extract metadata from them with dozens of separate actions, you can imagine why this is a big deal. With Magic Variables, you can specify which parts of a variable you need by selecting them from a built-in menu. Have a master App Store variable but only need the price of an app? Just tell the Magic Variable that you want to extract the ‘Formatted Price’ sub-item. How about only passing the artist of a song instead of the full item returned from iTunes? Same story: pick the Magic Variable and filter it to only return the Artist.

Changing the type of a Magic Variable from Safari webpage to Article.

Changing the type of a Magic Variable from Safari webpage to Article.

Variable details are indicated with a darker shade of blue in the same variable token, and they can be reverted at any time to the original state of the Magic Variable.

Visually, the difference between how you used to parse variables and Workflow 1.7 is striking:

Workflow 1.7 (right) doesn't need to use multiple 'Get Details of Variable' actions.

Workflow 1.7 (right) doesn’t need to use multiple ‘Get Details of Variable’ actions.

When I was considering the possibility of easier sub-variable creation in Workflow last year, this is exactly the kind of system I had in mind. Rather than requiring you to navigate through multiple stages of extracting variable details, Magic Variables make metadata an option that is clearly presented in the interface. Thanks to this, workflows are easier to manage; what used to be a series of 10+ actions can be summarized in a single collection of Magic Variables.

There’s more, though. Magic Variables can be renamed: in the editor, tap on the ‘Rename’ button and you’ll be able to assign the variable a unique name to be reflected throughout a workflow. Every time you open the Magic Variable editor, you’ll see the custom name you assigned.

Magic Variables that have been assigned custom names.

Magic Variables that have been assigned custom names.

The combination of icons, custom names, and inline variable details goes a long way towards making workflows more readable – something that couldn’t be said for the generic look of variables and the repetition of ‘Get Variable-Get Details of Variable’ action pairs in the old Workflow.

Once you start adapting your workflows to Magic Variables, you’ll also notice that it’s easy to lose track of what each action does when there’s no more ‘Set Variable’ step to act as a descriptive label.

The Reveal button highlights the actions associated with a Magic Variable.

The Reveal button highlights the actions associated with a Magic Variable.

Fortunately, next to Rename, there’s a Reveal button that scrolls to the action that generated the currently selected Magic Variable.1 This makes it easy to jump back and forth between a Magic Variable and the original action behind it, which helps when debugging long workflows.2

The other notable trait of Magic Variables is how they represent Workflow’s Content Graph engine through one-tap type coercion.

Let’s back up a bit first. Since Workflow 1.0, one of the app’s greatest assets has been its engine – the Content Graph – that intelligently converts data between formats to avoid errors in workflows as much as possible. Normally, for instance, you would think that passing an image to a Text action would generate an error; with the Content Graph’s type coercion, Workflow assumes that an image passed as text means the user wants to extract the file name of the image. It’s with this system that Workflow is able to turn URLs into PDFs of a webpage, Maps links into JPEGs, or an App Store result into an app icon saved into your photo library. Workflow constantly assumes what the user’s intention might be in case it hasn’t been stated with specific actions.

With Magic Variables, conversion between data formats reaches its logical conclusion as a visual picker embedded within the Type menu of a variable. Upon tapping a Magic Variable, you’ll see the type that Workflow loaded for it by default as a blue button under the variable’s name. You can tap this button to open a list of types and dynamically change the nature of the variable without the need to execute other actions.

Converting Magic Variables between different types.

Converting Magic Variables between different types.

One-tap type conversion opens intriguing possibilities for automation. The reduction of “processor” actions to change types3 increases the flexibility of variables, which in turn should enable deeper customization of actions. By putting the spotlight on type conversion, Magic Variables highlight the foundation of Workflow’s engine with unparalleled clarity.

Magic Variables have cut my most complex workflows in half. They allowed me to focus on the functionality of each action rather than remembering to save its output for later. While advanced chains of actions were possible before Workflow 1.7, Magic Variables make everything faster and easier to create, as well as nicer to look at.

Magic Variables are the best change to happen to Workflow since launch; I’ve prepared a few examples to explain why.

Working with Magic Variables

Alongside Magic Variables, Workflow 1.7 introduces new ways to pick variables and enter them in action fields. From a new variable bar that sits above the keyboard, you can access the Magic Variable editor, open a grid of variables, but also scroll a row of dynamic variable suggestions as well as shortcuts for “quick inputs” such as the clipboard, the current date4, and the ‘Ask When Run’ dialog.

The variable bar isn’t just a prettier way to pick variables for actions. Workflow will also contextually suggest Magic Variables depending on which action is currently being edited. If you’re entering a variable in a ‘Text’ action placed after a ‘Choose from Menu’ item, the end result of the menu will be suggested as a Magic Variable; when adding a reminder that follows a choice to pick a photo from the library, a ‘Photos’ Magic Variable will be displayed as a shortcut in the variable bar.

The new variable suggestion bar in Workflow 1.7.

The new variable suggestion bar in Workflow 1.7.

In my experience, Workflow 1.7 has correctly predicted which variables I wanted to use based on previous actions. It’s a small tweak, but it adds to the time savings of this update. Combined with the app’s existing list of suggested actions, it’s never been easier to get started making workflows.

My favorite example of the power of Magic Variables is my updated workflow to turn articles from Safari into templates for linked posts in a text editor.

I use this workflow on a daily basis: whenever I find a story I want to link on MacStories, I select some text on the original webpage and run the workflow. In a couple of seconds, I end up with a post template in Ulysses containing Markdown text as well as the original’s author name. There’s no manual copy & paste and I never type the author’s name wrong because it’s automatically extracted by Workflow.

Thanks to Magic Variables, this workflow has been cut down to 6 actions. The majority of the work happens in a ‘Text’ action where three Magic Variables perform the following data manipulation:

  1. A URL is converted into the title of the webpage through variable detail extraction;
  2. Using type conversion, the input of the action extension5 is first converted from ‘Safari webpage’ to ‘Article’ and then the author’s name (a variable detail) is extracted;
  3. The output of ‘Make Markdown from Rich Text’ is referenced as a Magic Variable.

The benefit of Magic Variables is apparent in this workflow. Instead of having to micro-manage outputs with a stream of ‘Set Variable’ and ‘Get Details of Variable’ actions, I can just throw in actions and recall their outputs later in an interface that also lets me change their type and fetch details I need. This workflow was possible before (I’ve been using it for almost a year now), but it’s never been this short or readable. You can get the workflow here.

The versatility of Magic Variable details and variable suggestions is most impressive in the workflow I use to save an App Store result as a “rich app card” in Trello. This is the workflow I use whenever I find an app or iMessage sticker pack I want to link in our newsletter: with a couple of taps, I can go from an App Store product page to a card in Trello other team members can see.

From an App Store app to a rich Trello card.

From an App Store app to a rich Trello card.

This workflow, however, was quite long before Workflow 1.7 – 28 actions, mostly comprised of ‘Get Variable-Get Details of App Store App’ iterations used to extract the app details required to create a card in Trello.

With Magic Variables, I was able to go from 28 actions to 14 actions while retaining the same functionality and achieving a clearer presentation of the workflow. Most of the heavy-lifting is now handled by a single Magic Variable in the ‘Add Trello Card’ action: the same variable is repeated multiple times in the description field of the card, each time with a different variable detail. This way, what used to be 9 actions (3 for each variable detail) is now 3 Magic Variables that don’t require any action at all.

Old actions (left) can now be built using Magic Variables.

Old actions (left) can now be built using Magic Variables.

Combined with the Magic Variable for the output of the If block and the lack of ‘Set Variable’ actions, these changes led to the removal of 14 actions, cutting the length of the workflow in half while preserving all of its functionality. You can get the workflow here.

I’ve observed similar savings in my workflow to save a currently playing song in a playlist and send it to my girlfriend over iMessage. This workflow used to contain 15 actions that extracted song details (name, artist, and iTunes URL) before adding the song to a playlist and preparing an iMessage.

Now, the same workflow requires 7 actions thanks to Magic Variables. Song details I want to send in an iMessage are assembled in a ‘Text’ action; they’re the result of a ‘Search iTunes Store’ action that returns 10 songs, which are then passed to a ‘Choose from List’ step. The song picked in the list is still an iTunes-type product, which means Magic Variables can extract details about the song from it. You can get the workflow here.

I’m in the process of updating all my workflows for Magic Variables, and a trend is clear: along with fewer actions per workflow, the role of the ‘Set Variable’ action is changing.

Despite Magic Variables, it is still possible to set variables and use them as you’ve always done. However, the use cases for manually setting variables are now extremely limited. The only instance where I can imagine users might want to have a named variable is for workflows where a variable of the same name changes across non-contiguous blocks of actions.

Between Magic Variables and suggestions for outputs of Repeat and If blocks, I effectively see the ‘Set Variable’ action as deprecated in Workflow 1.7. It’s still around and it can be used in workflows, but Magic Variables are the future.

There are some implementation details of Magic Variables I would have liked to see done differently.

Some action fields (like Trello’s Attachments one) don’t let you tap on a Magic Variable to extract details. I assume this is due to how certain fields in Workflow already open a popup to pick variables when tapped (it’s the same deal with the Category field in the ‘Search iTunes Store’ action, for instance), but this shouldn’t have been the case. The inability to fully use Magic Variables in some fields adds inconsistency to the app. Every field of every action should support the full range of Magic Variable editing.

While it’s remarkable that Magic Variables can convert types and perform advanced operations such as extracting a specific value from a dictionary6, these built-in controls haven’t been brought to other variable types that would benefit from them. You can’t restrict a regular expression match to a specific capturing group from a Magic Variable, for example, and you can’t fetch an indexed item from a list unless you use a separate action. In future updates to the app, I hope we’ll get additional options for type conversion and detail extracting in other formats.

Finally, with an easier way to convert variables between types as well as fetch details of a variable, it’s become clear that Workflow needs a ‘Generate Collection’ action to combine multiple variables together and pass them to another action.

There should be an easier way to do this.

There should be an easier way to do this.

Think about it: if you want to combine a string of text and an image in a single variable, how would you do that? You’d have to iterate over multiple bits of content and use the ‘Add to Variable’ action, which is still the only way to create collections of items with different types. A ‘Generate Collection’ action with an empty field would make it possible to bundle multiple Magic Variables together, enabling shorter workflows that, for example, send an email message containing text and images or tweets with messages and video attachments. This isn’t a problem per se, but it’s a byproduct of the new flexibility enabled by Magic Variables.

A New Workflow

I often ponder what the Workflow team should address in the app’s journey towards version 2.0. Magic Variables are precisely the enhancement that Workflow needed to move past the boundaries of classic programming environments; they rejuvenate Workflow’s creative side by simplifying an essential aspect of visual coding such as variable management. After trying them, it’s obvious that Magic Variables make more sense than anything that came before.

Magic Variables couldn’t exist in traditional scripting languages; they are only possible thanks to Workflow’s unique approach to visual automation.

Looking back at the past year in Workflow’s release cycle, it’s impressive to witness how much this team has accomplished. With App Store automation, integration with web APIs, better community and sharing tools, and now a complete overhaul of variables, Workflow is a profoundly different app from the one that launched in December 2014. At this point, lack of folders and other organizational features is the next big thing the Workflow team should tackle.

Magic Variables make Workflow feel like a new app altogether. They’re a fantastic addition to iOS automation and I look forward to updating years of workflows for Magic Variables.

Workflow 1.7 is available on the App Store.

  1. Doing so will highlight an action with a delightful drop shadow, which the Workflow team is bringing back in style throughout the app. Several UI elements of Workflow now carry borders, depth, and shadows – I like it. ↩︎
  2. To mark up other actions visually, I recommend using the ‘Comment’ action to add descriptions inline. You’ll thank me later. ↩︎
  3. Routines that span 5+ actions can now be cut down to one Magic Variable↩︎
  4. The date variable entered from the keyboard can be adjusted like any other Magic Variable: you can tap to change the format for date and time within the variable. This removes the need to use two separate actions (‘Date’ and ‘Format Date’) to achieve the same functionality. ↩︎
  5. Another default Magic Variable in Workflow 1.7. ↩︎
  6. Which makes working with web APIs in Workflow downright amazing now. ↩︎

Unlock More with Club MacStories

Founded in 2015, Club MacStories has delivered exclusive content every week for over six years.

In that time, members have enjoyed nearly 400 weekly and monthly newsletters packed with more of your favorite MacStories writing as well as Club-only podcasts, eBooks, discounts on apps, icons, and services. Join today, and you’ll get everything new that we publish every week, plus access to our entire archive of back issues and downloadable perks.

The Club expanded in 2021 with Club MacStories+ and Club Premier. Club MacStories+ members enjoy even more exclusive stories, a vibrant Discord community, a rotating roster of app discounts, and more. And, with Club Premier, you get everything we offer at every Club level plus an extended, ad-free version of our podcast AppStories that is delivered early each week in high-bitrate audio.

Choose the Club plan that’s right for you:

  • Club MacStories: Weekly and monthly newsletters via email and the web that are brimming with app collections, tips, automation workflows, longform writing, a Club-only podcast, periodic giveaways, and more;
  • Club MacStories+: Everything that Club MacStories offers, plus exclusive content like Federico’s Automation Academy and John’s Macintosh Desktop Experience, a powerful web app for searching and exploring over 6 years of content and creating custom RSS feeds of Club content, an active Discord community, and a rotating collection of discounts, and more;
  • Club Premier: Everything in from our other plans and AppStories+, an extended version of our flagship podcast that’s delivered early, ad-free, and in high-bitrate audio.