Apple Shortcuts: Introduction to Automation

"Automation" is a general term to describe a broad range of ways we save time by creating a thing (task, script, app) which does something we would otherwise need to do manually.

Barriers to Automation

Traditionally, automation required the knowledge of some sort of programming language. Languages like Perl, Python, and Ruby all started out being used heavily for script due to their relative simplicity and expressiveness. It still required a serious investment in learning the syntax, the libraries, and how to read error messages for even the simplest of tasks.

Another barrier to entry for many users is the lack of available or easily understandable hooks into the features and applications they want to automate.

What is Shortcuts?

In 2017, Apple purchased the third party app Workflow, which allowed the user to wire up many different actions to be performed in order. In iOS 12, Apple made available new ways for app developers to expose functionality which can be triggered by this app (and the system directly via Siri). They added this ability to the app and re-released it as Shortcuts.

There are a mix of simple and advanced steps you can add to your shortcut which range from things like "open a webpage in Safari" to "execute script over SSH" or "match using regular expressions."

Although made by Apple, Shortcuts isn't installed by default. You can download it from the App Store for free on any iOS device running iOS 12 or later.

Example Use

I have a friend who often references songs I've never heard or can't quite remember. Sometimes she'll send links to a video of the song, but I don't really want to watch the ads or log in to a social media site just to listen to music. Wouldn't it be great if I could just tap on the name of the song and have it play via Apple Music?

First, I'll open up the Shortcuts app and start a new shortcut. In the top right there's an icon which looks like options sliders. Clicking this, you can give the shortcut a name and icon. More importantly, you'll want to select "Show in Share Sheet" and set "Text" as the Accepted Types. This means that you can invoke this shortcut as a share action when you have text selected.

Since we selected only text as the input type, the shortcut will receive a string (text) as input. We want to search on this.

Add Search iTunes Store and set the Search to be the Shortcut Input. Change the last setting to only return 1 Item (we'll assume it's the correct one). This will return some type of song object that we can pass to the next action.

Now add Play Music. Nothing has to be configured here - it will take its input from the previous item, which is the song we wanted to play.

Technically, that's all we need to do to simply play the song. But it'd be nice to get a little notification with the full title and artist.

Add Show Notification to the shortcut. Here I'm setting the Title to be "Found Song". Inside the content of the alert, I'm adding "Now playing [iTunes Products Name] by [iTunes Products Artist]". Those two placeholders there can be found on the top of the keyboard when editing the body, and they're pulling information from the result of a previous shortcut.

The full workflow should look something like this:

Now go highlight some text that contains the name of a song and long tap to click Share > * Shortcuts* > Play Music. It should start playing and send you a notification.

Obviously, this is a trivial example, but there may be some pretty powerful automations you could write (and share) that can save you a lot of time.

Automator

As a closing note, I'll mention that macOS has, for quite some time, shipped with an application called Automator which is very similar to Shortcuts. There are built-in actions to interface with many parts of the operating system, as well as the ability to have chunks written in AppleScript or any other scripting language. These can be run like an application, as something like a magic folder you can drag files to as input, as a "service", or bound to a keyboard shortcut. Just poking around the app might give you some ideas of tasks you'd like to automate.

Protect Your Business Data

We are passionate about helping our customers protect their data. We want you to use Jungle Disk to protect yours. Click on Sign Up to get started. It takes less than 5 minutes!

Sign Up