Shortcuts 2.2, the second major update to Apple's automation app following October's 2.1 release, has been released on the App Store today. The new version of Shortcuts, which has been available to developers for testing via TestFlight for several weeks now, brings a variety of smaller refinements and bug fixes; more importantly, it extends Shortcuts' integration with one of Apple's most popular built-in apps: Notes. Additionally, Shortcuts 2.2 builds upon the existing 'Get Travel Time' action (based on the Apple Maps framework) with new Magic Variables well suited for shortcuts that integrate with Siri.
For the past few weeks, I've been building advanced shortcuts that take advantage of the new actions for Notes and Maps, which I'm going to explain and share in this article. The new shortcuts are also available through the MacStories Shortcuts Archive, which now features a dedicated Apple Notes section as well. Let's dive in.
New Apple Notes Actions
In version 2.2, Shortcuts can integrate with Apple's Notes app using actions that can create notes, modify them, and retrieve the plain text contents of specific notes without opening the app or showing a compose sheet. This has been made possible by the adoption of a new (and, so far, private) API that grants Shortcuts exclusive background access to the Notes app.
While third-party note-taking apps that integrate with Shortcuts via x-callback-url require using URL schemes that launch those apps to perform actions, the new Notes actions in Shortcuts 2.2 can write to and read from Notes in the background, without opening Apple Notes at all – just like Shortcuts is able to, say, interact with Health or Reminders directly (provided the user has previously authorized access to the selected app). This approach, while somewhat limited in this first release (as I'll explain shortly), expands the scope of Notes automation and brings some of the flexibility that was previously exclusive to web-based actions such as Evernote and Dropbox (which are based on web APIs and an account system that does not require opening their iOS apps).
There are three new Notes actions in Shortcuts 2.2, plus a tweak to an existing one. The new actions are Append to Note, Find Note, and Show Note; the Create Note action has been modified with the inclusion of a toggle that lets you turn off the 'Show Compose Sheet' option, which allows for the creation of new notes without user interaction.
When the 'Show Compose Sheet' toggle is disabled, passing any text-based variable to the Create Note action will create a new note with that text in the default folder of the Notes app in the background, without opening it. However, it is not possible to tell the action in which folder the note should be created, nor can you pass any formatted text to the action and expect a rich text note to be created in the Notes app.
This is the only limitation of the new Notes actions in Shortcuts 2.2: you're always forced to create plain text notes, and Shortcuts will always retrieve note contents as plain text, because these actions do not support formatted text or file attachments. So even though the Notes app fully supports styled text with inline attachments (such as images, videos, documents, etc.), Notes actions in Shortcuts 2.2 are built for plain text usage only. Any rich text or file object will be coerced to plain text upon saving it to Notes with automation; similarly, telling Shortcuts to retrieve the contents of an existing "rich" note will only return its plain text version without any formatting or attachment.
This is disappointing given Shortcuts' ability to process rich text as well as all kinds of files; I can only assume that the Shortcuts team is waiting for a deeper Notes integration in a future release of iOS, but this is just my theory. I don't begrudge them for taking this simpler route for now, but I hope supporting the full spectrum of data that can be saved into and read from Notes is planned for an update to Shortcuts in the future. It would be a shame not to take advantage of the flexibility of Apple Notes given Shortcuts' excellent support for rich text, files, and Magic Variables in its Content Graph engine.
Current limitations notwithstanding, the new Apple Notes actions in Shortcuts 2.2 open up some interesting possibilities for Notes users who'd like to speed up their note-taking and save some time when accessing notes from the app. The first shortcut that I built, called Dictate to Note, is a simplified version of my old Dictate Note (with Menu) shortcut that uses the new 'Find Note' and 'Append to Note' actions to quickly dictate text to an existing note in the Notes app. This shortcut is ideal for all those who keep a "note scratchpad" in the Notes app, and it can be used both from the Shortcuts app as well as the widget.
The first action in the shortcut, Find Note, is a good example of why accessing an app's documents and data in the background with an action is something Apple should open up to third-party apps in the future. The action can be configured with multiple filters and it can retrieve entire sets of notes that can optionally be sorted with custom parameters. First off, you can search for notes that match a specific search query in their title or body text, or which were created or last modified on a specific date. Obviously, these criteria support manual configuration with plain text searches or date pickers, but they can also be configured with variables previously generated in a shortcut. In this shortcut, I'm simply using a 'Name' filter to find all notes that contain the word "Scratchpad" in their title.
Second, results from Notes can be sorted. Sorting criteria include the body text, the folder where a note is stored, its name, creation and last modified dates, and a 'Random' value. As with other filtering actions in Shortcuts, you can optionally limit the number of results returned by the action. In this case, I chose to only retrieve one note called "Scratchpad".
Next, I used the Dictate Text action for speech-to-text. This action used to be available in Workflow before, but it was revamped with Shortcuts to support a 'Stop Listening' preference and the widget. This means that you can start dictation upon running a shortcut from the widget without having to be taken into the Shortcuts app; after a short pause, the shortcut will automatically pass converted text onto the next action and continue. Before the last action, I modified the output of Dictate Text to include an extra line break for better visual separation between lines in the Notes app.
The final step is Append to Note, which, as you can see, allows us to tell Shortcuts that the destination note should be the Magic Variable generated by the Find Notes Where action. This way, Shortcuts will know that the dictated text should be appended at the bottom of the "Scratchpad" note returned by the previous search action – a more elegant approach than hard-coding the note's title into the Note field because we can be sure we're dealing with a valid and existing note that was successfully retrieved at the beginning of the shortcut.
In just four steps, we were able to build a dictate-append to note shortcut that does not require Siri and which can be triggered either from the Shortcuts app or its widget. You can download it below.
Dictate to Note
Quickly append text to a Scratchpad note in Apple's Notes app using dictation.
The ability to find notes and filter them by date can also be useful to build shortcuts that present lists of notes sorted in ways that aren't supported by the Notes app. For instance, I always wanted to have a Notes widget that would give me a list of 10+ recently modified notes that I could tap to instantly reopen them. This kind of widget can be built using the new Notes actions in Shortcuts 2.2.
Using the Find Notes action without a filter applied, we can tell Shortcuts to retrieve 10 notes and sort them by 'Last Modified Date', ordering them by 'Latest First'. Shortcuts will communicate with the Notes app and assemble a list of 10 recently modified notes fetched from all folders across the app.
At this point, all the shortcut needs is a Choose from List action (which will display the list of notes) and a final Show Note action to open the selected note in the Notes app. The shortcut can be used from the Shortcuts app or from the widget; it doesn't require any URL scheme thanks to the native integration between Shortcuts and Notes, nor does it force you to hunt for a "donated" Siri shortcut to reopen a specific note. It all just works because Notes provides a native automation framework with configurable actions in Shortcuts.
View Recent Notes
Bring up a list of recently modified notes and quickly reopen one of them.
The principle behind the Sort Notes shortcut – find a note, then use Show Note to open it – can be implemented in more personalized search shortcuts that let users create their own menu with common search queries. The other Notes shortcut I built is called Find Notes (with Menu) and it allows you to reopen frequently used notes by choosing from a list of note titles. If you change your mind and realize you need to open a different note that's not included in the list of suggestions, you can also open the Shortcuts app and start typing a manual search query.
The idea here is that you create your own list of frequently used notes in Shortcuts (see image above) with the titles of individual notes you want to access quickly. Then, the shortcut adds an additional 'Search for Note Title' button to the list using the Add to Variable action. When the list is presented using Choose from List, you can either pick a note title and wait for Shortcuts to perform the Find Note-Show Note combo, or you can pick the manual search button, type a different note title, then wait for the note to be found and displayed in the Notes app.
It's worth noting how it only takes a second for Shortcuts to find a note inside the Notes app and how, once again, we can validate results before opening Notes because we're not trying our luck and invoking a URL scheme without knowing whether or not the destination item (the note) exists. Thanks to native Notes actions, we can confirm beforehand that the item we're seeking actually exists in the Notes app – a much better experience than blindly launching URL schemes with other note-taking apps.
Find Notes (with Menu)
Open frequently used notes choosing from a list of titles or manually search for a specific note in the Notes app.
The last Notes shortcut I want to share today can be used from either the share sheet or the widget, and it lets you append new content to the bottom of an existing note by either passing whatever was shared with the Shortcuts extension or manually typing/dictating some text.
In the first scenario, the shortcut is invoked as an extension and receives the input of the iOS share sheet. Unfortunately, as I explained above, Notes actions are limited to plain text for now, so anything you share will be converted to basic plain text; if you try to share a file or an image, for instance, Notes will save their file name rather than the actual file object. Therefore, this makes the extension ideal for saving text shared from other apps or webpage links from Safari. When running inside the extension, the shortcut will check if there's an input item to process, and if it finds one it'll append the text at the bottom of the note and finish execution. I recommend testing this for webpages, which are saved with their title and URL on a single line of text – it's a nice way to quickly append interesting links you come across to the bottom of a scratchpad note.
If there is no input, however, the shortcut will bring up a menu asking if you want to type or dictate some text to append at the bottom of the note. These actions can be completed from inside the Shortcuts app, the extension, or the widget. This makes the shortcut versatile enough to be used in a variety of contexts, and it's one I recommend installing to get an idea of the speed and reliability provided by Shortcuts' new Notes actions.
Append to Note
Quickly append text to a note called Scratchpad in your Notes app. Audio will be recorded using Shortcuts' native microphone access and dictation feature.
Travel Time Enhancements
The Get Travel Time action isn't new in Shortcuts 2.2, but it was considerably enhanced in this release with the addition of new details that can be retrieved as part of a 'Trip Info' object. Previously, the Get Travel Time action could only return the estimated travel time to a specific location; now, you can tap the Travel Time Magic Variable to reveal these additional details:
These extra bits of travel data can be leveraged to build custom shortcuts that let Siri be more precise and informative when telling you how long it'll take to get to a specific location. I built two shortcuts around this improved action that I'd like to share today.
The first shortcut calculates the travel time to get home based on your current location. After invoking the shortcut, either from Siri, the app, or the widget, you'll be presented with a descriptive message that includes the best route you should take (according to the Apple Maps API baked into Shortcuts), plus the actual travel time, distance, and estimated arrival time. As you can see in the screenshot below, the message is assembled by using several Magic Variables generated throughout the shortcut, with only a basic sentence structure around them.
What's nice about this shortcut is that the adoption of Magic Variables allows us to customize the Get Travel Time action without affecting the final output displayed in the last Show Result step. The first Street Address action should obviously be customized to include your house address. Then, you can choose between
mi (kilometers and miles) as the unit for distance, and you can also decide to return data based on three different transportation modes: driving, walking, or transit.
All of these options are fed to the Get Travel Time action, which generates a Magic Variable that can be "expanded" (i.e. tapped to reveal additional data points) and embedded in other actions. I now run this shortcut whenever I'm away from home and want to quickly know how long it'll take me to drive back, and I appreciate that I can choose to activate it either from Siri or the widget.1
Travel Time to Home
Calculate travel time to get home. The shortcut can be configured for different transportation methods and can be invoked from Siri or the widget.
The second Travel Time shortcut I built uses the same underlying foundation of Travel Time to Home, but rather than calculating travel time to a fixed address, it tells you how long it's going to take to get to the next calendar event that has a location attached to it.
To find events that contain a location, and not just any upcoming event, we can use Shortcuts' Find Calendar Events action and apply two search filters – 'Start Date is in the next 14 days' followed by 'Location is anything' with an
AND rule that will find events that match both conditions. Additionally, the action sorts events by start date (so that upcoming events are returned first) and the result set is limited to one event only. This way, we can make sure that "the next event that has a location attached" will be the item the shortcut is dealing with.
If no results are present, a Show Result action will tell you that no upcoming events with location could be found in the system calendar; otherwise, the shortcut will proceed to calculate the travel time to the event using the same system and message style as the previous shortcut. If you find yourself driving around town a lot between different calendar appointments, I think running this shortcut from Siri should come in handy.
Travel Time to Next Calendar Event
Calculate travel time to get to the next calendar event that has an address attached to it. The shortcut can be configured for different transportation methods and can be invoked from Siri or the widget.
There are some other changes and improvements in Shortcuts 2.2 I'd like to highlight:
iCloud sync is much improved. I've had trouble with Shortcuts' built-in iCloud sync ever since the first version of the app launched in September alongside iOS 12. At first, despite the presence of a setting to enable the option2, the ability to sync the order of shortcuts across devices never worked for me – as soon as I made a change to a shortcut on one device, it would scramble the entire order of shortcuts across all my devices. Then, for the past couple of months, I had to outright disable iCloud sync in Shortcuts because leaving it enabled would crash the app at startup. As someone who makes a living out of building shortcuts for people, you can imagine how frustrating it's been to have different sets of shortcuts between my iPhone and iPad. Fortunately, Shortcuts 2.2 has fixed the iCloud-related crashing bug and it has introduced a new sync ordering algorithm that is much faster and more reliable than before. I've stopped worrying about Shortcuts not syncing my edits between devices, which is nice.
The extension in the share sheet can accept images again. Arguably, this fix should have come out over a month ago immediately after version 2.1.3 of the app introduced a bug that prevented the Shortcuts extension from recognizing images passed to the share sheet. This has been fixed in Shortcuts 2.2, but I'd like Apple to act more quickly on these kinds of problems (which have been widely reported on blogs, Twitter, and Reddit) instead of waiting to ship a bigger release.
Get Numbers from Input. Shortcuts 2.2 introduces a new action to extract numbers from the data generated by another action. The new Get Numbers from Input action should be useful for all those who previously had to use regular expressions to find numbers contained in a string of text. I know I'm going to use this one quite a bit for my shortcuts.
New options for Adjust Date. The Adjust Date action, which previously only supported the ability to manipulate dates with additions and subtractions, now features a new 'Get Start Of' mode that lets you retrieve the start of a minute, hour, day, week, month, or year. For instance, if you ask for 'Get Start of Month' to a date variable that is 'March 23', you'll get 'March 1' as a result. Potentially useful for shortcuts that deal with advanced date calculations and relative dates such as my Apple Music Wrapped one, which I could update with this option in the future.
A new way to access nested dictionary values. If you work with dictionaries a lot, you know how tedious it can be to access values nested into multiple layers of sub-dictionaries and arrays. Shortcuts 2.2 simplifies this process with the introduction of a new syntax (somewhat inspired by Swift key paths) that lets you extract values from nested dictionaries and arrays without duplicating multiple Get Dictionary Value actions. To navigate dictionaries/arrays and extract specific values, all you need to do is write down key paths as shown below:
This method supports dictionary keys as well as items in an array (just enter the position of the item in an array) and it works both in the Get Dictionary Value action as well as the 'Get Value for Key' field of the variable inspector for a dictionary. This is a much better solution than the old approach; it's programmer-friendly – which is to be expected given the programmer-y nature of dictionaries and arrays – and it's going to help me rethink how I store and access data in some of my more complex shortcuts.
Tap the Library tab button to instantly scroll to the bottom of the grid. Finally, I have to mention the smallest refinement of this release that, however, has the biggest impact for all those users who maintain a library of hundreds of shortcuts: you can now tap the Library button in the tab bar to instantly scroll to the end of the grid. No more furious scrolling to quickly reach the bottom of the screen. Thanks, Tim Apple.
Shortcuts 2.2 is an iterative update that fixes a variety of technical issues, brings small but welcome improvements for existing actions, and introduces brand new automation possibilities for Notes. It's also very likely the last major update to Shortcuts before we see whatever Apple has in store for the app at WWDC 2019. While I would have liked the Notes actions to be a little more flexible, I'm happy to see Apple continuing to grow the range of iOS features that integrate with Shortcuts; I hope that some of these APIs will be made available to all third-party developers in June as well.
- If my iPhone is connected to my car's Bluetooth system, Siri becomes effectively unusable. Pressing the side button to invoke Siri involves a 4-second delay before I can start talking to Siri, and the audio quality of its responses is terrible via Bluetooth. I know that there's a setting in Siri to choose input devices when connected via Bluetooth, but unfortunately the preference doesn't stick. I wish there was a way in Settings to tell iOS to never use a specific Bluetooth device for Siri. It's been this way for years, and it's been never fixed. ↩︎
- It's located in Settings ⇾ Shortcuts (towards the bottom, in the list of apps). ↩︎