Reminders - Actions that Create Reminder + Alert for 'tomorrow', 'two days from now' and 'next week'

There are many times when it is late at night and things pop into my head that I want or need to do the next day. I have found Drafts wonderful for those sorts of items - quickly capture the idea, thought or task, and click a “Add to Reminders” action and it sends it to Apple Reminders.

What I’d like to do is have the action automatically set the reminder date to ‘tomorrow’ and the Reminders alert time to a specific time (i.e. 8AM, or Noon or whatever). Then I’d like to copy that to another action where the reminder date is, say, two days away and maybe make a third action where the due date/reminder alert is a day ‘next week’.

I know there are “Reminders with Options” actions but late at night, I don’t want to fiddle with the date, the priority, or the other options. I just want a ‘one click’ action that will capture the reminder and set it to remind me the next morning (or any of the other scenarios noted earlier).

Still trying to figure out how to develop my own actions in Drafts - but need some clear guidance on how to do this. If someone could point me in the right direction or share a snippet of code that enables this, would be forever grateful!

Hope this makes sense.
Thanks!

Do you know how to create a script action? I think the code below does roughly what you are looking for.

const list = ReminderList.default()
var reminder = list.createReminder()
reminder.title = draft.content

const now = new Date()

var tomorrow = new Date()
tomorrow.setDate(now.getDate() + 1)
tomorrow.setHours(8)
tomorrow.setMinutes(0)
tomorrow.setSeconds(0)

var inTwoDays = new Date()
inTwoDays.setDate(now.getDate() + 2)
inTwoDays.setHours(8)
inTwoDays.setMinutes(0)
inTwoDays.setSeconds(0)

var nextWeek = new Date()
nextWeek.setDate(now.getDate() + 7)
nextWeek.setHours(8)
nextWeek.setMinutes(0)
nextWeek.setSeconds(0)

var p = Prompt.create()
p.title = "Add Reminder"
p.message = "When you would like to be reminded?"
p.addButton("Tomorrow")
p.addButton("In two days")
p.addButton("Next week")

var alarmDate  = new Date()

if (p.show()) {
	if (p.buttonPressed == "Tomorrow") {
		alarmDate = tomorrow
	} else if (p.buttonPressed == "In two days") {
		alarmDate = inTwoDays
	} else if (p.buttonPressed == "Next week") {
		alarmDate = nextWeek
	}
	
	reminder.addAlarm(Alarm.alarmWithDate(alarmDate))
	reminder.update()
}

I’ve been noodling around with script actions - I know just enough to be dangerous. :stuck_out_tongue: - but wasn’t fully sure how to get started. I’ve edited other scripts but not created from scratch.

Really appreciate you posting the code - just the head start I needed. I’ll play around with it and let you know how it goes!

Stephen

1 Like

I can definitely tell that’s the type of code I’m looking for however I’m realizing actually enabling it to work was a bit more than I’m capable. LOL

This is basically what I’m looking to enable:

  • Type a task/reminder in Drafts
  • Click an action which does all of the following:
    • Action automatically puts the reminder in a specific “Reminders” list that is specified within the action
    • Action automatically sets a “Due Date” for that task/reminder for the next day that is specified within the action
    • Action automatically sets a “Time” for the reminder alert for 8AM on that same next day that is specified within the action

One ‘click’ and it does all that.

Then, when you get up the next morning, and starting the day, you get alerted at 8AM of the task/reminder I put in the day before.

Sounds like we are close to what you need. Just a few points I’m unclear on.

  1. Did you manage to get my previous code running?
  2. If so, can you describe how its behaviour compares to what you want? If not, let me know and I can give you specific instructions on how to run the script.
  3. When you say “specific Reminders list”, do you mean you want to use the same list every time, or choose which list each time?
  4. When you say “the next day that is specified within the action”, do you mean you want it always to be tomorrow, or do you want to select which day to be reminded.

If you want to minimise taps/clicks, perhaps just 8am tomorrow is what you want every time?

Hi. Thanks again for responding!

To answer your questions:

  1. I cut/pasted your code into Drafts however I don’t think I did it right. See screen shot below.
    Dropbox - drafts_reminders.png - Simplify your life

  2. As noted, I didn’t see any behavior but I think it was because I didn’t do something correctly. I doubt the issue was your code.

  3. Yes, same list every time. One click on the action does it all.

  4. Yes, always tomorrow (or always next week). One click on the action does it all.

What you describe at the bottom of your post is what I want. I basically want to apply the idea how we can “Snooze” an email in Gmail to to a fixed time (tomorrow or next week) and apply it to a new Reminder/Task.

So the use case would be: After I type whatever the task is in Drafts that I need to do (i.e. “Replace exterior lightbulb over garage door”), I click the action (lets call it “Reminder Tomorrow”) and it adds the task to one of my lists of tasks in Reminders, and it sets the reminder of that task for 8AM tomorrow. Then at 8AM tomorrow, Reminders sends me the alert for “Replace exterior lightbulb over garage door”. And then I’ll remember to go replace that lightbulb. :slight_smile:

I just want to eliminate the friction of choosing the list, choosing the date, choosing the time of the reminder when I’m capturing the task. I want all of those items set within the ‘action’. Then, maybe I could copy the action and create a new one that changes those variables for different situations.

Yeah, it may seem a little backwards but for me, the evening hours are my downtime and I usually remember I need to do things then. So capturing the task quickly, getting it out of my head (so to speak), and knowing it will ping me with an alert tomorrow (or whenever) when I’m at my desk or more focused on such things is what I want.

Got it, thanks. I understand what you’re after. That’s actually much simpler to achieve than what I previously shared. Just to make things simpler, I’ve packaged up the code into an action this time, so that you can just install it directly.

Here is the code included in that action. Hopefully you can see how to easily change the name of the reminders list you want to use and the number of days in the future you want the reminder to be set.

// You can change the name of the reminders list here.
const list = ReminderList.find("Reminders")

// You can change the number of days in the future here.
const numberOfDays = 1

var reminder = list.createReminder()
reminder.title = draft.content
var dueDate = new Date()
dueDate.setDate(dueDate.getDate() + numberOfDays)
dueDate.setHours(8)
dueDate.setMinutes(0)
dueDate.setSeconds(0)
reminder.addAlarm(Alarm.alarmWithDate(dueDate))
reminder.update()

The thing you were missing before is that to run these JavaScript automations, you need to use a “Script” step under the Step Types drop down menu. You can put code in there and it will run. Here’s a link to the Scripting Reference if you are interested in learning more.

1 Like

This is perfect! So great! And I love how it is easy to change the time, the Reminders list it would go to and the # of days.

Thank you SO much! I am definitely going to read up on the ‘scripting’ elements so I can teach myself how to do more of these sorts of actions and automations. Very cool. Thanks for engaging on this!!

Also, now that you pointed me in the right direction with ‘scripts’, I tried out the previous script you posted and that is great as well! I’ll play around with that a bit too.

Whoo hoo! As Borat would say: “Very nice, very nice” :smile:

1 Like

So glad that was helpful. Yes, do dig around in the Scripting Reference and try things out. It’s not as hard as it might initially seem. Like any programming, you’re going to make a lot of mistakes at first, but it’s so satisfying when you finally get things working.

I set this up on MacOS and it worked fine but on my iPhone I got the following error. Any idea?

Check that you allowed Drafts permissions to access Reminders in iOS Settings. You would get an error like that If permissions were not granted.

Where in iOS Settings would I do that? Not familiar with where permissions are set between apps in iOS.

Disregard previous post. I found it - in Drafts settings. I already had it set to allow Drafts to access Reminders. Yet, it is still throwing that error.

A couple of things to check. Here’s what it should look like in the Settings app:

Could you also check that the Reminders list your have named in the script is actually available in the Reminders app on your iPhone? It may be that the script is failing because it can’t find the list you’ve mentioned.

That would be it! The Settings are fine and align with what you shared, but I was pointing to a list that apparently is only on the MacOS version of Reminders and not on iOS. Thought all task lists were synced to cloud but apparently not! Thanks for pointing this out!

Stephen

1 Like

I had thought that I could modify this script to create a reminder WITHOUT a time by simply removing lines 11-13, but doing so just results in a reminder in which the current time is added (instead of 8am). I would be grateful is someone could help me figure out how I can specify a due date without a time

Also, is there any way to tweak pdavisonreibers’s script so that I could create a separate reminder for each of multiple drafts? Ideally I would want to select several items in my inbox, run the action, and have multiple reminders created. As it is now, if I select several items and run the action, only 1 of the items is sent to Reminders. I realize that I can accomplish this by selecting multiple items, operations, run action, and then choosing the action but am hoping there is a way to incorporate it into a script and thus eliminate two steps

Consider the following:


// You can change the name of the reminders list here.
const list = ReminderList.find("YourListHere")

// You can change the number of days in the future here.
const numberOfDays = 1

var reminder = list.createReminder()
reminder.title = draft.content
var dueDate = new Date()
reminder.dueDateIncludesTime = false
dueDate.setDate(dueDate.getDate() + numberOfDays)
reminder.dueDate = dueDate

// reminder.addAlarm(Alarm.alarmWithDate(dueDate))
reminder.update()

The dueDateIncludesTime property is the major thing here: https://scripting.getdrafts.com/classes/reminder.html#duedateincludestime

Not sure what you want to do with the alarm, so I commented it out for now, and set the reminder.dueDate explicitly. Hope this helps point you in the right direction.

Many thanks @jsamlarose, that’s exactly what I was looking for, including even commenting out the alarm!

1 Like