Drafts Action Directory

Remind Me of… Things

Posted by @nahumck, Last updated: 2018-06-23 20:05:44 UTC

Replicate the “Remind me of this” functionality of Siri using Drafts + Things.

Install

Steps

  • script

    var when = new Date();
    var p = Prompt.create();
    p.title = "Select Date";
    p.addTextField("title", "Title", draft.title);
    p.addDatePicker("when","Select When Date", new Date(), {"mode":"date"});
    p.addSwitch("switch","Add a Reminder?", true);
    p.addDatePicker("when","Select When", new Date(), {"mode":"time","minuteInterval":5});
    p.addButton("Send to Things");
    var con = p.show();
    
    var url = draft.permalink;
    var title =  p.fieldValues["title"];
    var when = p.fieldValues["when"];
    var reminder = p.fieldValues["reminder"];
    
    if (con) {
    	var todo = TJSTodo.create();
    	todo.title = title;
    	todo.when = when + reminder;
    	todo.notes = url;
    	var container = TJSContainer.create([todo]);
    	// Use CallbackURL object to open URL in Things.
    	var cb = CallbackURL.create();
    	cb.baseURL = container.url;
    	var success = cb.open();
    	if (success) {
    		console.log("Task created in Things");
    	}
    	else {
    		context.fail();
    	}
    }
    else {
    	context.cancel();
    }
    
    

Comments

Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.