We’re back for the last installment in our four-part series about the iOS 12 Shortcuts app. The first article introduced readers to the Shortcuts app by describing the purpose of the app, the user interface of Shortcuts, and general settings. The second installment focused on actions, which are the building blocks of more complex shortcuts. The third article focused on creating a simple shortcut to demonstrate how to construct your own shortcuts, and today’s post provides a more complex shortcut using scripting tools as well as links to some helpful resources.
The Rocket Yard Siri News Reader Shortcut
Federico Viticci of the MacStories website has been a fervent advocate of iOS automation for several years, and he created a shortcut that acts as a verbal news reader for your favorite website. In this post, we’ll go through his shortcut action by action and describe what each action is doing. When we’re finished, you can ask Siri to “Read Rocket Yard Headlines” and the five most recent headlines from this website are read to you. Let’s get started.
1) Create a new, empty shortcut by launching Shortcuts and tapping on the Create Shortcut button.
2) Want to be a good shortcut programmer? It’s a great idea to insert comments into your code for future reference and to make your choice of actions clear to others who may use your shortcut. So let’s start by adding a comment action. Using the search field at the bottom of the empty shortcut, enter the word “Comment”.
Tap the Comment action to edit it, then type in something like this: “Grab the latest articles from The Rocket Yard. Use this as a Siri shortcut to listen to the headlines.”
3) Next, we need to set up a variable to temporarily hold a number for us. In programming jargon, a variable is “a symbolic name associated with a value and whose associated value may be changed”. In this case, we need to create a variable to capture and hold the number of lines of text to be displayed or read from an RSS feed. Tap on the search field again, and type “set variable”. The only thing we need to do here is give the variable a name — “Lines” — and then the shortcut assigns a value later on.
4) Now, add another comment action and enter “Grabbing headlines from The Rocket Yard”. So far, so good.
5) Add a Text action. As before, you can either scroll through all of the various actions available in Shortcuts or just type the word “Text” into the search field at the bottom of the shortcut. The Text action “passes the specified text to the next action”. In our Text action, type “The Rocket Yard”.
6) Maintaining our good practices, add another Comment to describe what we’ll do next — “Enter the RSS feed of the blog we’re grabbing headlines from”
7) Now we’re going to actually start doing something! Add a URL action to our shortcut. This action takes a specified URL — in this case, the web address of the RSS feed for The Rocket Yard — and passes it to the next step of the shortcut. Add the URL action to the shortcut and enter this URL: http://feeds.feedburner.com/owc
What our shortcut is going to do is get five items from the RSS feed for The Rocket Yard, and then loop through a process for each of those five items:
- Get its name (the headline of the article)
- Add that headline text into a variable called “News”
- Set the variable “Lines” to the value of the variable “News”
As we loop through this process, each successive headline is added to the variable “Lines”. At the end of five loops through this, we have the text of the last five headlines. Our loop looks like this (see screenshot below):
8) By now you know how to add actions to a shortcut, so we’ll leave it to you to find each action, enter the appropriate type of URL (RSS URL) for the shortcut to read, add one variable to “News” and set the other to “Lines” in the respective actions, and so on.
9) To display the headlines, the next step is to place the variable “Lines” in a text field and pass along the name of the website, then show the resulting text in a dialog on the iOS device screen. Those two steps are seen in the screenshot below:
At this point, we’re done with coding the shortcut. Tap the settings button at the top of the shortcut (looks like two toggle buttons, far right under the word “Done”, and set a name (I used “Rocket Yard Headlines”) for the shortcut as well as a button icon.
10) Run the shortcut by tapping on it. The result is a text dialog that looks like this (see screenshot below):
For extra credit, we can add this shortcut to Siri. In the shortcut settings, tap Add to Siri and say something like “Read Rocket Yard Headlines”. Siri not only runs the script when you say “Hey, Siri, read Rocket Yard Headlines”, but it reads the headlines to you as well!
This shortcut not only works on your iPhone and iPad, but HomePod and AirPods as well.
You don’t need to come up with your own flowchart for creating a shortcut, as there are repositories of shortcuts that may already do what you need. There’s one resource built right into the Shortcuts app — the Gallery — that has a number of shortcuts that can be added to your Library and edited to your needs.
Sharecuts is a website created by developer Guilherme Rambo that also features shortcuts developed by others. If you create a shortcut that is useful and unique, upload it to Sharecuts. I find that the shortcuts on this site are often useful for learning new programming techniques.
Apple has a Shortcuts User Guide available on its website that is a very useful resource. Whenever I have a question about the way action works or need clarification, I usually head to the User Guide to gain enlightenment.
Whenever you find that you’re going through too many individual steps to perform some task or tasks, consider making your life easier by creating a shortcut to automate the entire process. As you gain experience creating your own shortcuts, you’ll find that you can turn even complex processes into a one-tap shortcut.
- Read Part 1 here: The iOS Shortcuts App Part 1: An Introduction…
- Read Part 2 here: The iOS Shortcuts App Part 2: Apple and Third-Party Actions
- Read Part 3 here: The iOS Shortcuts App Part 3: Creating and Using Simple Shortcuts