The purchase of the Workflow app by Apple, and releasing it as Shortcuts app in their latest iOS 12 release, is a step forward in personal automation if you ask me. A huge step, but let’s zoom in to what is possible from a developers standpoint.
Shortcuts are a succession of actions, like ones interfacing with the native device capabilities exposed (camera, maps, text messaging etc), script actions such as setting/getting a variable and looping over a list of found/selected items, or even other inline shortcuts. When working with them you find that you can almost always find a way to realize the idea in your head with the building blocks provided. But that is exactly the limitation of the current implementation. They are linearly executed predefined building blocks that take an input and create an output. This leads to very cumbersome programming, with simple constructs like filtering/sorting becoming a huge headache.
In order to execute function-like behaviour you typically first park the main threads value in a variable, then extract what you need into new variables, do some processing (recursion or looping bringing even more headaches), and then ‘get variable’ to come back to the main thread. I find myself wishing for a real scripting environment all the time. Of course Apple tries to keep the attack vectors to a minimum with this approach, but maybe in the future a proofing layer over a scripted approach can achieve the same result. Making us developers happy shortcut coders.
But, being a power user seeing automation possibilities first of all, I felt the need to create some shortcuts. I spent quite some moments in my car lately, and am disappointed about Siri’s shortcomings when it comes to dictation in other languages and delegating results to other apps. So I created the following shortcuts:
- Dictate to Siri in my native language (Dutch), while operating her in English, and copying what I said to the clipboard (to be used in subsequent actions).
- Run other shortcuts that take clipboard contents as input, like automatically translating to english.
- Match a certain contact from voice/clipboard input (like from step 1)
- Extract maps location from voice/clipboard (which can contain an address of type Text, or a found Contact with one or more addresses)
- Navigate to (selected/clipped text, apple maps location or contact) with the app of my choice: Waze, sometimes Google Maps.
- Drive to a contact, or home, with Waze.
As you can see I have named the shortcuts with “>” in front (expressing it expects a previous input), or with “>” behind (expressing it is a building block for other shortcuts). I hope these shortcuts and it’s implementation details can serve you as well. I still have to find out how to publish my shortcuts in an open source manner like on GitHub. Maybe I will just create a repo with a doc of iCloud hosted shortcut URLs.
UPDATE: I have done just that and published my GitHub hosted shortcuts.
Have fun breaking your head over this new functionality!