I like Habitica a lot. I find that it’s good at directing my attention and motivating me to do things that are aligned with my goals1. I also use Rescue Time, it’s job is to tell me what I really do with my life. It stops me lying to myself about what my days look like.

10h 20h 30h 40h 10h

This graph is my productivity over the last 6 months. (As reported by Rescue Time.) It’s inaccurate because it mostly isn’t tracking my laptop2, but as I do most of my unproductive time in phone and tablet land it’s probably well recorded there.

I’ve tried manually inputting habits in the past. If I worked well for an hour I’d give myself a point. But if I was really working I’d forget to put in the point, and if I was actually just barely working I’d remember. Generally reinforcing the wrong habit.

Enough intro, onto the nerd stuff!

IFTTT and Zapier both have a connection to Rescue Time. They both have a way of emitting cURL commands too. IFTTT through the Maker channel and Zapier through webhooks.

That means that if I do something in real life then I can be rewarded or punished in Habitica land.

zaps

I’ve started off with a reward for reading. I get a point for each time I accrue 20 minutes of reading a kindle book or articles in Pocket.

How do I unlock this sorcery?

I’ll do this for Zapier because it’s easier to test, but the same holds for IFTTT3. You can also swap out Rescue Time for any other trigger too. So if you want to get a reward when you go into the gym’s geofence then you can.

Obvious stuff: get a Zapier/IFTTT and Habitica account.

You are going to need to get your Habitica API details; they live here. (The User ID and API Token.)

Once you’ve got your ingredients all ready then you can get going!

Pick something you want to be rewarded (or punished) for. Something that Rescue Time tracks. Then make a custom subcategory for it.4 Then set a new goal.

goal

Set it to the category you want and then how long you need to spend doing it before the trigger fires.

You’re all done in Rescue Time now.

Go to Zapier and make a new Zap.

zap1

Set it to be triggered by your goal.

zap2

Now for the voodoo part. There is a good page on the Habitica wiki that explains everything I’m about to say. I was having a severe stupid when I was reading it, so in case my words are useful, then here they are.

The call to the API is a POST like this:

https://habitica.com/api/v2/user/tasks/read20minutes/up

The bit in red is the name of the habit. (Multiple triggers can aim at the same habit.) The green bit is either up or down depending on where you want your score to go.

That goes into the URL field.

This is the part that I spent all the time on. Your authentication details go in the header, not the body. That’s right at the end of section 5. Make 2 new key, value pairs with your details.

keys

That’s x-api-user: xxxxx and x-api-key: xxxxx if you are playing along at home.

That’s it! don’t change anything else and you’ll be just fine.

Test it in step 6, name it in step 7 and away you go!

When you test it you should see a new Habitica habit show up. Then if you test it again it’ll go green. (Unless you’re a punisher and you picked down!)

And that is that.

If you have any clever ideas for other things to join up then let me know. I’m a total sucker for this stuff.

  1. i.e. it gets me to do things that the good version of myself thinks are useful. The things that–given some time to think about it and plan–I would want to be doing. 

  2. Rescue Time for Linux is a process that you need to start manually. I’m sure that’s the Linux way, but it’s super annoying. “Just make a startup script” sure, one day. 

  3. Now that I’ve got it working, I’d actually make it in IFTTT, Zapier is pretty crippled unless you pay real money for it. 

  4. You can put other activities into that category if you want them measured on the same timer if you like.