Wave GoodBye to Workflow, Say Hello to Shortcuts

It’s iOS 12 release day and the time has come to do something many people feared as long ago as March 2017 – it’s time to say goodbye to Workflow. I’m extremely happy to have had Workflow – and what’s more I’m happy to say goodbye to it because today Shortcuts launches and we have nearly everything that was in Workflow – and a way for app developers to hook straight into the app and the operating system.

What are we losing?

This question was what came to my mind at WWDC, I try not to be negative but a concern for many of us Workflow and automation nerds was “what won’t work anymore?”. Thankfully there are only a few things which we have truly lost:

  • File manipulation in Box
  • Triggering IFTTT Applets
  • Post to Slack
  • Save to Transmit (as the app is no longer on the iOS App Store it’s not a surprise)
  • Post to Tumblr
  • Edit Image
  • Send via DeskConnect (also unsurprising – the service was shut down long ago).

The only one of these that really causes difficulties is the edit image action, while you can still crop images and various other actions you can no longer do so in an interactive manner as part of a Shortcut.

What have we gained?

We have gained a lot in Shortcuts, here’s a list of actions which to my knowledge didn’t exist in Workflow but are part of Shortcuts – but aren’t donated to Siri by an app developer.

  • Add to Draft (Drafts 5)
  • Get Contents of Draft (Drafts 5)
  • Open Draft (Drafts 5)
  • Run Drafts Action (Drafts 5)
  • Markup
  • Request Payment
  • Run Javascript on Web Page
  • Send Payment
  • Set Airplane Mode
  • Set Bluetooth
  • Set Cellular Data
  • Set Do Not Disturb
  • Set Low Power Mode
  • Set Wi-Fi
  • Show Result

The last action is most interesting to me – it works like an alert if you run a Shortcut from Shortcuts, but will display the answer in Siri if you call the shortcut from Siri. The dictation action has also had an upgrade – allowing it to stop automatically after a pause, or a short pause, or on a tap (you can choose). This makes Shortcuts much more useful if you’re using it via Siri.

What’s still to come?

The possibilities here are seemingly endless – I’ve already seen many of the apps I use daily updating to support Shortcuts, from Waterminder to TripIt, Carrot to Working Copy, and many more. What we get now will be up to the app developers – but they seem to be making the most of it!


Backing Up Your Workflows/Shortcuts

It’s almost time for the iOS 12 release and while I think that Shortcuts is going to be a separate app in the App Store to update to from Workflow, backups are a good idea. Of course backing up your device is a good idea, but it certainly wouldn’t hurt to do a separate backup of your Workflows or Shortcuts that you’ve created – and maybe it’s time to clear out your collection and start afresh (speaking as someone with over 800 Shortcuts, it’s definitely time!).

I’ve created both Workflows and Shortcuts to do this for you, the Shortcuts shortcut is designed to be run on each of your devices – while iCloud Sync should be working now, some of us with extremely large libraries have had the syncing get a little stuck.

Essentially all this does is grab all of your Workflows and create a zip of them in iCloud Drive, the date and time you run the automation is included in the file name, and the Shortcuts variation also includes your device name.

Backups are good, and even if everything goes perfectly on Monday, which I’m sure they will, you won’t regret it!

Keep on automating.

Download the Workflow

Download the Shortcut


Workflow: Upload Blog Post via SSH

I use Grav as my blog CMS, it’s powerful and customisable, and it lets me upload blog posts via (S)FTP. The catch? My previous system for blogging involved using Transmit and Workflow – and sadly Transmit for iOS is no more. (You may be wondering why I’m only changing my system now, instead of back in January when Panic stopped working on Transmit for iOS. It’s simple, it was still supported in Workflow, sadly it is no longer supported in Shortcuts.)

This Workflow takes advantage of the stdin input option for the Run Script Over SSH action, in simple terms it means that you can give this action input as well as using variables as input in the script section.

A quick lesson on how Grav works for those unfamiliar with it and looking to modify this for Jekyll or another CMS:

  • There is a User folder where the data for your site is stored (config files, pages, etc.)
  • Inside of this folder is the Pages folder, where your pages are stored.
  • Folders inside of this become slugs the URL, so my blog posts are all in blog.
  • The file name is the name of the twig template.

To start with I choose where I want to store the post, if it’s a link to a guest post it goes in one folder, and a blog post goes in another – this is just my personal preference. I’m using a dictionary to do this because then I can see one option, but have it output something different – as my blog is the second item in my menu I would have to choose 02.blog every time otherwise. The next step is asking for the slug – this is nearly always on my clipboard (because I run this from Drafts and Drafts puts the slug on my clipboard!), then I get the text that was shared to the Workflow and Run Script Over SSH – which is where all the magic happens. The workflow I’ve shared does the following:

cd user/pages/$Chosen_Location;
mkdir $Slug;
cd $Slug;
cat > blogpost.md;

I’ve used the dollar signs here to represent Workflow variables – the key line is the last one, where I save the input of the SSH action to the file blogpost.md.

Steps:

  • Dictionary: This is a list of the folders where I might choose to save a blog post.
  • Choose from List: I choose one of those folders
  • Ask for Input: And grab the slug for the post.
  • Set Variable: I save the slug to a variable
  • Get Variable: And then I get the blog post shared to the Workflow.
  • Run Script Over SSH: Finally I run the SSH script.

Now, I actually save my blog posts in numbered folders – Grav will drop the number and dot at the start of the a folder name and use the rest of it as a slug, this helps me find posts based on when they were published from a folder list. If I create the post in the Grav admin GUI then it numbers them automatically, but it is possible to do this on the command line too! The script I use is as follows:

cd user/pages/$Correct_Location;
filecount=$(ls | wc -l);
mkdir ${filecount}.$Slug;
cd ${filecount}.$Slug;
cat > blogpost.md;

What this does is it counts the files and folders in the current folder and saves them to a variable on command line called filecount – and then I use this to create the folder for me. This variable is only valid for this session – but that’s fine for what we need. The folder where the post will be published contains a file which will display the list of blog posts and this gives me the +1 I need to create the next folder.

I hope this script is of use to at least one person!

You can get the workflow here: Upload Blog Post


Workflow: Add Task & Sub Tasks To OmniFocus

One thing I frequently do in OmniFocus is to add an action group, that is a task with a series of sub tasks. Action groups are flexible because they can be turned into projects if necessary, or be a series of tasks within a project.

The Workflow works by asking you for the main task, then it asks for the sub tasks. Each sub task is indented (and has a dash added in front of the name to make it TaskPaper friendly), and then the whole lot is put into my OmniFocus inbox.

Exact Workflow Steps:

  • Ask for Input: This is the main task.
  • Text: Add a dash before it – which in TaskPaper makes it a task not a project.
  • Add to VariableTask List
  • Ask for Input: Ask for the sub tasks.
  • Split Text: Turn this into a repeatable item
  • Repeat with Each – go through the sub tasks.
    • Text: Add the tab indent and the dash before each task.
    • Add to VariableTask List
  • Get VariableTask List. This makes sure we get the main task too, the output of the repeat loop would just be the sub tasks.
  •  Combine Text: Put the action group together.
  • Add TaskPaper to OmniFocus: Everything goes into my OmniFocus inbox.

You can get the workflow here: Add Task & Sub Tasks To OmniFocus.


Workflow: Markdown To Nice PDF

Every so often I want to make a nice PDF from some text which is currently formatted in Markdown and I often do this by sharing the text to Workflow. Unfortunately by default when you make rich text from markdown in Workflow you end up with something like this:

Yes, that’s Times New Roman. Not a font I usually use by choice. Thankfully however it’s quite simple to fix this with my Workflow. This can be accomplished in a number of ways, I convert the rich text to HTML, replace the <body> tag with one containing a HTML inline style (<body style="font-family: Arial, Helvetica, sans-serif;">), make rich text from that HTML, and then make the PDF. The body in HTML is where all of your content is, so this will then apply to all of your text. If you just wanted to change the first level of headings, you could replace the <h1> tags instead.

This is how the whole Workflow runs:

  • Make Rich Text from Markdown
  • Make HTML from Rich Text
  • Replace Text, this is where I replace the body tag.
  • Make Rich Text from HTML
  • Make PDF, make sure that include margin is enabled otherwise the PDF looks funny.

Bonus: The PDF contains the text as well, so it’s searchable and also accessible. All you need to do is to add an action at the end of the Workflow to make it do what you want with it, you could quick look it, share it, open it in another application or save it somewhere you choose!

You can get the simplest workflow here: Markdown To Nice PDF

It would also be possible to link a style sheet, such as the [Pure CSS] one, by adding the css link to the <head> tag, the caveat of this is most pre-built CSS files work best when you add classes to sections (e.g. <table> would be <table class="pure-table">), which will require many more Replace Text actions if you want to account for all the possibilities.

If you want the Pure CSS version is also available.


Automators 1: Automating Calendar Events

This week’s episodes of The Automators is focused on calendar event creation. There are many ways you can automatically create calendar events, and it’s useful to be able to do so, to avoid losing information. You can also use calendar events as a trigger to do something – which we cover towards the end. Below there are details of all the automations we cover, including 4 (really, four!) screencasts.

Workflow: Calendar Event Templates

This is a very simple Workflow which asks me for the date and time of the event, and then what kind of event this is (the demo has 3 examples) – it then adjusts the time to add an appropriate length for the appointment and adds it to my calendar. This is very useful because I can never remember what floor my dentist is on or exactly where to turn to find my hairdresser – so I can add this to the notes. Even if the places you frequent are not hidden like mine are you can still use this!
You can get the workflow here: Calendar Event Templates Make sure to read on to find out about the “Run Workflow” action at the end of it.

Workflow: Add Event To Work Calendar

This workflow follows the first one, and is in fact run by it – or could be. It simply asks you if the appointment you’ve made is during working hours, and if you say yes, adds an event that starts half an hour before and ends half an hour after the appointment you’ve just created to your calendar. Make sure to tweak the calendar setting here! You can get the workflow here: Add Event To Work Calendar (Menu)

Of course, you can automate this too, this formats the date of the event as one letter (so Monday becomes M, Friday becomes F), and if it’s not Saturday or Sunday, checks if the event starts after 8 am but before 6pm – if yes it adds an event to your calendar. It’s not insanely complicated, but it’s not as simple as the Workflow above.
You can get the workflow here: Add Event To Work Calendar (Auto)

David’s Hyper Scheduling Workflow

Since February David has had an ongoing Hyper-Scheduling Experiment, which involves scheduling blocks of time in his calendar to provide a framework throughout his day. You can see his Workflow to generate some of the core blocks here.

You can get the workflow here: Block Schedule

Add Travel Time

Here David walks you through how his Workflow to add travel time events to your calendar works.

You can get the workflow here: Travel Time

Repeating Events

Of course, one of the simplest ways to automate calendar event creation is repeats – and you can go from very simple up to fairly complex within that. The simplest repeats are every day/week/month/year, but if you go into the Custom... options then you can create repeats such as “On the first weekday of every month”.


Copy and paste

If repeating events count as automation (they do!) then copying and pasting events does as well.

  • CMD+D allows you to duplicate an event, and then you can drag and drop it.
  • CMD+C and then CMD+V lets you paste, if you select a new date before you paste then the event is automatically added to that day. In many apps you can even paste it in at the time you have selected.
  • Fantastical on iOS gives you the option to duplicate an event when you tap and hold on it, or when you swipe, and tap “More…”, BusyCal allows you to duplicate an event by force touching it. I personally prefer Fantastical as it immediately asks me for the new date where as with BusyCal you need to edit the new event.

Workflow: Copy a Calendar Event

This Workflow lets you choose from calendar events, and uses the chosen item to create a new event. It is currently set to use events from today, but you can easily change the filter in the “Find Calendar Events” action to look in the last week, the next week, or any time period of your choice.

You can get the workflow here: Copy Calendar Event

Parsing a list of events with Numbers

I first mentioned this automation in episode 418 of the Mac Power Users, this is designed to help you take a list of events and quickly add them to the right calendars. As David mentioned on the podcast you could also use it to calculate dates backwards from a specific event (he used a trial as an example) to add other events or deadlines to your calendar.

You can download the spreadsheet here.

The Keyboard Maestro Macro is very simple, it splits the text on your clipboard into lines, and then runs the following AppleScript on each line.

tell application "Keyboard Maestro Engine" to set myEvent to getvariable "Event"

tell application "Fantastical 2"
    parse sentence myEvent with add immediately
end tell

This AppleScript merely sets a local variable to the Keyboard Maestro variable for the line, and then uses Fantastical’s AppleScript support to get it to parse the event and add it straight to your calendar. If you wanted to evaluate each event before it gets added then you would remove the with add immediately.

You can download this Keyboard Maestro Macro here

You can also make this system iOS friendly in two ways, the Numbers sheet itself of course works on iOS. But you can do two things with the list of events it generates, the first is to use a Workflow, Clipboard Events To Fantastical which goes through all the lines on your clipboard adding them to Fantastical for you. The second way is to use Drafts, with the Events in Fantastical action provided by Agile Tortoise.

As mentioned in the show, David has a great series of video tutorials for Fantastical where he guides you through the core features and some of the syntax options.

Adding event with AppleScript

As we mentioned in the show, AppleScript is not the most flexible when it comes to adding events to your calendar. However it is definitely possible! I highly recommend the official Apple documentation as a starting point for a script that works, There’s also a library called CalendarLib which is linked on the very helpful macosautomation.com.

Of course, you can also use AppleScript to control Fantastical – as demonstrated in my Keyboard Maestro Macro above, here’s their documentation for integration with other apps.

Cloud Based Automation

Using web services like IFTTT or Zapier to automate things based on calendar events can be limited if you’re not using the “right” calendar system – so you can have IFTTT trigger things based on an event starting in Google calendar, but not in iCloud calendar. You can however use a variety of triggers from time and date, to RSS feed entries, to add events to your calendar on almost any system – as long as if it’s iCloud you have the IFTTT app installed.

Favourite Workflows

In this last part of the show we talked about our two favourite automations related to calendars.

David – Meeting Confirmation

This workflow is really useful if you have meetings that you need to remind other people of, David actually has two – one for in person meetings, and one for scheduled calls. You can get them here:

Rose – Workflow: Event Review

I use this Workflow to help me review the events that have happened in the last week, as well as to prepare tasks for appointments in the upcoming week. This adds the calendar events from last week to a Drafts note, and combines any tasks you note down for the next week into Taskpaper and adds them to Omnifocus.

You can get the workflow here: Event Review


Shortcuts Beta now open!

Earlier today a few little birdies told me about the Shortcuts beta being open to sign up for if you have a developer account. If I hadn’t already had one I might have been tempted to sign up for it just for this!

It seems Apple is sending out the invitations pretty quickly as mine has already arrived. I’m really looking forward to testing this and getting stuck in – iOS 12 has made some big promises regarding automation, I bet it will live up to them!

You can read more about the current beta over on MacStories.


AIRPRESS LOADED