Passing Siri Shortcut to Drafts

shortcuts

#1

New Drafts 5 user here, but I do have some experience using Workflow and now Shortcuts. I’m trying to automate writing a letter, but could have written 20 letters in the time it’s taking me to fail writing automation! So much for saving time.

Would someone be kind enough to give me the basics (or a link to a tutorial) for passing Siri Shortcuts output as input to Drafts 5 (pro). Specifically, in Shortcuts I’m trying to to pass date and selected contacts address info to Drafts as the start of a business letter.

There may be an easier way to do this, maybe a template in Drafts that can access contacts (I don’t have to use Shortcuts)? I need the current date, selected contact info (full name and address), and the ability to dictate the body of the letter by voice. After the the letter is complete, I need to save the draft as a unique file, and send it as an attached PDF via email. It would be amazing to be able open a template letterhead file and do all of the above.

Unfortunately, I’m not a coder and much of the scripting reference in this forum is over my head. I’d be SO grateful to the community for a point in the right direction.

Thanks!


#2

Drafts doesn’t yet have the ability to access contacts. But with Shortcuts you should be able to string some things together. The simplest way would be to assemble your text in Shortcuts and then pass the whole text to Drafts before triggering dictation.

I will try to put an example together this eeek if I have some time.


#3

I agree this is entirely possible, but would it not be better to compose your letter in Drafts (using dictation and any manual correction required), and then send that draft content to a Shortcut to do all the contact selection, date specification, and bundling up to mail? I think that would smooth things out as you wouldn’t have to trigger as much back and forth between apps and as a byproduct it does happen to circumvent your current issue.


#4

https://www.icloud.com/shortcuts/558c4d7b06564c7bb6c6cfd421079f58

This is what I’ve got so far, it’s pretty basic at this point. It just grabs the date and contact info, I also used “ask for input” for a subject line, then sends it all to Drafts.

The suggestion to begin in Drafts would appear to make easier to use “repeat for each” for multiple recipients of the same letter, but I have no clue how to send a Draft to Shortcuts. If someone could explain how to export contents of a draft as input for a shortcut (workflow action) I’d be grateful!
.


#5

The “Run Shortcut” action step sends text to Shortcuts. By default it’s templates is [[draft]] which sends the whole current draft. Sort of covered in this tip - which is about getting a result, but there’s no need to use the step in that way - it can just trigger the shortcut with input text.


#6

Nice! thanks for the tip. What the action/shortcut step used in Shortcuts to grab the text sent from Drafts?


#7

The template in the action is what gets passed. You can find a list of tags you can use in the template here.

You can also mix in static text as well as dynamically evaluated tags.


#8

Thanks! Good stuff!

I’m having trouble grabbing the text sent from Drafts via the Shortcuts Action in the Shortcuts app. I expected it would be “Get Text from Input” but the action in Drafts runs, opens Shortcuts, then returns to Drafts with no text being passed to the shortcut.


#9

A quick example set:


#10

Thank you for that, the set variable was what I was looking for!

Dictating the body of the letter into Drafts is easy, then the action sends the text over to Shortcuts to add contact info and other details. This works.

Thanks!


#11

Hi. New here (and to Drafts) for this issue. I was looking for a way to edit long text in a Shortcut. Drafts was recommended over on reddit.

I can use: source text > Add to Draft, Mode: Create, Edit in Drafts. Well enough, goes to Drafts.

But how do I return the edited text to Shortcuts? At which point does it ‘save’? If I edit text, dismiss keyboard, and then return to shortcuts (on top menu bar left), the result is the original text.

I had a look at the DraftsContentTest shortcut posted above, but all that’s doing is Set Variable, which I’m already doing after the Add to Draft action (in shortcuts).

I have no idea what a Drafts Action is yet, and for now don’t really care to know. I just want to pass text to Drafts > edit > return…

Also, how would I delete that (literal) draft, which is just a temporary edit?

Thanks!

PS: hard to find the right place to post questions related to Shortcuts. I would expect a whole sub-forum under the Integration Guide. I take it Actions Help is not quite right…


#12

Drafts does not have a way to do temporary edits like you are describing within the execution of a Shortcut. No sure what your over all goal is…typically a flow like this would start in Drafts, were you would type your text and run an action which could pass that text into Shortcuts…and that action could be set to automatically archive or trash the text.


#13

Too bad. The goal is for a shortcut to fetch an XML file from a server via SSH, edit contents, and put changed file back on server. Can do within shortcut if text isn’t too long. But wanted to use Drafts for longer content.


#14

On the Shortcuts side you could split the XML into element based chunks, select from a list which chunk to edit and so manage the size that way. Not great, but better than nothing.


#15

Nice idea. Thanks. Better to wait until Drafts gets updated so that it can pass text back to a shortcut that called it. Even better with the option (when called) to trash the temp file.


#16

Is that definitely going to happen though and in what timescale? :thinking:


#17

We’re talking XML here…

… Do we know if Drafts or Shortcuts can shred XML? If so it could be more broadly useful.


#18

That is not a feature likely to come to Drafts…nor do I think it’s really practical. Editing is not best done in context of execution. It’s an out-of-process type activity. Shortcuts would likely timeout, or iOS quit it in the background, or other things that make it technically unreliable to pause to user interaction mid-stream.

I would suggest you consider redesigning your flow to break it into two Shortcuts, one that handles the loading and pushing text into Drafts, and one that can be trigger from a Drafts action after editing to push the text back to Shortcuts and do whatever remaining processing/uploading/whatever you need after editing.


#19

That matches to my thinking :wink:

I was just querying why @ctawn had an expectation that such a feature was coming to Drafts.


#20

I don’t think that’s true. There is a Wait for Return action in Shortcuts, which does exactly that, so it won’t time-out.

Thanks for the other suggestion about workflow redesign. This is not something I’m going to use very often, but I am distributing it (and have in fact already without the desired Drafts option). So two shortcuts doesn’t work. It’s part of a larger multi-function shortcut within some XML (sourced on a server) may need to be edited (fairly quickly in most cases) and returned to server with edits. It would work with just a larger edit window within shortcuts. Right now the only option is a small alert dialog with a text box (Show Alert). Basically, Shortcuts needs an “Edit Text” action.