Running Actions Using Shortcuts

I am trying to run actions in Shortcuts that do not depend on an existing draft or that operate against a newly created draft - and in neither case do I have the information needed to identify the draft. More specifically:

a. How do you run an action in Shortcuts that creates a draft from a template? In this case, I’d want the equivalent of saying Run “X” using “None,” where “None” would be used in lieu of a specific draft identifier.

b. If you use Shortcuts to create a draft (e.g., Create Draft with Dictation) and then want to run an action on that draft, how do you identify the newly created draft? In this case, I’m looking for the equivalent of Run “X” on the “Currently Open Draft.”

Is either of these possible?

Let’s start by clarifying something about Shortcuts. There are two kinds of shortcuts actions:

  1. Ones that run directly in Shortcuts.
  2. Ones that require the app using them to open.

Most of the actions provided by Drafts fall into the first category, and the ones that manipulate drafts typically return a “Draft” object in Shortcuts that contains all the information about the draft and can be used as input for further actions. For example the “Create Draft” action can take a variety of inputs (the text, tags to assign, etc.) and create a draft without launching Drafts - and after that action is run in Shortcuts, the next step in the shortcut can access the “Draft” returned by that action - to, say run an “Open Draft” action that launches Drafts to that new draft.

That is likely how you would configure a shortcut to create a draft from a template. Just have a “Create Draft” step, with the template configured as the content of the draft, followed by an “Open Draft” action that used the “Draft” returned from the previous action.

The shortcut actions that fall into category #2 above, that launch the app, do not return values to Shortcuts. This is a technical limitation in what can be done with Shortcuts actions in third party apps, because Shortcuts does not wait for a response, it just launches the app and moves on. Actions provided by Drafts that fall in this category include ones that require user-interface interaction, like “Create Draft with Dictation”, “Open Draft” and “Run Action”.

These cannot be chained together to further act on the anything created because of this limitation. Unfortunately, Shortcuts does not really identify these actions in it’s UI, making it hard to keep track of what will and will not launch Drafts.

There are some ways around this using URL schemes instead of Shortcuts actions, for example.

1 Like

Thanks. That explanation helps a lot.