Tutorial: Designing a Chain of Actions in Drafts Involving Apps that Support x-callback-url

By now, you're probably already aware that you can create a long chain of custom URL actions in Drafts that involve other apps that support x-callback-url. Theoretically, you can create these chains for as long as they fit the purpose. Nevertheless, when you start to involve three or more actions, you might be wondering which action to begin with.

Here's a sample workflow that some of us may be doing quite frequently: sharing an article that we find interesting to as many outlets as possible.

  • We may tweet about it, and
  • We may post it on App.net, and
  • We may save it to Instapaper because it's at least three pages long, and
  • We may want to return to Chrome to continue reading, or use Chrome to return to Tweetbot or Riposte.

We know it's possible to do all of the above, especially since all of the apps involved here support x-callback-url. Yet, when you start coding your actions, you might be wondering where to start. Based on my experience in writing many long chains of actions in Drafts, here are some guidelines that you can use when designing your chain.

1. There can be only one action that does not support x-callback-url

And, it should be put as the final action. For example, while Clear and Momento are great apps that support URL schemes, they do not have full support for the x-callback-url specification. Thus, creating a single chain of action that involves both Clear and Momento is not possible at the moment.

2. Identify your finish line

Regardless what happens during the chain of actions, you need to plan ahead of where you want to be after doing all of the actions. In the above example, I wanted to go back to Chrome.

Once you have identified your finish line, put it as the last one to invoke.

This diagram shows the order of actions in the chain.

3. Arrange the order of actions based on the likelihood of cancellation

Based on my previous tutorial on how to design a chain of actions that utilises x-cancel parameter to properly route the cancel actions, you may need to arrange the order of actions such that the least-likely-to-be-cancelled actions are prioritised over the most-likely-to-be-cancelled ones.

In my example above, I'm least likely to cancel tweeting and posting on App.net about the article, and I'm more likely to cancel saving it to Instapaper. Thus, the appropriate order should be: Tweetbot, Riposte, Instapaper and Chrome.

4. Create a custom URL action in Drafts involving the last two actions

Drafts is the key here. Without Drafts, none of this could happen. The idea here is to store the last two actions as a URL action that can be invoked later by another action that should precede it. It's similar to encapsulating the last two actions into a method to be invoked later.

For my example, I would bundle the Instapaper and Chrome action into a single Drafts action. The only thing I need is the URL that I will save to Instapaper.

Here's the snippet for the action I'm naming as Instapaper and Chrome:


Open this link if you want it installed on your iOS device automatically. Note that my x-cancel policy here is to continue to Chrome even when I cancel the Instapaper action.

5. Take the preceding action and combine it with the last action bundle

In my example above, I would create a new bundle of actions involving Riposte as the first action and the Instapaper and Chrome action as the x-success parameter. This time I'm going to need a text and a URL.

Here's the snippet for the action I'm naming as Riposte, Instapaper and Chrome:


Open this link if you want it installed on your iOS device automatically. Note that my x-cancel policy here is to continue to the Instapaper and Chrome action when I cancel the Post to App.net action.

Note: If you're wondering why I use an App.net client that supports x-callback-url instead of the built-in Post to App.net in Drafts, it's because I want to utilise the URL shortener service offered by a full-fledged App.net client.

6. Repeat last step until there are no more action left

In my example above, I would create another bundle of actions involving Tweetbot as the first action and the Riposte, Instapaper and Chrome action as the x-success parameter. Here's the snippet for the action I'm naming as Tweetbot, Riposte, Instapaper and Chrome:


Open this link if you want it installed on your iOS device automatically. Note that I'm using the same x-cancel policy here. I want to continue to the next steps even though I cancel the Tweet action.

Note: Tweetbot doesn't fully support x-callback-url specification, but it uses its own URL scheme specification that combines both x-success and x-cancel parameters into a single callback_url parameter. Thus, regardless whether we tap on the Tweet or Close button, Tweetbot will redirect us to the next app in its callback_url parameter.

The last iteration is to bundle the Drafts post into a Chrome bookmarklet:

javascript:window.location='drafts://x-callback-url/create?text='+encodeURIComponent(document.title+'%5Cn')+ encodeURIComponent(location.href)+'&action=Tweetbot%2C%20Riposte%2C%20Instapaper%20and%20Chrome'


Designing a new chain of actions can sometimes be overwhelming to do. Hopefully, these guidelines can help you to consistently be able to create any long chain of actions you want without wondering where to start or whether a certain combination of apps are possible or not.

To find my other workflows, please visit my Productivity and Workflows blog.