Shortcuts: Voice Controlled Options30 Nov 2018
Shortcuts on iOS is a wonderfully versatile tool and I use it for a wide variety of things. Sometimes I even use it hands free as Shortcuts support Siri trigger words. Unfortunately, the shortcut’s subsequent interaction tends to be rather one way unless you are able to access your device’s keyboard. But it is just a tendency. Shortcuts can still interact with you on basic decision making operations and I use this in a number of shortcuts, including, most notably, a briefing routine that not only varies by time of day, but allows me to customise the content as it runs.
In this post I’m going to show you the basic building blocks for how this works.
First of all, I have a very simple shortcut called “Speaker”. This shortcut contains a single action to speak the text it is passed. I’ve preset it with my preferred settings for Siri’s voice, language, pitch and rate. I’m used to listening to podcasts and watching YouTube videos at high speed, so I have things set a bit faster than normal speech.
This then means that whenever I want a Shortcut to say something, rather than having to set-up a Speak Text action each time, I can just direct the text to my preferred settings in the Speaker shortcut. You’ll see this come into play next.
Would You Like Me To
The core shortcut that allows me to take action on verbal input is called “Would you like me to”. The shortcut expects to receive a dictionary of parameters as it’s input. The dictionary is expected to contain at least two keys.
Shortcut. These are used by the Shortcut to ask me a question, listen for an affirmative response, and if it is heard, then it will run the listed Shortcut.
The first three actions take the dictionary input, formulate a question based around the phrase “would you like me to …” and the
Description entry, and then speak it to me using the Speaker shortcut.
Next dictation is activated, captures whatever I say, converts it to upper case and compares it to the word “YES”. Keeping this check simple and aligning it to the wording of the question is the fundamental basis for what I’m doing with this shortcut.
If there is no match, the shortcut runs through to the end. If there is a match, the dictionary is retrieved and is passed as input to an action to run a shortcut. A shortcut named from the
Shortcut entry in the dictionary. This means that parameters from the previous shortcut can also be passed through to the subsequent shortcut, as we’ll see in the next part.
The other shortcuts are very simple, but I’ve made this particular one available for download - Shortcut: Would you like me to.
Calling ‘Would You Like Me To’
How would this work in practice? Well, throughout my briefing shortcut I have options around what bits of information I would like to listen to. Each set of information to listen to be it a weather report, a daily podcast, or something else is managed by a separate shortcut and then the ‘Would you like to’ shortcut is used as a wrapper for each one.
Below is an excerpt from my briefing shortcut and it is one that I use for pulling in an RSS feed from the BBC and having the headlines and excerpts read to me. My briefing uses several RSS feeds and so my shortcut for reading RSS headlines is designed to accept a feed URL and a name for the feed. These are parameters that need to be passed to the RSS reading shortcut, via the ‘Would you like to’ shortcut, and so these items exist in the dictionary used, alongside the entries used by the ‘Would you like to’ shortcut.
The first action sets up the dictionary with four data items:
- Description: The suffix to the “Would you like to …” question presented in the “Would you like to” shortcut.
- Shortcut: The name of the shortcut to run if the response to the question in the “Would you like to” shortcut is “YES”.
- RSS: The URL of the RSS feed to be retrieved by the shortcut named in the Shortcut entry in the dictionary.
- Announce: The introductory announcement for the RSS feed as read out from the shortcut named in the Shortcut entry in the dictionary.
The second action is simply the calling of the ‘Would you like to’ shortcut using that dictionary as the input.
That’s all there is to it. By using the dictionary as a set of parameters, passing that to a shortcut that simply listens for a “YES”, it is possible to control at the most basic level some voice based interaction with a shortcut.