Action

Smart Task in Todoist

Posted by @mattbirchler, Last update over 6 years ago

Create tasks in Todoist with names, due dates, and priorities. The task name must always be on the first line. Additional info needs to be prefixed by a set number of strings followed by a space:

  • “at” or “@“ are for due dates (using OmniFocus’s smart time parsing, so “10am tomorrow” works)
  • A line with just the number 1-4 will set the priority to that value
  • All lines that don’t match up with a prefix listed above will be assumed to be a note

Steps

  • script

    var arr = draft.content.split("\n");
    
    var baseURL = "todoist://addtask";
    var addLink = CallbackURL.create();
    addLink.baseURL = baseURL;
    
    
    for (i = 0; i < arr.length; i++) {
    	// The task name
    	if (i == 0) {
    		addLink.addParameter("content", arr[i]);
    	}
    	// The due date
    	else if (arr[i].slice(0,3) == "at " || arr[i].slice(0,3) == "At ") {
    		addLink.addParameter("date", arr[i].slice(3,100));
    	} else if (arr[i].slice(0,2) == "@ ") {
    		addLink.addParameter("date", arr[i].slice(2,100));
    	}
    	// The priority
    	else if (arr[i].slice(0,9) == "priority " || arr[i].slice(0,9) == "Priority ") {
    		addLink.addParameter("priority", arr[i].slice(9,50));
    	} else if (arr[i].slice(0,1) == "1" || arr[i].slice(0,1) == "2" || arr[i].slice(0,1) == "3" || arr[i].slice(0,1) == "4") {
    		addLink.addParameter("priority", arr[i]);
    	}
    	// Anything else
    	else {
    		addLink.addParameter("content", arr[i]);
    	}
    };
    
    // alert(addLink);
    
    
    // open and wait for result
    var success = addLink.open();

Options

  • After Success Archive
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.