Can I trigger an action by draft content?

Can I trigger a particular action automatically if the draft contains a specific string?

No. You have generally have to manually trigger actions.

If you are on macos, you can use snippets in some third party apps to trigger an action, which could include running a Drafts action. Keyboard Maestro for a x ample could do this.

You could also have something run periodically, to find drafts that match some text and run an action on them. On i*OS, you could do this with a Shortcut automation, but your device I think would need to be unlocked to complete.

Hope that helps.

Thanks. From my perspective, it would be very helpful if actions could be triggered automatically on certain strings in Drafts, for example to format or transform strings. @agiletortoise

If your only requirements are formatting and transformation of the trigger text, and they are to consistently trigger the same result each time, make sure you take a look at text expansion utilities (or equivalent Drafts actions - you can fine a few via this foulrum,I believe), and Autocomplete Suggestions.

I have a variety of texts that end up in Drafts (highlights from books) and need attached text (always containing a certain substring) and quotes removed, before being processed from Drafts into Anki.

Sounds like the transformations could occur when you process them into Anki then. The alternative would be to use a mechanism on the import step that does your transformation.

These are triggers you can use now. The trigger you hope for may appear one day, but it may not; so it may be better to take a step back and see if you could utilise a slightly different process for the same result.

Keep in mind that your suggestion would need to work cross-device (avoiding contention of multiple devices attempting to process the content of a draft simultaneously or even asynchronously), and at an arbitrary time through external creation or internal, manual entry of the text (which like text replacement string triggers would presumably trigger at the point a matching piece of text has been entered).

Sorry for butting in.
Reading your comments made me think, would an action that processes multiple drafts at once, be a solution?

For example :
Action searches all drafts with a particular string
→ action removes the string + other changes you need to make on the draft
→ moves draft content to another app
→ repeat the process for all other drafts found in step 1

It isn’t the automatic trigger you had hoped for, but it still might be a useful enough option if I am understanding your needs correctly.