How to Chain Any Combination of Built-in Drafts Actions without Writing New Custom Actions

Drafts 3.5 is a great update to an already amazing app. My favorite feature is, of course, the new ".." range feature in [[line|n]] tag. For example, with [[line|4..]] tag, I can easily select all entries from the fourth line to the end of the draft and use it as the email body in my Mail Later action.

Open this link if you want it installed on your iOS device automatically.

Phillip Gruneich has recently shown that you can use the [[line|..2]] tag to send more information recursively to another app. With Drafts 3.5 update, we're no longer limited to selecting a single line for recursive actions.

Today, I want to highlight how I've been using the new range feature to chain any combination of built-in Drafts actions easily without having to write a new URL action for each combination.

Using a single action, I can define at runtime how I want the first three lines of my draft to be crossposted to any number of services.

The Motivation

By now, you probably know me as someone who loves to create his own custom URL actions that chains two or more apps using the x-callback-url specification. Even though I enjoy creating them, oftentimes I find it too limiting because the order and the number of actions that I want to chain are pretty much static and limited to the ones I describe in the action. I've always wanted to have a way to easily define what I want to chain at runtime, instead of at coding time.

For example, I may write a 140-character draft that I want to crosspost to multiple Twitter accounts, my account, my Facebook account, log it to a Dropbox file or an Evernote note, and send it as both an iMessage and an email to multiple recipients in my circle of friends. Even though I can create a very long chain of actions to do all of the above, it won't help much if I want to do a simple crosspost to Twitter and only. Other times, I may want to share it on Facebook and email only. It would be great if I could write an action that can handle this:

[Something worthy of a tweet]
Tweet: epramono
Tweet: geekwithjunior
Post to
Post to Facebook
Post to Google+ (public)

or this:

[A short journal entry]
Dropbox Action: My son's logbook
Post to Facebook

or this:

[A must-read link for my circle of friends]
Post to Google+ (circle)
Email Action: Friends
Message Action: Friends

I dream of one action to rule them all: an action that allows me to chain an arbitrary number of built-in Drafts actions, defined at runtime, on the same set of lines.

The Solution

Using the new range feature for [[line|n]] tag in Drafts 3.5, I created a custom action named "Share...". I reserve the first three lines ([[line|..3]]) as the contents that I want to crosspost, and use the remaining lines as the list of built-in Drafts actions that I want to trigger.

I will invoke the action on [[line|4]] first, and create a new draft by retaining the first three lines and the other actions which have not been invoked. This action will be called recursively until there are no more actions left.

Open this link if you want it installed on your iOS device automatically.

You can modify the action to fit your needs. For example, you might want to reserve one line, two lines, or even four or more lines. As long as you understand how the action works, it's quite simple to modify it.

Once you're ready to use this action, I'd suggest you create your own TextExpander snippets containing several chains of actions that you're likely to perform. It will save you time and avoid any typing mistake as you write the action names.

The Exceptions

This approach works with built-in Drafts actions, i.e. the ones that are made available when you install the app. It also works with built-in actions that may require a popup, such as Email or Message. If you have created custom Email actions, Message actions, Dropbox actions, or Evernote actions, it works with them too. It even works with custom URL actions that do not have an x-success parameter attached to it.

This approach does not work with actions that send you to another app, regardless whether it supports x-callback-url or not, nor whether it's being encapsulated in a custom URL action in Drafts or not. This is because we're trying to invoke actions that are defined at runtime, whereas x-callback-url forces us to know which action to invoke at coding time.


This approach is great for both novice and power users. Novice users can now achieve some of the powerful features in x-callback-url and recursive actions in Drafts without having to write a single line of code. Both novice and power users can also enjoy the flexibility offered by this approach, where you can define the list and the order of the actions at runtime.

Thank you again, Greg, for the awesome update to Drafts!

You should follow me on Twitter here.