Send completed tasks on OmniFocus with AppleScript
Motivation
I have been using OmniFocus as my todo list tool for a while.
I pretty like the application except for API absence.
Unlike modern task management tools like Todoist, or Trello, OmniFocus does not offer APIs to integrate with any third-party tools.
What I want to have with APIs is a weekly report function that lets me know what kind of tasks I have completed within the week.
It might be possible to be done with the GTD review process
, but I wanted to record them somewhere to look back in the future.
Automation with AppleScript
To achieve that, I noticed that there are blogs about OmniFocus automation using AppleScript.
“AppleScript”
Yes, I know the name, but I have never used it.
As you can imagine, I struggled to understand the syntax of AppleScript for the first few hours. However, reading this excellent article, which compares Python and AppleScript, helped a lot to be familiar with the basic syntax.
Here is the script I wrote. I referred a lot to this repo, though.
https://gist.github.com/yayoc/48141089f57dc1d1b1dbfeeebfd64753
The script retrieves completed tasks from OmniFocus at first and sends it to my email account.
Run the script periodically
To review the completed tasks on Sunday, I register it into launchd on my personal computer to run the script periodically. Here is a memo of what I did.
- Creating a plist file, which specifies StartCalendarInterval key, under
~/Library/LaunchAgents
, - Load it with
launchctl load PLIST_FILE
.
As a result, I successfully got an email that includes completed tasks on Sunday, like the below, Yay!
Wrap up
It was my first time to automate workflow with AppleScript. Although I am still not fun with esoteric AppleScript, I am happy that I could understand basic syntax and remove tedious workflow. Probably, I will automate some other recursive tasks later. If you are interested in writing AppleScript, what integrates with OmniFocus, The following links worth reading.
Cheers!