Editor autocomplete suggestion to call a Drafts Script action?

Is it possible to have an autocomplete suggestion call a custom Drafts Script Action I have written? So I type in the autocomplete syntax, it runs the assigned Drafts Action (which is a Script), and the results of the Script replace the autocomplete syntax.

I poked around the autocomplete and template tag documentation thinking I might be able to fuse the two but couldn’t quite wrap my head around whether it was possible.

The autocomplete functionality does not offer that. It is for text snippets only.

You could use a keyboard shortcut to trigger the action, or add an entry so it is one tap on the action bar. The action itself can insert a result at the current cursor position.

If you are unsure how to do any of this, let us know what aspect you need to know about (adding shortcuts, template tags, scripting to insert text, insert text action step, etc.)

Not a problem, I already have both an action bar button and a keyboard command for this script. Was just curious if autocomplete suggestions could also be used to trigger a script as well.

Could TextExpander be jury-rigged to do this? It’s an intriguing thought.

There are several apps that allow scripted actions to occur when entering a trigger snippet of text (including TextExpander). You could trigger a specific action with them using the URL scheme.

The niggle is that other than via the clipboard, I don’t recall seeing a way for actions to return results to calling apps. So again, I would be looking at the action to do the actual insertion.

I would further query if there’s an advantage of the snippet over triggering a search, or defining the snippet as a slash command?

1 Like

Ahh, I wasn’t aware of Slash Command - this looks it might handle my use case. Thanks for the pointer.

It isn’t a standard Drafts feature, so I wouldn’t expect most Drafts users to have come across it. It is something I created before we had the quick search feature to allow me to do abbreviated commands that were then read in and operated on by an action triggered by a keyboard shortcut or action bar tap. Kind of a purely keyboard driven equivalent of a pop up menu for me. But these days, I find that Quick Search is pretty convenient.

1 Like

As a mainframe guy I can relate to slash commands. :slight_smile:

The only thing Drafts doesn’t seem to support as an input medium is punched cards… :slight_smile: