Action

Remind Me of… Things

Posted by @nahumck, Last update over 6 years ago

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

Steps

  • script

    // Get link to draft
    var url = draft.permalink;
    
    // Prompt for date with toggle for reminder
    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?", false);
    p.addButton("Send to Things");
    var con = p.show();
    
    var title =  p.fieldValues["title"];
    var when = p.fieldValues["when"];
  • script

    // If reminder time is selected, prompt for time
    if (p.fieldValues["switch"] == true) {
    	var q = Prompt.create();
    	q.title = "Select Time";
    	q.addDatePicker("reminder","Time", new Date(), 	{"mode":"time","minuteInterval":5});
    	q.addButton("Add Time");
    	var con = q.show();
    }
    
    var reminder = q.fieldValues["reminder"];
    reminder.toString("HH:mm")
  • script

    // Create Task
    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();
    }

Options

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