TextExpander Snippets within Drafts Action Templates

I can’t seem to find the “Expand in Action Templates” referenced in the linked article. Can somebody point the setting out to me? I want to be able to use a TextExpander snippet within a Drafts template.

Tap on the cog, bottom right, to access settings. Select TextExpander in the list of sets of settings available. It is in the Extensions group.

You should then see a screen like this:


I found this page and enabled those toggles but the snippet is still not expanding, I’ve tried it on my Mac and iOS device.

This is how it looks on my Mac.

Works just fine for me on iOS (I just tested it), but as per the docs for its use I would not expect it to work on a Mac. That isn’t supported.

On iOS, refresh your TextExpander snippets, reboot the device and see if that helps.

I tried to simply put the AppleScript as one of the action steps in the template, I don’t think I set that part up correctly because something is broken.

I use Drafts on my Mac more frequently then I do on my iOS device.

Can you explain what you mean by that? I do not know what template you are referring to, how you are relating AppleScript to TextExpander snippet expansion, or what from that appears to be broken.

As mentioned in the TextExpander article you linked to, the action expansion features are only available on iOS.

If you are trying to fill in text when creating a draft from a template on Mac, you would need to use built-in Drafts scripting/template tag features…or, alternately, just generate your whole template from a TextExpander snippet.

Ok, I have a task list action:

Step 1 insert text

M2W Task List (Week of)

<<;strtme>> <<== This TextExpander snippet didn’t work. Therefore I thought I’d:

Step 2: AppleScript

set theCurrentDate to (current date)
set theWeekday to weekday of (current date)

if theWeekday = Monday then
	set startingDate to theCurrentDate
else if theWeekday = Tuesday then
	set startingDate to theCurrentDate - 1 * days
else if theWeekday = Wednesday then
	set startingDate to theCurrentDate - 2 * days
else if theWeekday = Thursday then
	set startingDate to theCurrentDate - 3 * days
else if theWeekday = Friday then
	set startingDate to theCurrentDate - 4 * days
	error number -128
end if

set dateList to {date string of startingDate}
repeat with i from 1 to 4
	set theDate to startingDate + i * days
	set end of dateList to date string of theDate
end repeat

dateList --> {"Monday, September 6, 2021", "Tuesday, September 7, 2021", "Wednesday, September 8, 2021", "Thursday, September 9, 2021", "Friday, September 10, 2021"}

set {TID, text item delimiters} to {text item delimiters, linefeed}
set dateList to dateList as text
set text item delimiters to TID

dateList -- a string of paragraphs of the dates

The result of the AppleScript should be something like this…

Monday, August 30, 2021
Tuesday, August 31, 2021
Wednesday, September 01, 2021
Thursday, September 02, 2021
Friday, September 03, 2021

But as you can tell by my struggles no method has worked for me.

1 Like

Drafts has its own template tags, with support for date formatting.

Start with the Using Drafts Templates article, especially the date section with information on strftime formatting.

All you need to get the date formatting you need in an Drafts template is:

[[date|%A, %B %e, %Y]]

Yes, but that’s only for the current date. Drafts has no easy syntax to calculate future dates that I know of. In my workflow, I need something that would look like this…

Monday, August 30, 2021
Tuesday, August 31, 2021
Wednesday, September 01, 2021
Thursday, September 02, 2021
Friday, September 03, 2021

That’s why I tried a TextExpander snippet then I tried simply placing the AppleScript (to accomplish the above) date strings.


@bocciaman, from your description (always better to share the actual action by the way as the picture is incomplete without it) it sounds like you are inserting your template and then just running some AppleScript after it expecting it to operate on and update the inserted text. I am not sure if that was your intention, but that is not how it is designed to work and would explain why it did not work for you.

Instead I think you would want to run the AppleScript, take the output of the AppleScript, and insert it into the editor at the current cursor position.

Here’s a version that does that.


I have modified this particular version to work backwards by 5 and 6 days for Saturday and Sunday respectively to allow for testing this over the weekend. Simply remove those four lines (condition and action x 2) to restore the original script structure.


It is pretty easy to do some date calculations in JavaScript in Drafts. Greg posted a straight forward example earlier this year in response to a question about it.


I have an idea for TextExpander that could workaround something that came up earlier, but there’s an issue with it when I came to put it together. I’ve had to contact and open a support ticket with Smile as I think they have broken/removed something that used to work and would be helpful for a more generic solution.

@sylumer I couldn’t get the Bocciaman AS List to execute, I even tried putting the original script in the AppleScript section and ran it with the additional script. It didn’t work in either case.

I did re-download the action from the directory link above, and when I run it, it does what I expected it to; inserting a set of dates as follows:

Therefore, I am going to need more to go on than couldn’t get it to execute I am afraid. You have not described in enough detail what does/does not happen to allow any investigation beyond me running the action to check it does indeed still work.

Things it would be worth confirming:

  1. You get the completion notification as shown above when the action is executed. Specifically a successful completion notification, an error notification, or no notification.
  2. You are running this on a Mac.
  3. The version of Drafts and MacOS you are running - I know you have had issues by running an out of date version of Drafts in the past.
  4. What appears in the action log when you run the action?
  5. That you are triggering the action directly from the action list (vs Action Bar, URL scheme, widget, Shortcuts, etc.)

But any insights you can provide could help with this.

As noted above I just added some additional lines to the script to allow for weekend testing. If you compared the core script they should have been the same, and as you can hopefully see from the script , and my result, this would not have affected the running of the action.

An update on my TextExpander idea. Smile have indeed removed a set of functionality. Presumably intentionally if they have been regression testing their releases, but it seems that no one had noticed, not even them judging by their documentation not reflecting that. They have a request from me to restore the functionality, but they have not committed to any time frame to do so. If they do, I believe I can post an interesting alternative.

Do I need to provide permission to the folder ~/Library/Application Scripts/?

I’m not sure how to fix the permission issue.

You should have been prompted for that permission the first time you ran some AppleScript from Drafts; I think, but it has been a long time for me.

You may be able to set it manually via the usual file/folder app permissions settings.

I’m still not clear on how to fix this issue. Here’s my system info:

Model Name: iMac
Model Identifier: iMac10,1
Processor Name: Intel Core 2 Duo
Processor Speed: 3.06 GHz
Number of Processors: 1
Total Number of Cores: 2
Memory: 16 GB
Boot ROM Version:
SMC Version (system): 1.52f9
Chipset Model: NVIDIA GeForce 9400
VRAM (Dynamic, Max): 256 MB
Adapter Firmware Version: 1.40
System Version: macOS 10.13.6 (17G13035) (High Sierra)
Kernel Version: Darwin 17.7.0
System Integrity Protection: Enabled
Time since boot: 1 day 17:10

Drafts Version 26.2.4

Also, I did give it permission to this folder. Do I need to put the actual .applescript file in there?

Delete and recreate the folder at ~/Library/Application Scripts/com.agiletortoise.Drafts-OSX, quit and relaunch Drafts, and try again. You should be prompted to allow permissions to that folder.

You do not need to directly put anything in that folder, it’s managed by the app, but the permissions process is required to workaround Sandboxing.

Do I manually recreate it or is it done automatically once restart Drafts?

I recreated the com.agiletortoise.Drafts-OSX folder, I still wasn’t asked for any permission and I still get this message when I try to run the action: