Chain Chain Chain
Recent months have seen some significant updates to 3 of my most-used apps - Drafts, Launch Center Pro and IFTTT. The updates have made them more powerful, and less dependent on hacky steps to chain them together, but the available documentation on the web is a bit confusing. As it took me a while to get my head around, I thought it was worth summarising here.
For the uninitiated, Drafts is an app for quickly capturing text, then doing something with it, usually by invoking another app. Launch Center Pro is speed-dial for apps, allowing you to set up actions that you can launch with a single tap. IFTTT (If This Then That) is a web service that chains together web services, allowing an action in one to trigger a related action in another; the app enables further integration with iOS.
Drafts and LCP use a standard called x-callback-url to communicate with other apps, and there’s much overlap between what they can accomplish, but this same standard can also be used to chain them together to create really powerful workflows. Add to this the recently added Launch Center Pro channel on IFTTT, and there’s a world of possibilities, if you can figure out how to make them work.
Let’s take a simple example. I use a Google Spreadsheet to keep track of my expenses, and I want a simple way to insert the date, the amount, and a brief description in that spreadsheet, without having to faff with a spreadsheet app on my phone. I’d ideally like to use Drafts for this, because that’s where I capture everything else.
IFTTT has a Google Drive channel, with an ‘append to spreadsheet’ action, but there’s no way to trigger this from Drafts. However, I can trigger it from Launch Center Pro. I create an IFTTT recipe, and set it to be triggered by LCP. It asks me to define a name for the trigger - I’ll use “LogExpenses”.
I then choose the Google Drive ‘Append to spreadsheet’ action, pick the name and location of the spreadsheet I want to update, and define how I update it. Here I am passing the date triggered, and two values from Launch Center Pro which will be my value and description (you can pass up to 10). The three pipes delimit the spreadsheet cells.
Now, this is the clever bit. Thanks to the x-callback-url implementation in Drafts and LCP, we can trigger this IFTTT recipe directly from Drafts, without messing with LCP at all.
I create a new Log Expenses Drafts Action, with a ‘URL’ action step, and type the following URL:
launch://x-callback-url/ifttt/trigger?name=LogExpenses&value1=[line|1]&value2=[line|2]&x-success=drafts4%3A
Breaking this down:
launch:// - The URL for Launch Center Pro
x-callback-url/ - Tells LCP that we’re using this standard, so to expect an x-something parameter later
ifttt/ - Tells LCP we’re using IFTTT
trigger?name=LogExpenses - Tells LCP to use the Trigger “LogExpenses” that we defined in IFTTT
&value1=[line|1] - Use the first line in Drafts as Value 1 in the IFTTT trigger
&value2=[line|2] - Use the second line in Drafts as Value 2 in the IFTTT trigger
&x-success=drafts4%3A - use the x-call-back-url standard to return control to Drafts (the %3A is a colon - for some reason this has to be URL encoded)
Now, when I want to log an expense, I open Drafts and type something like:
Train ticket
62
I then invoke the Log Expenses action, which momentarily activates LCP, then drops me back into Drafts. A few moments later, I get a notification from IFTTT that my spreadsheet has been updated.
The fact that the trigger doesn’t need to be created in the LCP app doesn’t appear to be documented anywhere, and it allows for an impressive amount of flexibility and reusability. For example, one could set up a single generic IFTTT recipe, which updates different spreadsheets depending on what is passed in the Drafts action.