Sync Fitbit workouts to Toggl

Published: 9th of October 2018. Estimated read time about 3 minutes.
Categories: (How to) (Productivity) (Toggl)
Sync Fitbit workouts to Toggl

Fitbit to Toggl

I'm a big fan of data, any kind of chart or visualisation about even trivial datasets get me pretty interested in the subject matter really quickly. No surprise then that r/dataisbeautiful has been one of my favourite time killers ever since I stumbled upon it.

workouts this year chart

Some of the most interesting data we have is about ourselves, or at least that's how I see it. I've been tracking my personal productive time on Toggl for about a year now and it has been really interesting seeing how my productivity and interest in certain topics ebbs and flows.

Throughout all this time I've been wearing my Fitbit 24/7, because I really like the data it gives me about my general fitness and efforts to keep myself somewhat in a shape that doesn't look like a circle.

Workout stats for the year

Talking to my buddy Daniel this morning he told me he has a way to combine Toggl projects into "buckets" (as in groups) and he has been toying around with the idea to orientate his goals in a way which matches these buckets. I mentioned that I like having fitness as something that is in its own bucket, as for me it helps keep me energised. I also immediately realised I've got no tangible display of my efforts other than the Fitbit heart rate chart (as wonky as it is).

Wait a minute, a while ago I set up a Function as a Service (FaaS) on webtask.io that runs on a schedule to help get me out of bed in the morning (also credit to Daniel for the idea).

I have previously set up a Fitbit API cache server in Dotnet Core so I know I can get my workout data from their API, what if I set up a Webtask function to run every night and sync my daily workouts to a Toggl project?

It would be really easy.

Sync Daily workout data to Toggl

All you need to get this going is:

Webtask editor

Once you have all of the above go ahead and add the code to a new Webtask function on https://webtask.io/make, then we need to set up some environment details.

First, make sure you add the following Secrets and enter your corresponding API keys and project ID.

secrets

FITBIT_API_TOKEN
TOGGL_API_TOKEN
TOGGL_PROJECT_ID

Then we need to make sure to add the following NPM Modules.

modules

[email protected]
[email protected]
[email protected]

You could probably use different versions if you really wanted to.

Give it a go by pressing the play button for the Runner, check your Toggl to confirm that it worked. Great stuff!

Now let's set it up to run on a schedule.

scheduler

I like to have mine run at 11 pm each night, feel free to change to what best suits your needs. Remember it only syncs workouts from the day that it is run on.

Sync all workout data for the year

Now you might be telling me "Hey Jacob, that's really cool mate but how do I add all the workouts from the past year?". Well, I'm glad you asked such an oddly specific question, let me show you how.

dotnet core runner

First clone this Dotnet Core 2.1 app from the GitHub repo.

Open it up in Visual Studio and update the "Secret" variables at the top, the same details you used for them on Webtask will work here. With that done you can start it and watch it sync all the workout data you have for the current year.

If you found this useful come give us a star on Github and share your ideas.

Thanks for stopping by.

Recommended Posts

Back to top ⇈

This website runs on 100% renewable energy 🌳