HomeKit

Home automation is the perfect example of such background tasks. Contrary to what I expected, Shortcuts doesn’t offer a full-blown HomeKit integration to control individual characteristics of accessories or create recurring automations. For that, you’ll still have to use the standalone Home app. Instead, Shortcuts can set HomeKit scenes for any of your configured homes.

To trigger HomeKit scenes in Shortcuts, you’ll need to use the new ‘Run Home Scene’ action. Once added to a shortcut, there are two parameters to configure for this action: the home you want to control, and an existing scene you want to set. HomeKit scenes are presented in a list that can’t be searched, which may be slightly inconvenient for heavy HomeKit users who have set up dozens of scenes in their homes. Fortunately, the ‘Scene’ field of the action supports Magic Variables, so you can pass the name of a scene previously picked from, say, a custom ‘Choose from List’ action.

Your HomeKit scenes are available in Shortcuts with a dedicated action.

Your HomeKit scenes are available in Shortcuts with a dedicated action.

Despite the barebones nature of this action (as I mentioned above, you can’t control individual HomeKit accessories at all), I appreciate the inclusion of ‘Run Home Scene’ in Shortcuts as it allows the app to interact with HomeKit, even if in a limited fashion. This means it’s finally possible to build widgets that trigger HomeKit scenes or have Siri execute multiple scenes in a row. As I’ll explain later on, I’ve been taking advantage of this integration for a shortcut that I couldn’t create with the old Workflow app.

Run JavaScript on Web Page

This is one of the most surprising enhancements to Workflow’s existing roster of Safari actions: Shortcuts can execute arbitrary JavaScript code on a webpage and pass results to subsequent actions.

Executing JavaScript in Shortcuts can only happen inside the action extension when you run a shortcut from the share sheet in Safari or Safari View Controller. The action is sandboxed to the Safari process and the current Safari page; it can’t control other browser tabs or access data from other apps. A ‘Safari web page’ item needs to be the input type of this action, which can return text, dictionaries, boolean values, or numbers as output.

Of course, you can use variables with JavaScript in Shortcuts.

Of course, you can use variables with JavaScript in Shortcuts.

The first time you run a shortcut with a JavaScript step in Safari, you'll be asked to grant JavaScript access to a domain. This permission prompt comes up once per domain, and it's specific to each shortcut containing JavaScript.

The first time you run a shortcut with a JavaScript step in Safari, you’ll be asked to grant JavaScript access to a domain. This permission prompt comes up once per domain, and it’s specific to each shortcut containing JavaScript.

These requirements notwithstanding, you can execute any JavaScript code you want as long as it doesn’t contain any synchronous functions such as alert() or prompt().30 You can read and modify the contents of a webpage inline, perform HTTP requests and regular expressions – if you know JavaScript well enough, you can put together complex scripts that can do almost anything you’d be able to do with a JavaScript console in a desktop web browser.

I’m not a JavaScript expert, but I’ve been impressed with Shortcuts’ ability to return structured data and file objects via JavaScript, which can then be processed with other actions in the app. An obvious implementation of Run JavaScript will be adapting bookmarklets to execute inside the Shortcuts extension, but I look forward to seeing users come up with more advanced ideas that combine visual Shortcuts actions with JavaScript – something that bookmarklets alone were never able to achieve.

Set Do Not Disturb

With this new action, you can enable Do Not Disturb with the same set of options available in Control Center.

Once added to a shortcut, flipping the Do Not Disturb toggle will reveal an ‘Until’ field in the action that lets you choose between multiple options for disabling Do Not Disturb later:

  • Until turned off
  • Until a specific time
  • Until you leave the current location
  • Until a calendar event ends

Of these settings, the ‘Time’ and ‘Event Ends’ options can be configured with variables. For time, you can pass a valid date/time item (which can be typed in natural language too) and Shortcuts will engage Do Not Disturb and automatically disable it when it reaches its expiration time. For the calendar, you’ll need to pass a Calendar Event object, which you can obtain with the ‘Find Calendar Events’, ‘Add New Event’, and ‘Get Upcoming Events’ actions.

You can now create custom shortcuts to set Do Not Disturb with the same options available in Control Center, augmented with variables.

You can now create custom shortcuts to set Do Not Disturb with the same options available in Control Center, augmented with variables.

Alas, Shortcuts cannot schedule Do Not Disturb to start at a specific time; it can only enable it now and disable it later. I assume this is due to iOS’ own inability to create standalone Do Not Disturb schedules. In the future, I’d like this action to include a start time option and new ways to control the geofence’s radius when leaving a location. Still, it can be useful to activate Do Not Disturb as part of a more complex shortcut, or to have a widget that can set Do Not Disturb with presets.

Markup

If you want to annotate an image or PDF document and save it somewhere else, Shortcuts now supports the native iOS Markup mode – the same annotation feature you can use in Notes, Files, and other system apps.

Native Markup inside Shortcuts.

Native Markup inside Shortcuts.

The Markup action supports images and PDFs as input types, and returns their annotated versions as output. Whether you’re using it in the Shortcuts app or in the share sheet, the action will display the full-screen annotation UI to add shapes, text comments, and drawings to a document. It would have been nice to set default colors and tool sizes to be automatically loaded when Markup comes up, but I’m just nitpicking at this point. I’ve had fun incorporating this action in my screenshot shortcuts.

Other System Actions and App Changes

Here’s a list of other system actions that are new in Shortcuts:

Open multiple URLs at once. Shortcuts replaces Workflow’s old hack to open multiple URLs in Safari with a native solution to open dozens of links at once in separate tabs. In a nice touch, Safari can present a new prompt if you attempt to open too many URLs at once; on most devices, the prompt will be displayed if you try to open more than 50 URLs, but the threshold is lower on older devices. In addition to being tied to Shortcuts’ Open URLs action, the new prompt also kicks in if you try to drag and drop too many links onto Safari’s + button on iPad.31

If you see this alert, something has gone terribly wrong with your shortcut.

If you see this alert, something has gone terribly wrong with your shortcut.

Send and Request Payment. Based on the existing SiriKit domain for payments, these actions allow you to request and send money using third-party payment apps that already work with Siri. For instance, in addition to Apple Wallet, you can use Square Cash or N26 as actions that don’t even need to open the main app (though that’s an option). Fields you can customize with variables in these actions include the recipient’s email address, amount, and optional notes.

iCloud sharing. In replacing the old Workflow Sync service, Apple also reworked how sharing shortcuts with other people works in the new Shortcuts app. You can now share custom shortcuts via iCloud: in the shortcut editor, tap the share sheet and choose ‘Copy iCloud Link’; after a few seconds, the share sheet will be dismissed and you’ll have an icloud.com shareable URL in your clipboard.

Opening the iCloud link for a shared shortcut takes you to a webpage containing a preview of the shortcut and a button to import it into the Shortcuts app. In my tests, iCloud sharing – just like the new iCloud shortcut sync – has been fast and reliable.

Device Scripting. In the Device section of the Scripting category, you’ll find new actions to toggle Airplane Mode, Bluetooth, Cellular Data, and Low Power Mode. Unfortunately, it is not possible to connect to specific Bluetooth devices from Shortcuts.

Set Brightness. In the old Workflow app, this action could only control the brightness of the app itself. In Shortcuts, you can change device brightness system-wide without opening Control Center. As before, you can set brightness manually with a slider or by passing a numeric variable between 0 and 1.

Show Result and Siri Integration

The last new action in Shortcuts deserves a standalone mention as it’s probably the most important of the bunch, and the one that will unlock fascinating new possibilities for automation in iOS 12. The action is called ‘Show Result’, and it allows you to program a custom Siri response that the assistant will display and read aloud when a custom shortcut is triggered with a personalized phrase.

The contents of the Show Result action become a text response in Siri.

The contents of the Show Result action become a text response in Siri.

This brings me to another essential advantage of Shortcuts over Workflow: in iOS 12, you can assign a phrase to a custom shortcut and let Siri execute it in the background like other native app shortcuts. With the exception of specific cases in which Siri won’t be able to complete execution of a shortcut inline, this integration allows you to enhance Siri with a virtually endless list of personal commands. With iOS 12 and Shortcuts, automation turns into something more than running a sequence of actions in an app or widget: it can become a way to expand Siri itself, making it infinitely more useful and tailored to each user.

To trigger an individual shortcut with a custom phrase, you need to open a shortcut’s settings screen and tap the ‘Add to Siri’ button. Once given a phrase, a shortcut can be summoned from Siri, which will run it in the background unless it hits a step that isn’t supported by the assistant.

How to add a custom shortcut to Siri. The 'Add to Siri' button shows you the personalized phrase you recorded.

How to add a custom shortcut to Siri. The ‘Add to Siri’ button shows you the personalized phrase you recorded.

In this first version of Shortcuts, unsupported actions include any kind of user interaction. If a shortcut requires you to type or dictate text, choose from a list of items, or preview data with Quick Look, Siri will have to open the Shortcuts app and finish executing the shortcut there. Only shortcuts that do not require any user interaction can be fully executed inside Siri.

With this in mind, if you have shortcuts that perform sequences of actions without your input or launching other apps, you’ll be able to run them entirely within Siri. When you summon a shortcut with a custom phrase, Siri will display a “Running your shortcut…” message along with a small intent snippet for the requested shortcut; it’ll then proceed to run actions in the background and, if available, provide you with a custom voice response.

Custom Siri responses can be configured with the ‘Show Result’ action. This is similar to ‘Show Alert’ in that it can be filled with arbitrary text or variables and doesn’t support showing images or other document types with Quick Look – just text.

First, you configure a custom Siri response in the editor...

First, you configure a custom Siri response in the editor…

...then, you run the shortcut with a custom phrase in Siri, and the fun begins.

…then, you run the shortcut with a custom phrase in Siri, and the fun begins.

Unlike Show Alert, the Show Result action doesn’t have a title field and doesn’t contain buttons to continue or stop execution of the shortcut. If a shortcut is running inside the Shortcuts app, the extension, or the widget, Show Result will bring up a native alert; however, when a shortcut is invoked from Siri, Show Result’s alerts become text responses read aloud by the assistant.

The same Show Result response in the Shortcuts app, Siri, and the Shortcuts widget.

The same Show Result response in the Shortcuts app, Siri, and the Shortcuts widget.

Responses configured in the Show Result action can be as verbose as you want, and they can be intermixed with other actions or suggested shortcuts by apps. For example, if a custom shortcut contains both native app shortcuts and a custom Show Result response, running the shortcut in Siri will produce multiple responses: you’ll see the visual intent and response from a third-party app, plus the response you configured yourself in the Shortcuts app.

In the example below, you can see how a custom Show Result response (labeled as “Shortcuts says…”) coexists with other native app shortcuts, each executing a task in the background. The same custom shortcut can even have multiple Show Result responses, which Siri will read as it runs through each action.

Multiple native app shortcuts in a custom shortcut...

Multiple native app shortcuts in a custom shortcut…

...become multiple visual responses in Siri.

…become multiple visual responses in Siri.

With shortcuts and customizable responses, Apple is effectively giving users an intuitive tool to program their own Siri commands. All of this happens with no traditional “coding” whatsoever. This approach is not necessarily about automation per se as much as it’s about automation as a means to an end – leveraging Shortcuts’ automation features to make Siri do exactly what we need.

As you’re going to see with the following examples, the marriage of Siri and Shortcuts automation unlocks a whole new level of flexibility in iOS 12.


  1. Due to time limits for extensions running in Safari, they won't be able to call the completion handler. ↩︎
  2. Good luck creating a drag and drop stack of 50+ URLs. ↩︎

Supported by PDF Viewer Pro:

Read, review, and annotate PDFs on the go with PDF Viewer Pro.

A
A
Add Bookmark
DarkLightAutomatic

Use this link to save your spot in the review and return to it later.
You can add this as a bookmark or share it with friends.