Help with dictation

Hi
I am using an action to dictate to a new draft and this works fine. I prefere the drafts dictation interface over ios.
So I now have a new draft with my text diction.
I then run an action that appeds it to a file. this work well.

I want to combine the two actions so that

Start → open dication → dictate → manually finish → dictation window closes and I have dreaft with dictated text → ( here is where I am stuck ) Open the append action and run. → End result dicated text is neatly in file.

What happens is that I am dictating(step 1) and the append action (Step 2) runs imediatly and send an empty draft over to my file. I casn see why it dose this now. I think I need a way of running step 2 when the dictation has finished and the text text is in the draft.

Any help would be greatly appreciated. I am not a coder , but tend to learn on the fly.

Rich

2 Likes

Actions always run with a draft as the context for evaluating action steps. When you run and action from the action list or action bar, that draft is the one currently loaded in the editor - which is probably a new, blank draft most of the times you run your action.

If you share the action you are using it would be easier to diagnose. I’m guess you have a script step that is creating the a new draft with using dictation – but just because that new draft was created, does not change the further steps in the action are still running with the previous draft in context.

There are a couple of ways to write the action to do what you want. I might suggest breaking out your append action into a separate action, and queuing Drafts to run that action against your newly created one, which would look like the below (in a single script step):

// open dictation and get the resulting text
let text = editor.dictate();
// create new draft 
let d = new Draft();
d.content = text;
d.update();
// lookup action, and queue it to run against new draft
let a = Action.find("NAME-OF-APPEND-ACTION");
app.queueAction(a, d);
3 Likes

Hi
Many many thanks that worked a treat. Very robust. Now able to append my Obbsidian notes.:grin: I think it was the queue line that I wasn’t understanding

Thank you

R