Action to dictate text to the same draft

Hi,
new here. Pro user since several months. I’m in need of an action to dictate words and add the date and time with a line break below.
Running the action should not create new drafts but adding the dictated text to the opened draft. Seems not too complicated but unfortunately I have no knowledge in programming. Could some provide an action described above? Would really appreciate it.
Regards

There is an example Insert Dictation action in the directory that inserts the result of the dictation in the current draft (at the cursor position).

(Ships with app in “Editing” action group)

I would need minor modifications to insert the timestamp, and possible always insert at the end of the draft, if that is what you are needing.

Wasn’t aware about the availability of the source of this snippet.
How could I add the timestamp or another linebreak for example?

Could someone give me an example how to implement a linebreak and timestamp in the code?

Something along these lines should do it. This will prompt for dictation, and then append to the end of the current draft with a timestamp and the dictated text. It utilized template tags. The template variable can be edited to change the format of the appended element.

// define a template
let template = `
# [[time]]
[[dictated-text]]
`;

// dictate
var s = editor.dictate();
if (s.length > 0) {
    draft.setTemplateTag("dictated-text", s);
    draft.content = draft.content + draft.processTemplate(template);
    draft.update();
}
1 Like

Hi,

This is a great script for my workflow, however; when I add to Siri and summon the action using “add note”, neither the dictated text or timestamp inserts into the current draft (it doesn’t add anywhere as far as I can tell, just leaves it blank).

What am I doing wrong?

Thanks

The above is for a Drafts action. When the action is triggered it will allow for dictation.

If you are giving Siri an instruction, that is something quite different. Drafts actions do not hook into Siri in the same way shortcuts can on i*OS.

I should have been specific…

Using Drafts for iOS, when in ‘edit’ mode for this particular action, I clicked the option ‘Add to Siri’ found at the bottom left corner of the edit pane. A pop-up window appears and I pressed the blue ‘Add to Siri’ button.

When I summon Siri to insert dictated text with timestamp, the Drafts dictation window appears and begins dictating my speech. However; once I press ‘create’, neither the text or timestamp appears.

‘After Success’ is set to ‘nothing’.

“Add to Siri” is suitable for actions that establish their own context. They run without any draft context, because they can be run from anywhere, anytime. They cannot act on the current draft as if you are running them like tapping on an action in the list.

That feature is more for things that launch drafts to a particular destination.

As an alternative approach, try this:

Drafts Action

Shortcut

https://www.icloud.com/shortcuts/11702569dd1746dc9cff150a3192f3d2

It uses x-callback-url calls to get the currently loaded draft and then run the action against that draft.