Drafts 3.0.6 and Batch Import Action Groups

A few days ago, Drafts 3.0.6 hit the App Store. It's a fantastic update, and it introduces some incredibly powerful new features. Mainly, Drafts now supports [[line|n]] variables, where "n" is replaced by the actual line number you wish to reference. This means that we are finally no longer limited to a paltry 3 variable maximum in each action.

A quick recap before I launch into a new idea which I'm hoping could be of great interest to many of you. In Drafts 2.5, when custom URL actions first became available, the only variables that could be used in actions which would draw directly from your draft were [[draft]], [[title]] and [[body]]. When [[draft]] was used in an action, it was replaced by the entire contents of your draft. [[title]] was replaced with the first line of your draft, and [[body]] was replaced with every line after the first. This was great for simple tasks, but advanced methods such as batch importing actions from a list in a draft was impossible.

With Drafts 3.0, the [[clipboard]] variable was introduced. This allowed a max of three completely different variables to be called in one action (the [[draft]] variable draws a combination of the [[title]] and [[body]] variables, so I don't count it as an extra variable to be used, since it can carry no more information than the other two). I was able to get a batch import action working with that version of Drafts by using what was basically a hack to "chop" the first line out of the draft and into the clipboard so it was isolated and could be imported as an action. However, the biggest downfall to this strategy was that it required the entire contents of the list of actions to be URL encoded. This not only made it extremely difficult to read and edit each action before importing, but also made creating and sharing lists of actions extremely difficult and time consuming, as each line had to be properly encoded while leaving an unencoded space in between so Drafts could differentiate them. Overall, I was glad the process was at least possible, but disappointed that it was so complex that no average Drafts user would be able to make use of it.

Now, however, with the introduction of [[line|n]] variables in Drafts 3.0.6, the process is finally possible in the form I've always hoped it to be in. With my new Batch Import (and the subsequent batchImport2 and batchImport3) actions, it's possible to open a list of actions in Drafts in the format of two-line groups, the first line of each being the unencoded action name and the second line being the unencoded action itself. Between each two line grouping is a fully blank line, to make reading the list easier and less cluttered. With the properly formatted list, run the Batch Import action and watch as each action in the list is quickly and effortlessly imported into your actions list.

A few reasons why this is an awesome achievement: actions such as the built in Twitter actions have completely different titles for every user, because each action title is in the form of "Tweet: USERNAME". In order to call one of these actions in a custom URL action, I personally type "Tweet: the_axx". However, if, for example, Greg Pierce (the developer behind Drafts and a few other great apps) were to run the same action, he would have to change the code for the action to say "Tweet: agiletortoise" in order for Drafts to run the correct action. This makes sharing even simple actions like my Cross Post action annoyingly complex, because once imported, users have to go into the settings for the action and change the code to match their Twitter username. This is an even bigger problem for batch importing actions, because users don't necessarily remember which actions require changes and which don't. Sorting through to try to identify that is a horrible process. However, if you can look at all of the actions laid out in a list before they are imported, it is far easier to find the places where changes need to be made, then you can import them correctly and never have to mess around in the settings panels.

Another reason I'm excited for this is that it can make sharing large amounts of actions between Drafts fans much, much easier. Before the Batch Import action was possible in such a simple and intuitive form, sharing actions has been a bit of a nightmare. For people getting into Drafts for the first time, who haven't been importing each new action that myself and many others have been coming up with as they are released, it would take a crazily long amount of time to go through each webpage and individually import each action. Now they can simply import the actions necessary to Batch Import, and then be able to open long lists of actions that people build and import them all at once.

This is the initiative I'm hoping I may be able to start among those of us who are skilled in creating URL actions. I'm calling them Action Groups, and they're quite simply a list of actions that are in some way related which interested users can import all at once. My first, The Essentials Action Group, is a small list of 6 essential actions which I think every Drafts user should have access to. These are some of the actions which I use on a daily basis, and are essential to my own personal workflow as well. For new users, they will be able to open this list in Drafts with one tap on a link, and then batch import them all at once. Not only is this simple and easy, and allows even those who are new to URL actions to get quick access to a variety of useful new functions, but the fact that each action is laid out clearly and in an unencoded form in front of them could even help them learn how to make actions of their own far faster than scrubbing through the tiny action URL viewer with the iOS magnifying glass in Drafts' settings.

I encourage anyone who is interested to feel free to borrow my Batch Import actions and post them on their own site with any lists of their own essential actions or other groupings. I'd love to see this take off as a way to finally be able to easily share our action lists with all Drafts users.

So without any further blathering, lets get to the actions themselves. Direct import links for the Batch Import actions:

Batch Import




For anyone interested in testing them out, or who wants some of the actions listed, here are a few action groups I've created. Just don't forget that you must have the above four actions installed for the import process to work, although you only need to run the actual Batch Import action to start the process. Click on the links below on an iOS device with Drafts installed to be launched into a properly formatted draft ready to be Batch Imported.

The Essentials Action Group

Includes Cross Post, Triple Cross Post, Cross Post Later, Add to Fantastical, and a customizable one called Chopper which allows you to perform a specified action on each line in a list of items. (Same concept as the batch import, but compressed into a single action because it only runs on one line at a time.)

Necessary changes:

  • Change "YOUR USERNAME HERE" in the Cross Post action to whatever your Twitter username is before importing.

  • Change "YOUR ACTION HERE" in the Chopper action to whichever action you want to use for it. (It will perform the action on each item in a list one by one, so choose one you may find useful for the purpose.)

  • If you wish to change the name of Chopper, make sure you change it not only in the title line, but also in the final word of the action itself (also the final word of the whole draft, so it should be easy to find), otherwise it will fail to call itself and repeat on each subsequent list item.

The Freedom Action Group

Includes four different actions which all allow for customizable action combinations on the go. Since you can't always tell beforehand which combinations of actions you are going to want in order to meet the needs of every situation, you can now type the title of one action into line 2 after your text, and the title of a second action into line 3. Running Choose Actions will take the text from line 1 and run the action from line 2 on it, then call back and run the action from line three on it. Just make sure that at least the action from line 2 supports the x-success parameter, otherwise Drafts won't know how to call back and run the second action.

If your actions require 2 lines of text to function, you can use one of the last three actions, based on your needs. Running Choose Actions (2line) will run actions typed into lines 3 and 4 on text typed into lines 1 and 2. Running Choose Actions (1/2lines) will run the action in line 3 on the text in line 1, then the action in line 2 on the text in lines 1 and 2. Finally, running Choose Actions (2/1line) will run the action in line 3 on the text in lines 1 and 2, and the action in line 4 on the text in only line 2.

Choose Actions made its debut a couple weeks ago, so for more information you can check out its original post here.

The Time-Delay Action Group

Includes a variety of actions to time-delay sending out text through various mediums until a date or time better suited for the sending. These actions all require the use of Due, and you can find them in far greater detail at their original page.