A script to automate reminders

I don’t think your script is useless. I’ll use it.

I was just tying to completely automate the process of entering a note into my tasks folder and having it show up on my calendar without me possibly forgetting to do anything else.

Also it would be nice to be able to add tasks on my phone and when they sync to Mac automate the reminders function as well. But I don’t know if that can happen.

Doing it on the iPad or iPhone is really the ultimate plan. I use an application called Daylite to display all my tasks and events. But I like to enter my tasks into dt3 or dttg since I am able to store much more information with the task. But I don’t want to lose track of them.

Currently I enter all my tasks into a group simply called tasks.

So you would like a reminder in the Reminders app for every task which is placed in the group called tasks? Does the reminder need a due date?

-- Script to add a selected record to Reminders as a to do
-- Written by Eric Böhnisch-Volkmann, Version 1.1, Sep 12, 2012
-- © 2010–2014 DEVONtechnologies, LLC
-- Modified October 28, 2016 by Jim Neumann / BLUEFROG / DEVONtechnologies, LLC
-- Modified by blanc (remove user input)

-- Set properties
property pPrefix : "Reminder" -- Prefix for the created to do item
set theDueDate to ""

-- Import helper library
tell application "Finder" to set pathToAdditions to ((path to application id "DNtp" as string) & "Contents:Resources:Template Script Additions.scpt") as alias
set helperLibrary to load script pathToAdditions

try
	-- Get the selection
	tell application id "DNtp" to set thisSelection to the selection
	
	-- Error handling
	if thisSelection is {} then error localized string "Please select a document or group, the try again."
	if (length of thisSelection) > 1 then error localized string "Please select only one document or group, then try again."
	
	-- Get and format the data we need
	set pLocalizedPrefix to localized string pPrefix
	tell application id "DNtp"
		set thisItem to first item of thisSelection
		set theSummary to (pLocalizedPrefix & ": " & name of thisItem) as string
		set theURL to (reference URL of thisItem) as string
	end tell
	
	-- Let the user choose the reminder list
	tell application "Reminders"
		set theListNames to {}
		repeat with theList in the lists
			set theListNames to theListNames & {name of theList}
		end repeat
	end tell
	if (count of theListNames) = 0 then error (localized string "Please set up at least one list in Reminders.")
	-- set theChoice to choose from list theListNames with title (localized string "Choose list") default items {item 1 of theListNames}
	-- CHANGE ITEM NUMBER to put reminder in different reminder list
	
	set theChosenListName to item 1 of theListNames
	
	-- you can change the reminder date/time here - change weeks to days or hours, change the number of weeks or hours. The 28800 bit is (60 s * 60 min * 8h) to make 8 o'clock
	set theDelayValue to (1 * weeks) + 28800
	-- Calculate due date
	
	set theDueDate to (date (date string of (current date))) + theDelayValue
	
	-- Add new to do to Reminders
	tell application "Reminders"
		tell list theChosenListName
			--Create new to do
			if theDueDate ≠ "" then
				set theEvent to make reminder with properties {name:theSummary, remind me date:theDueDate, body:theURL}
			else
				set theEvent to make reminder with properties {name:theSummary, body:theURL}
			end if
			show theEvent -- Show new to do item in Reminders so that the user can edit it right away
			activate
		end tell
	end tell
	
on error errMsg
	
	display alert (localized string "Error when adding item to Reminders") message errMsg
	
end try

This script will add a reminder to the Reminders app for one week from now, at 08:00. If you put it in an appropriate smart rule it should do what you want. If it goes out and makes coffee and boils an egg, however, I cannot be held responsible (but it works here for me).

(as I said, somewhat quick and dirty, there are a few more lines of code which could be cleaned up)

It would be possible to add a failsafe to this: if you were to set up custom metadata (e.g. called “RemSet”), then the script could e.g. set RemSet to 1 and not set up another reminder for that document so long as that “1” remains. That would reduce the risk of setting multiple reminders for one document (that’s especially important if you can’t narrow down your smart rule suitably)

I appreciate the work but I don’ think I have the knowledge to get this working. I pasted it into the embedded edit script area but I don’t know if it should go within the existing script or replace it.
And when I paste it in it doesn’t color code. I don’t want to take up your time with this. But I see I am missing some basic knowledge of scripting in DT3.

John

Turns out nor do I :wink: the embedded script can’t handle the date command (oh, yes, I remember). I’ve “cleaned up” and simplified the script now and attached it here zipped. You need to unzip it, and then add the script file to DEVONthink’s (DT) smart menu script folder like so: in DT click on the script icon in the menu (it’s on the left of the Help menu); select “Open Scripts Folder”; it contains a folder “Smart Rules”; drop the script in the folder “Smart Rules”.

Now when you set up a smart rule and as the action select an external script, you will be able to select our new script called “Auto-Add as Reminder” from the dropdown list.
Whether or not you use both the internal and external reminders is up to you of course. Your smart rule can run both scripts.

I have actually tried all those steps now, and it works for me. Sorry for not having tried the previous script embedded, then I would have noticed myself that it wasn’t going to work without modification.

As I said, your rule needs to make sure it only runs on each file once (otherwise you’ll have lots of reminders…); if you set up a custom metadata (DT preferences/Data; I’ve called mine “IsReminderSet”), then you could set your rule to look like this:

Obviously, you might want to change on which group the smart rule acts. You might want it to trigger “After Synchronisation” if you are adding items to the group with DTTG on iOS. As a one-off, you may also want to set the “IsReminderSet” to 1 with a smart rule on all files already in the folder which is acted on by the smart rule, just so as you don’t get reminders for that which is already in there today.

If you open the script, you can change both the point in time of the reminder (currently one week on the future at 08:00) and the reminder list - both parts of the script are marked with a comment. Note: DT caches the scripts on startup, so any changes you make to the script aren’t reflected until you restart DT.

Auto-Add as Reminder.zip (5.9 KB)

Try it out - again, I’m not going to be responsible for the script taking meth and playing loud music, but it’s not done any harm here :smiley: Let me know if you run into any problems.

And thanks to all those who have helped me code these past few days - the great thing about knowledge is we all have differing degrees and selections of it, and can share and help out.

As homework, you could try and integrate writing to metadata into the script - that way the metadata bit would only be set if the script is actually successful - currently, if it failed with an error, then the bit would still be set, and the script wouldn’t run on that file again (which in practice probably actually won’t be a problem).

2 Likes

I’m aware I’m interweaving with the AppleScript approach of @blanc, but nevertheless I have the idea you might be putting the cart before the horse somehow.

It’s always difficult to understand someone’s workflow without actually seeing it, but coukd you explain what happens in what order? You use Daylight, Reminders and DTTG, and sync the latter to DT, correct?

So you’ve just been triggered/asked to do something, but you don’t want or cannot do if right now. So you set a reminder somewhere and that apparently references information you can store in DT/DTTG but not in Reminders.

How do you set the reminder currently?

I completely agree with your sentiment - always ask the workflow first, and then offer support for that workflow. I’m just enjoying coding to be honest - and the original question included the words “script” and “automate” :smiley:

2 Likes

Well, I’m pretty impressed with the speed at which you accomplished that to be honest :+1:

I also perfectly understand the need to quickly reference some information when reviewing or performing a task as @Johncesta mentions , but I use a DT(TG) UUID to do that. A UUID is portable between DTTG and DT, as are the tasks in Reminders if you sync them over iCloud.

In short I use one app to do task management (although I personally don’t use Reminders) and one app to store/reference information, and have them reference each other with a UUID or URL-scheme where necessary. That puts most things in one spot and declutters my workflow considerably.

I lose interest in things if they don’t move quickly enough (making me useless at some tasks, I must admit) :see_no_evil: It took me an hour yesterday to figure out how to send a document path to another application in one of my scripts, so I’m still struggling with the basics, really.

The script for John adds a link (x-devonthink-item) to the document in the reminder, so in that sense it’s similar to what you are doing, if I understand you correctly. That link is also displayed in Reminders in iOS, but is not a valid link there, unfortunately. What is lacking is a link back from the document to the reminder. Anyhow, it’s nice to see how ppl are doing things, picking up ideas here and there and then shaping things into a personal ideal - which is why it’s great if a bunch of ppl chip in on threads like this one (I hope @Johncesta agrees :D)

I just pasted x-devonthink-item://UUID in Reminders in iOS (the URL field) and that opens the corresponding document in DTTG.

Wouldn’t it be possible to search for that reminder with a Shortcut that is passed the DTTG UUID? That reminder can be opened with some URL-scheme x-apple-reminderkit://, but it requires the UUID of the reminder to open it. I’ve never used it, so I’m not sure how one obtains that.

DTTG UUID > Shortcuts > Search Reminder containing > Open reminder

But if one uses Reminders or any other app to handle the task status, I don’t immediately see a need for DTTG to open the reminder. Hence the question what specific steps are taken in @Johncesta‘s workflow.

That works - but it’s not scriptable; ie it is possible to send the link to the body of the reminder, but not to the url-field of the reminder - Apple seems to have forgotten that property (at least, it’s not in the dictionary). And whilst macOS recognises the link as a link even in the body of the reminder, iOS does not… woohoo.

That might very well be one of the reasons I personally don’t use the Reminders app for my reminders :slight_smile:

My challenge is that the application I want to use is called Daylite. It can sync reminders from apple reminders. So apple reminders is used as a bridge to Daylite.

If I can use reminders than I can sync my reminders to almost any other calendar or todo application or PIM on the Mac that I like.

Yea, one needs to copy the url an move it to the URL field.

I want to start using daylite. And I also want to start using dt3 and dittg again. But I need to get my tasks in ddtg and dt3 to daylite since daylite has the more total encompassing display for todo, calendar, notes etc. (not the best notes really but dt3 will take care of that.)

So in dt3 while I can 1) make a note 2) use the built in script to send it to reminders,
I may forget and all is gone or lost.

So it would be convenient if I could create a note in dt3 and save it in my TASKS group and have that note automagically become a reminder in apple reminders.

The iPhone is different. On the iPhone and iPad I have to create tasks and todos directly in apple then review them and continue the work with saving letters and pdfs and things in DT3

Thanks all for participating,

J

“My” script in this response will do exactly that for you if you set up an appropriate smart rule :relieved: you could even set it up to run e.g. hourly so long as you use the rule format I suggested (setting a custom metadata “bit”) in the same response. Let us know whether it works for you :slight_smile:

working on it now. Have run it and the 32 tasks in the inbox have moved to the smart rule’s folder.

haha

trying now to modify the app for my tasks and quotes group is where it will look.

oh now I get it. The smart rule needs to be modified to change the group. cool.

So as I see it, when I add a note into my defined group that note is sent to this group as defined by the smart rule.

image

how long do they remain in that folder? Are they supposed to become tasks in the Reminders app?

Thanks

I don’t have a preferences/data section?