How to run an action using Siri Shortcut? (asks a newbie)

I’ve made a simple “captain’s log” action which works nicely from the actions menu, but now I’d like to invoke it using voice, either from phone or watch.

The shortcut appends the current Drafts text to a file on iCloud, including date (based on Append to iCloud Journal)

I’ve recorded a Siri Shortcut for the action, and using voice does append a new line to the file, but it only adds the date and not the text of the draft.

What steps am I missing?

I’m a newbie at using voice commands, but I’ve used Workflow previous to it becoming Shortcuts.

Can you share your actual captain’s log action, as that’s the action that is having the issue?

There are some details on the web site, but here’s my step by step.

  1. Slide open the actions list if it isn’t visible.
  2. Scroll to show the action you wish to share.
  3. Swipe from left to right, across the action to edit it.
  4. Scroll down the action editing page until you get to the Action Directory section.
  5. Tap on Share to Action Directory.
  6. If you just want to post here and don’t want it listed for people to browse in the Action Directory, ensure that the ‘Unlisted’ option towards the bottom is enabled.
  7. Tap on the Share button.
  8. Tap on the Share Now button.
  9. Tap on the Copy Link to Clipboard button.

Then just paste the URL into your posting.

1 Like

Ah, thanks! I didn’t understand that you meant to actually upload the action, I didn’t know it could be posted unlisted.

But I think the fundamental issue is probably that I don’t understand how to use Siri shortcuts, which is a question for another forum. (I was quite happy with Workflow and had a lot of use for it but Shortcuts broke my key workflows so I abandoned it).

Reading the text of the “Add to Siri” sheet in Drafts is confusing because it says that it will only work with blank drafts, which seems completely pointless. I’m obviously missing something fundamental somewhere.

It is working with blank drafts because for the majority of users, particularly users of previous versions, when they open Drafts, they get a new Draft each time. I don’t personally have mine configured like that, but if that’s typical behaviour, then I can understand why that is the case for Siri … and why there’s a specific note about it in the Siri set-up. I don’t think you’re missing anything fundamental. I think you’ve understood the situation perfectly, but just any potential reason as to why seems to have been the issue.

For reference on the above, take a look in your settings for the New Draft Creation section at the top and in particular the New Draft After and Focus mode settings.

But, all is not lost :wink:

I’ve had a quick go at putting together an alternative Captain’s Log action. Instead of using the File action it uses a Script action to accomplish the same sort of thing, but with a bit more besides.

The key assumption here is that the last draft you modified is the one that you want to append details for to the log. Based on this assumption, the script first identifies the last modified draft. It loads it into the editor. This is hopefully quick enough that you won’t even notice a blank draft was there initially. The second part of the script then builds the log file.

Below is what the script looks like. Hopefully you can make sense of the key elements I replicated from your initial action.

//Load the last modified draft
let allDrafts = Draft.query("", "all", []);
allDrafts = allDrafts.sort(function(draftA, draftB)
{
	return draftB.modifiedAt - draftA.modifiedAt
});
editor.load(allDrafts[0]);


//Get the current log content
let fmCloud = FileManager.createCloud();
let strLogPath = "/Logs/Log-" + draft.processTemplate("[[date|%Y-%m]]") + ".txt";
let strLogContent = fmCloud.read(strLogPath);

//Append the new log content to the existing content
strLogContent += draft.processTemplate("[[date]]");
strLogContent += " ";
strLogContent += draft.processTemplate("[[time|%R]]");
strLogContent += " ";
strLogContent += draft.processTemplate("[[tags]]");
strLogContent += " : ";
strLogContent += allDrafts[0].content;
strLogContent += "\n";

//Write the revised content back to the log file
fmCloud.write(strLogPath, strLogContent);

I did try to queue up the original action at first after loading the last modified draft, but even after loading that draft, the ‘draft context’ the queued action took was the original blank draft. Hence why I reproduced the file action in the script.

In my tests, this worked just fine when run from the actions list and from a Siri command. Hope it works for you too, but let me know if it has any issues.

1 Like

Oh my goodness, you’ve gone above and beyond! I’m very grateful! I shall give that a spin later and report back.