Action
Todoist Quick Add
Action to create one of more tasks in Todoist.
The action uses the Todoist Quick Add API call so it can take advantage of the features used within the native Todoist apps to add tasks to specific projects and set due dates/times. For example:
Make Cake Thursday 5pm #Food
Call Joe tomorrow #personal
Each line in the draft is processed as a separate task. Blank lines are retained. When complete the actions adds ‘OK’ or ‘Fail’ to the end of each line depending on the result fo the API call. This is primarily for testing.
You will need to add your Todoist API Token to the script in the position indicated
Steps
-
script
// check to see if draft is blank var content = draft.content; var check = content.length; var todoistToken = "Insert your Todoist API Token Here"; if (content.length == 0) { alert("Draft is blank"); context.cancel("Draft was blank"); } // Call API for each line in a draft var newDraft = ""; // split draft and loop over lines var lines = draft.content.split("\n"); var http = HTTP.create(); // create HTTP object for (var line of lines) { if (line.length == 0) { newDraft+="\n" } else { var response = http.request({ "url": "https://todoist.com/api/v7/quick/add", "method": "POST", "data": { "token":todoistToken, "text":line }, }); if (response.success) { newDraft+= line + " - OK\n" } else { newDraft+= line + " - Failed\n" console.log(response.statusCode); console.log(response.error); } } } editor.setText(newDraft)
Options
-
After Success Default Notification Info Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.