Action
Send Markdown To-dos to Todoist
Create a to-do in Todoist for each found Markdown style to-do in the draft with a permalink back to the draft.
You can also include Todoist context options like #project, @tags, due dates, priority, and reminders.
All context options must be at the end of the line and after ‘//‘ (e.g. - [ ] task name // #project @tag 1pm p1).
The Todoist tag @drafts is automatically added to all created to-dos for easier tracking in Todoist.
Sample To-dos:
- [ ] Update website header // #WEB mon 1pm
- [ ] Reorder retail bags // #STORE @buy
- [ ] Biz dev metting review // #MGMT p1 in 30 days
Steps
-
script
// Create a to-do in Todoist for each found Markdown style to-do in the draft with a permalink back to the draft. // You can also include Todoist context options like #project, @tags, due dates, priority, and reminders. // All context options must be at the end of the line and after ‘//‘ (e.g. - [ ] task name // #project @tag 1pm p1). // The Todoist tag @drafts is automatically added to all created to-dos for easier tracking in Todoist. // Sample To-dos: // - [ ] Update website header // #WEB mon 1pm // - [ ] Reorder retail bags // #STORE @buy // - [ ] Biz dev metting review // #MGMT p1 in 30 days // split all lines of draft let lines = draft.content.split("\n"); // create a Todoist object let todoist = Todoist.create(); // Create error counter let ctErrors = 0; // Iterate over all lines in draft for (let line of lines) { // If line containts Markdown to-do continue if (line.startsWith("- [ ]")) { // If line contains Todoist context options (e.g. - [ ] task name // #project @tag 1pm) capture them if (line.includes("//")) { // Create an array of the split line let arr = line.split("//"); console.log(arr); // Set the title of the to-do from the first item of arr let title = arr[0].trim(); // Set the context options of the to-do from the second item of arr let context = arr[1].trim(); // Setup the task creation text in Todoist shorthand format var todo = "[" + title.replace("- [ ]", "").trim() + "](" + draft.permalink + ") @drafts " + context; } // If line didn't contain '//' then just add the to-do title and draft permalink else { // Setup the to-do creation text in Todoist shorthand format less the context options var todo = "[" + line.replace("- [ ]", "").trim() + "](" + draft.permalink + ") @drafts"; } let success = todoist.quickAdd(todo); if (success) { console.log("Todoist task created: " + line); } else { ctErrors++; console.log("Todoist error: " + todoist.lastError); } } } if (ctErrors > 0) { context.fail(); }
Options
-
After Success Ask , Tags: todoist Notification Info Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.