View Single Post
Hi all -

It would be really cool to get Siri to add tasks to omnifocus. Since that won't happen till Apple releases APIs, I wrote an applescript to pull all new reminders from iCal (which gets all of the reminders, synced over iCloud) and adds them to your omnifocus inbox. If you have a computer with ical and omnifocus running, then you can add a task to the reminders app on the phone via Siri, which will sync via iCloud back to your mac, which then gets imported into omnifocus via this script, which I have running every minute via launched. You could probably do it less often... I haven't found that it burns too many cycles on my 3 year old macbook pro. You can set the interval to whatever you want (in seconds) in the launched plist below.

The applescript adds a note to your reminder after it send it to omnifocus, so you don't get duplicates. It leaves the todo in the reminders section of ical as well, instead of deleting it, because I figured it would be nice to have it pop up automatically on the phone later. You could just as easily delete them after transferring them into omnifocus, but then you don't get the cool location and date reminding of the iOS reminders app. I couldn't figure out any way to get at the location information in the particular todos from iCal. Perhaps apple will update the ical applescript dictionary to allow that in the future.

Also, I set the due date in the reminder to the start date in omnifocus. Since I rely heavily on start dates instead of due dates to keep things organized, seemed to make sense. Plus it's in the spirit of the 'Remind me to get the mail tomorrow' spirit of the iOS reminders app.

Set the calendar name on the second line of the applescript to whichever calendar you sync reminders to from your iPhone.

To get launched working running, add the code I have below for omni_siri.plist to your LaunchAgents folder in your user Library and execute
Code:
launchctl load -w ~/Library/LaunchAgents/omni_siri.plist
at the terminal. It should also autoload on startup from then on.

Tell Siri "Remind me to get the mail tomorrow", and soon you will have a new inbox item in omnifocus (on your computer and back on your phone, the next time you open omnifocus on your iOS) with the text "Get the mail" and a start date of tomorrow. Cool!

Best,
naupaka

Here's the applescript.

Code:
tell application "iCal"
	set myRemindersIDS to todo of calendar "Reminders"
	repeat with theTodo in myRemindersIDS
		tell theTodo
			set todo_summary to (get summary of theTodo)
			set todo_due to (get due date of theTodo)
			set todo_description to (get description of theTodo)
			if "transferred" is not in todo_description then
				tell application "OmniFocus"
					set theDoc to first document
					tell theDoc
						make new inbox task with properties {name:todo_summary, start date:todo_due}
					end tell
				end tell
				tell application "iCal"
					set description of theTodo to "transferred"
				end tell
			end if
		end tell
	end repeat
end tell

tell application "OmniFocus"
	synchronize default document
end tell
Here's omni_siri.plist for launchd.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
	<dict>
		<key>Label</key>
		<string>com.myOmniSiri</string>
		<key>LowPriorityIO</key>
		<true/>
		<key>Program</key>
		<string>/usr/bin/osascript</string>
		<key>ProgramArguments</key>
		<array>
			<string>osascript</string>
			<string>/full/path/to/your/scripts/reminders_to_omnifocus.scpt</string>
		</array>
		<key>StartInterval</key>
		<integer>60</integer>
	</dict>
</plist>