Can drafts receive info from a shortcut and then pass info back to that shortcut?

I have a shortcut that asks me to update some text. I’d like the shortcut to pass the text to drafts where I can edit it, and then have drafts push the finished text back to the currently running shortcut. Is this possible?

Thank you.

Not possible with one shortcut. You would have to pass the text to Drafts, and then run another action that ran a different shortcut to receive and process the final product.

I feel really silly going “Well, actually” to the actual creator of Drafts, and apologies if there’s some factor I’m overlooking, but two solutions occurred to me. These don’t have the shortcut pass the text to Drafts and then Drafts pass the text back to the shortcut, but we can get close, and it still only involves one shortcut.

Solution 1

  1. Shortcut checks if there’s already a draft in Drafts with label draftsShortcut (or what have you). If there is, the shortcut shows an alert and quits.
  2. Otherwise, the shortcut creates a draft in Drafts with label draftsShortcut and opens that draft.
  3. Shortcut runs Wait to Return, so Shortcuts is in “holding mode” until the user returns to Shortcuts.
  4. The user updates the draft.
  5. The user leaves Drafts and goes to Shortcuts, so Shortcuts takes over again.
  6. Shortcuts polls Drafts for the draft with label draftsShortcut (which didn’t exist at the beginning, but does now) and proceeds to work with its text from there.
  7. The user either then deletes the draftsShortcut draft at some point prior to running the shortcut again, or maybe the shortcut can run a Drafts Action that deletes that draft if it isn’t needed.

This doesn’t have Drafts passing the text back to Shortcuts, but the user action would be almost the same (user starts in Shortcuts, user goes to Drafts, user goes back to Shortcuts).

Solution 2

  • Similar to the above, but the shortcut would run with an If statement.
  • If there’s no draft in Drafts with label draftsShortcut, then the shortcut runs step 2 above and stops.
  • If there is one draft in Drafts with label draftsShortcut, the shortcut would run step 6.
  • If there’s more than one draft in Drafts with label draftsShortcut, the shortcut quits or takes some other action.

So, still one shortcut, but run twice, before the user updates the text and after, and it’s contingent on whether the draft with label draftsShortcut exists or not.

I grant that the spirit of the original post was to use one continually running shortcut, but this may be just as good, and easy to run twice with a keyboard shortcut or icon on the Dock, etc. I’ve also done Drafts Actions that work this same way — run it once to start, and then run it again at the end and it does different actions based on whether a specific-labeled draft exists or not.

Hope that helps!

2 Likes

Just to note the first one solution can time out. It all depends on how much editing time is offered - but Shortcuts does not wait indefinitely, not is it always the exact same amount of time in all circumstances (it monitors resources and demands); Apple’s black box approach can be frustrating at times on these sorts of constraints.

Any reliable solution is going to have to be two-part, which I think is the crux of what Greg is getting at rather than it being entirely impossible to write both parts into a single shortcut. After all, you can even write recursive shortcuts which do different things at entry based on what is passed in.

The issue is the hand off and round tripping. To my mind I would have the Shortcut run and if it hands off to Drafts, it does so and ends. When handing off I would have it load an action group or bar in Drafts as well as prepping the draft to be edited. The idea being that one of the offered actions would trigger a shortcut to complete the processing. That could be the same shortcut as before (with different entry data passed to it), or a separate one, but that triggered shortcut then completes the run. More complicated in it’s setup, but a smoother experience as the user’s completion is the single trigger to continue.

2 Likes

I think a third solution would be to trigger a Drafts action from the shortcut at the end again that will apply the edit to the draft you’re currently editing (however you identify this).

This will prevent the timeout I think and would also work in the background if necessary

Thank you all for the input ideas and suggestions. I suspected this wasn’t possible (in the way I wanted to use it), but am glad for the confirmation.