Action

Process Meeting Notes to Things

Posted by jsndyr, Last update 5 months ago

This script looks for the following text in a Drafts note and imports it into Things 3.

  • [ ] Task title/details on this row
    • due: YYYY-MM-DD format
    • notes: Add any notes you want for your todo here
    • tags: Tags can be separated by commas
    • project: Add your task to the selected project. Needs to exactly match the title in Things.

The only field that is required is the first row. You can include none, one or more of the rows that are indented below as needed. Project name needs to be exact to work.

Once a task is moved to Things, the checkbox is updated to say [things] so you can continue to add to do items to your note and add them without duplicating previoulsy added items.

I use this action to process my meeting notes to make sure all of my to do items end up in Things for tracking purposes.

Steps

  • script

    // Function to create a task in Things with optional task details.
    function createTaskInThings(title, dueDate, notes, tags, project) {
        let baseURL = "things:///add?";
        let urlParts = [];
        urlParts.push("title=" + encodeURIComponent(title));
        
        if (dueDate) {
            // Use "when" field for Things URL scheme instead of "deadline"
            urlParts.push("when=" + encodeURIComponent(dueDate));
        }
        
        if (notes) {
            urlParts.push("notes=" + encodeURIComponent(notes));
        }
        
        if (tags && tags.length > 0) {
            // Join multiple tags with comma
            urlParts.push("tags=" + encodeURIComponent(tags.join(',')));
        }
    
    	 if (project) {
    	 		urlParts.push("list=" + encodeURIComponent(project));
    	 }    
        let url = baseURL + urlParts.join("&");
        // Open URL to create a new task in Things
        app.openURL(url);
    }
    
    // Function to mark task as moved to Things in the Draft
    function markTaskAsMoved(index) {
        lines[index] = lines[index].replace("- [ ]", "- [things]"); // Mark the task as moved to Things
        // Update the draft content with the modified lines
        draft.content = lines.join("\n");
        draft.update();
    }
    
    // Parse current draft content
    let lines = draft.content.split("\n");
    
    lines.forEach((line, index) => {
        if (line.startsWith("- [ ]")) { // Task line found
            // Variables to store task details
            let dueDate = null, notes = null, tagsArray = [], project = null;
            let title = line.substring(5).trim(); // Remove "- [ ]" prefix
    
            // Look ahead for up to 4 sub-bullets
            let lookAheadIndex = index + 1;
            while (lookAheadIndex < lines.length && lines[lookAheadIndex].startsWith("\t- ")) {
                let subBullet = lines[lookAheadIndex].trim().substring(1).trim(); // Remove leading "- "
                
                if (subBullet.startsWith("due:")) {
                    dueDate = subBullet.substring(4).trim();
                } else if (subBullet.startsWith("notes:")) {
                    notes = subBullet.substring(6).trim();
                } else if (subBullet.startsWith("tags:")) {
                    tagsArray = subBullet.substring(5).trim().split(',').map(tag => tag.trim());
                } else if (subBullet.startsWith("project:")) {
                		project = subBullet.substring(8).trim()
                }
                
                
                lookAheadIndex++;
            }
    
            // Create task in Things with the gathered details
            createTaskInThings(title, dueDate, notes, tagsArray, project);
    
            // Optimistically mark the task as moved in Drafts; 
            markTaskAsMoved(index);
        }
    });
    

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.