I actually automate a bunch of things in my many workflows, but mostly they’re so specific I tend to think most people wouldn’t be interested. This is an exception.
Workflow don’t call it Workflow now it’s Shortcuts is something I’ve at best dabbled with in the past few years. I’ve found in the past few months as I’ve added multiple steps to post-production of my podcasts, that I was occasionally forgetting a few steps from time to time. I started looking for apps that created convenient templated checklists and came up with no really viable out of the box options that appealed.
I’ve been using Things to plan my life and tasks for many years now and having that on all of my devices (iPhone, Apple Watch, iPad and Macbook Pro) is extremely handy to have so rather than change that, I started digging into automating input into Things. I’d read that Things supported a URL Scheme so dove in.
First I built a test JSON Text string that was static, to prove that it would work:
{"type":"to-do","attributes":{"title":"Episode","when":"today","tags":["Podcasting"],"checklist-items":[{"type":"checklist-item","attributes":{"title":"Publish Notes"}},{"type":"checklist-item","attributes":{"title":"Publish Ad-Free"}},{"type":"checklist-item","attributes":{"title":"Test Item 1"}},{"type":"checklist-item","attributes":{"title":"Test Item 2"}},{"type":"checklist-item","attributes":{"title":"Test Item 3"}},{"type":"checklist-item","attributes":{"title":"Test Item 4"}},{"type":"checklist-item","attributes":{"title": "Test Item 5"}}]}}
The shortcut was really simple: The above JSON in a Text field, wrapped with “things:///json?data=[ JSON ]”, feeding into a URL object, then feeding into Open X-Callback URL, no custom callback or success URL and it worked perfectly.
A few experiments and the order of the keys in the JSON weren’t important, so long as the levels conformed with the URL Scheme it worked like a charm.
Creating a more sophisticated Shortcut was a bit more annoying. I’ve attached the Shortcut image and file but to walk through each section and why:
- List: Some of the shows I edit
- Choose from List: Prompt the user to pick one from the list, only one though
- Set Variable (Podcast): As a programmer, I don’t like Magic Variables since they hide their source when you’re visually reading the Shortcut. This variable is the selected podcast from that List
- Ask for Input (Episode Number): Ask for what episode we’re working on as a user input
- Text: Here we combine the “Podcast” variable with the text ‘Episode’ followed by the result from the line above (the episode number)
- Set variable (To Do Main Title): Save the full main title of the To Do List item for later.
- Text (list of Carriage Return separated items): Building a checklist underneath a To-Do requires a list of items. This will be the template for every checklist. Add/modify as needed in the Shortcut.
- Set Variable (Checklist Items): Save that checklist
- Get Variable (Checklist Items): Use that in the next line.
- Split Text: Using the new line separator (aka a Carriage Return) we split the text ready to run a repeat for each entry in the checklist
- Repeat with Each: Cycle through each checklist item from the text field
- Dictionary (repeat until done): Build the JSON dictionary with type “checklist-item”, and “attributes” with a single text item with the Key “title” and the value “Repeat Item” from the repeat loop (aka the actual line of text for this checklist item)
- End Repeat: What it says on the tin
- Set Variable (Checklist Items Dictionary): This is now a complete dictionary of all of our checklist items we’ll embed later into the final JSON dictionary.
- Dictionary: This is our second-level down of the JSON, where we define the To-Do’s Title (saved from earlier), we set the due date to today, then we set an array for what tags we want applied to it. I use an imaginatively named tag in Things called “Podcasting” which is added as a Text entry in the array. You could add more entries for multiple tags if you like.
- Set Dictionary Value: Adds the Checklist Items Dictionary we created earlier against the key “checklist-items”
- Set Variable (Attributes Dictionary): Save this to our Attribute level of the Things JSON
- Dictionary: This is the top-level of our JSON dictionary, where we simply create the item of “type” “to-do”
- Set Dictionary Value: Adding in our second-level JSON Dictionary we prepared earlier, the Attributed Dictionary under the key “attributes”
- Set Variable (JSON Output): The final Dictionary now saved as a Variable
- Text: Build the final text string and wrap the JSON around the URL Scheme
- URL: Interpret the above Text as a URL
- Open X-Callback URL: Call the URL, but I didn’t want any custom callbacks or success URLs, because I just didn’t.
And we’re done. Yes I could tidy up some bits and yes you can use Magic Variables and yes I could embed Variables directly rather than Get Variable every now and then, but never mind that. The code is hopefully more readable than most other examples I came across, tried to follow, then just created it from the ground up to make sense.
Hopefully that’s useful for some one (other than just me) at some point in the future that wants to make checklists from a standard template as a repeatable task in Things.