Connecting Omnifocus tasks and Toggl time entries via API


#1

I posted a question related to this a few days ago (Security permissions & CURL ) and ended up resolving the problem by using AppleScript (which didn’t have any issues) instead of JXA. I refined my scripts and ended up with two scripts that work VERY well if you want to link Toggl and Omnifocus. You can find them here: GitHub - Omnifocus Scripts.

The Start Toggl Task and Complete Toggl Task integrations are a pair of scripts that can be run from within Omnifocus to start and stop Toggl time entries connected with the Omnifocus task selected. Both scripts require you to enter your Toggl API (found within your account preferences) on the first run. Complete Toggl Task also requires jq to be installed on your system. This can be easily installed with brew install jq.

Start Toggl Task uses the selected task in Omnifocus and starts a Toggl time entry. The Omnifocus task ID gets recorded as a tag in Toggl to enable completion of the task, and a second tag “omnifocus” gets added to allow reporting on all Omnifocus tasks tracked this way.

Complete Toggl Task looks for the active Toggl time entry, and if it has an “of_” tag, then it finds that OmniFocus task and marks it complete. It also updates the estimated minutes in Omnifocus with the duration from Toggl. Finally, it removes the “of_” tag from the time entry.

Hopefully, these are of use to others here. Feel free to take and change; I’d love any suggestions or ideas to make these better.


Tracking/Timing Tasks : My Dream OF/2 Functionality
#2

This sounds outstanding! I can’t wait to play with it in a couple of weeks.


#3

These scripts have been updated to include linking Toggl projects with Omnifocus projects. GitHub - Omnifocus Scripts. For me, this makes time tracking within Omnifocus very easy; I select the task to work on, click the Start Toggl button on the Omnifocus toolbar, and it then associates it with the correct project in Toggl and starts a time entry. When finished, I click the End Toggl button in Omnifocus and it will stop the timer and mark the task complete. For the most part, this eliminates the need to even have the Toggl app or website open—I only need those if I want to add additional tags to the time entry.

Also—if you’re an AppleScript or command line geek, and work with JSON driven APIs at all, you’ve got to check out jq. It is an amazing utility.


#4

Thank you so much! I was able to change the script to my workflow (Omnifocus contexts -> Toggl projects), and with a few changes, it works perfectly.


#5

Hi Samuel,

having a Toggl button for Omnifocus is a great idea, thanks for your scripts!
As reported here, using the correct API throws the Error retrieving lists window for me. What would be the best way to troubleshoot this?

Thanks for any & all advice!


#6

I’m not entirely sure why it iss throwing this error, but I’ll take another look and see if I can debug it. Just to confirm, you do have at least one project in Toggl?

Thanks for the feedback!


#7

Hi Samuel - all thanks to you! The script suddenly worked today. I’m not sure why. I’ve had one different error after, but haven’t seen it anymore after a few more tries. Hurrah!

For future roadmap: I assume that making the script work with Toggl’s built-in Pomodoro breaks is going to be a headache, correct? Kind regards, E.


#8

Glad it is working. I’m not sure why some of the errors have been happening.

And yeah—I’m not eager to integrate the pomodoro breaks. I actually don’t use them in Toggl; I just haven’t found Toggl’s implementation to be an effective tool. When I do use pomodoro, I use a different app or (more often) a physical timer.


#9

Hi guys,

I’m new to using scripts with Omnifocus - how do I install these scripts? I’ve put all the files in the Omnifocus Scripts directory but don’t see those Toggl buttons in my Omnifocus app (Mac).

I’m running the latest High Sierra and Omnifocus versions.


#10

I have the same question as @uriah“I downloaded the files, now how to I get them running in OF?”

Homebrew and jq are both current on my machine, I pulled the root folder from the repo and placed it in the dir found using OF Help > Open Scripts Folder.

@samuelkordik could you point us in the right direction?

Is there some kind of init that needs to happen beyond just placing the directory + files?

Super excited to connect OF and Toggl! :D


mp


#11

@uriah,

I moved all the contents of the .zip into the root OF Scrips Folder (Help > Open Scripts Folder), previously the Toggl scripts were in the folder OmnifocusScripts-master.

After that, right click on any toolbar icon (or menu > View) choose: Customize Toolbar.
You should see the new Toggl options there. Drag them into your toolbar.

If they’re displaying without the custom Toggl icons, follow this comment from @johnsidi for fixing icons on MacOS.

I’ve been able to successfully run the Start Toggl script and choose a Toggle project now, however running into a known error which is documented on the repo here. I don’t have any empty Toggl workspaces, a suggested fix proposed by @chase-dwelle.

If/when I’m up and running I’ll check back.


mp


#12

Hi @pikemilsner thanks a lot - it’s working in Omnifocus 3 Beta!


#13

Weehoo! :)


#14

Really enjoying this! Thank you for it!


#15

Just found this absolute gem of a script, all installed and setup.

I can start a timer and it appears in Toggl but when I try to stop it I get this error in OF:

Running time entry in Toggl not linked to Omnifocus task

Any ideas as to what is going wrong?


#16

What’s the difference between Complete and Complete Toggl?