Adapt Script to facilitate all-in-one dictation

Hi Folks. Just wondering if anyone could help on this? I have this action that can send multi-line tasks to the Inbox in Todoist. With the advent of Widgets though, it would be super-handy if I could run the action from a widget and it kicks straight into dictation and then runs the rest of the script as per the below.

So could anyone recommend the changes that would need to be made to facilitate this? Thanks.

// create task in Todoist inbox for each line in the draft

let lines = draft.content.split("\n");

let todoist = Todoist.create();
let ctErrors = 0;

for (let line of lines) {
if (line.length > 0) {
let success = todoist.quickAdd(line, “”, “”, {
“auto_reminder”: true
if (success) {
console.log("Todoist task created: " + line);
else {
console.log("Todoist error: " + todoist.lastError);

if (ctErrors > 0) {;

Take a look at the editor dictation function. It returns the dictated text as a string without even having to save it to a draft, but you could, of course, do that as well if you wanted to. But otherwise, just split that function’s result rather than the content of the current draft.

let lines = editor.dictate().split("\n");

Also, don’t forget to wrap your code in triple back ticks as the forum does do its very best to mess it up otherwise.


Wow. That straightforward. Excellent stuff. Much appreciated. Works like a charm. And sorry, did click on the code block thingy but it didn’t seem to do much. Will bear the triple ticks in mind next time. Thanks again for your help.

Without wishing to lecture you, triple backtick is standard Markdown. Personally I find it better to memorise (not hard) and use the Markdown markers rather than rely on the icons.

I consider myself lectured :wink:

I mean…if we’re being pedantic, it’s not part of standard Markdown. It’s part of extensions to Markdown. The original spec only has indented code blocks. :wink: