Problem chaining Dictate action with others to utilise Siri Intents

I get the whole Siri Intents thing and think the integration with Drafts is great. I know how to initiate set up etc., so no problems there.

However, I’m running into a bit of a problem when I try to ‘bolt’ a dictate new draft action along with other ‘include actions’ in a new action. Essentially all I am trying to do is invoke dictation via Siri shortcut/keyword and then get Drafts to run an action on what has just been dictated.

Here is the dicate action.

The issue seems to be that, although a new draft gets created (I can see it on screen) when the next steps in the action run (‘include actions’ for dropbox etc)., these are referencing not the newly created draft from the dictation, but rather, the previous draft created before it.

So is there anyway to ensure that a dictation step can be used and then use further non-javascript ‘include action’ steps on the dicated draft for it to be sent to Dropbox etc.?

Creating a new draft in script does not change the draft that is in context of the running action, so the include action steps will always be looking for values from the draft that is in context. It is currently not possible to change the draft that is in context mid-execution of an action.

There’s a couple of ways to approach this…

  1. Write to Dropbox in the script after dictation (you would not need to create the drafts at all, if you don’t want), something like this added to your script:
let db = Dropbox.create();
db.write("/path/to/file.txt", d.content, "add", true);
  1. Queue the action to run on the new draft, instead of including the action. This will set up a new action to run with the new draft in context. The only downside of this is it will occur after completion of the current action, so the shortcut will continue running before it completes. Like:
let action = Action.find("My Dropbox Action");
app.queueAction(action, d);
  1. Use template tags to pass data. You can put your dictated text in a custom template tag, and use that tag in subsequent action steps. This means, of course, the included action will have to have templates which use those tags - which might not be desireable.
draft.setTemplateTag("dictated_text", d.content); // now use [[dictated_text]] in subsequent action step templates

OK. Thanks. I was obviously a little naïve thinking “Dictate new draft,” actually meant that :wink:

Looks like I’m staring down another “JavaScript for the non-JavaScript user,” rabbit hole here. Thanks for the feedback and I’ll give a go incorporating some of the workarounds you’ve kindly listed. Cheers.