iGoogle Gadget for Backpack Reminders

A little while ago, I toyed with the idea of creating an iGoogle Gadget for Backpack Reminders as a fun experiment. As far as I can tell, basic reminder creation functionality works reliably, so I figure I’d share it.

To try it out, you’ll need a Backpack account and a customized iGoogle page. Getting a basic iGoogle page is easy enough, but I’ll point out that after you create a Backpack account you’ll need to grab your API key. (After logging in, click the My Info link towards the upper right, then scroll all the way down to the Backpack API Key section.)

With your Backpack username and API key handy, you’re ready to add the gadget to your iGoogle page.

  1. Go to your iGoogle page.
  2. Click the Add stuff link towards the upper right.
  3. Click the Add feed or gadget link towards the lower left.
  4. Paste this URL (http://rossbelmont.com/google/backpack-reminders.xml) into the text field and click Add.
  5. Click OK in the security warning popup. (This gadget only stores your data on Google’s servers.)
  6. Click the Back to iGoogle home link towards the upper left and notice your new gadget on the page.
  7. Paste your Username and API Key into the text fields and click Save.

This will be a lot more fun if you’ve already created some reminders, but if not you can create some right there inside the widget. If you’re interested in how this was built, read on.

How this Gadget works

Creating the Gadget was an interesting exercise. Google provides a web-based editor to code/test/debug these little guys, which is both cute and limiting at the same time. Also, the Gadget is defined in an XML file, so in this case there’s a bunch of JavaScript code actually inside the XML. If you want to look at the code, just open the XML file in your favorite text editor.

To actually create a reminder, an HTTP POST is necessary due to how the Backpack API works. The Gadget API can only perform GETs as of this writing, so I wrote a small bit of PHP (code here) to handle this. (If you’re paranoid, you’ll note that your Username and API Key are stored by iGoogle and only passed through the code.) I was considering using jQuery to POST within the Gadget and avoid running anything on my own server, but unfortunately the AJAX-iness of iGoogle Gadgets doesn’t seem super-robust. Sometimes PHP just works.

Anyway, I hope you like it.

RSS feed of Backpack Reminders

I thought it might be fun to get my Backpack Reminders syndicated as an RSS feed, for easy sharing outside of a calendar. So, I whipped up a little Rails app to do just that.

How can I use this for myself?

This requires that you have a web hosting account with a provider that supports Ruby on Rails. If you’re in the market for one, I’ve been really happy with my experience at Joyent.

The other thing to watch out for here is security. You don’t want anyone who can guess the URL to be able to read the feed. So, I embedded a security token in the URL that is “unguessable” for all intents and purposes. Also, I avoid storing that token in the source code in clear text by using a standard encryption algorithm.

To use this, the steps are more or less as follows:

  1. Download the Rails app.
  2. Edit the file app/controllers/feed_controller.rb to include your Backpack username and API key.
  3. Choose a security token to be embedded in your feed’s URL. In this example, let’s pretend it’s mytoken.
  4. Generate the SHA-1 hash of your security token. On a Mac, this can be done in Terminal with echo -n mytoken | openssl dgst -sha1. Put this value in the appropriate spot on line 6 of feed_controller.rb.
  5. Change the text blurbs in app/views/feed/rss.rxml to pretty-up the display of the feed.
  6. Upload the Rails app to your web host and test the URL. It should be something like http://myhost.com/reminderfeed/feed?sectoken=mytoken.

How does this work?

The Backpack API makes it a breeze to access your reminders in Ruby, and Rails makes it easy to serve an RSS feed. This is basically the minimum amount of glue need to connect the two. If you’d like more details, the files of interest are app/controllers/feed_controller.rb and app/views/feed/rss.rxml.

If you look at rss.rxml, you’ll notice that I ran into a time zone gotcha because my web host is in a different time zone then my Backpack. If anyone has suggestions on how to improve this, please leave a comment and get in touch.

Create Backpack reminders via e-mail/SMS

It’s no secret that I’m a huge fan of Backpack. And though it’s great to store all my miscellaneous info and personal mini-projects in one central location, I’d forget to do anything without Backpack’s reminders feature. It’s simple and it works beautifully.

The one problem I have with Backpack reminders is that I almost never think of the things I need to be reminded about when I’m sitting at a computer. So, what I’ve done is whipped together a quick Rails app that gives me the ability to create Backpack reminders via e-mail or SMS. Here’s how it works:

  1. Realize that you haven’t called Aunt Betty in a while.
  2. Whip out your phone and type call aunt betty sat aft into a new text message.
  3. Send the message to “remindme@mydomain.com”.
  4. The script I wrote picks up the message and sets a Backpack reminder for Saturday at 2pm with the text call aunt betty.
  5. Go about your business until Saturday afternoon, when your Backpack reminder fires off, and alerts you either by e-mail or SMS.
  6. Call Aunt Betty and stop feeling guilty.

You can use any e-mail program to send a reminder message to the “remindme” address, which is handy when you’re in front of a computer. The SMS example above relies on the feature most cell phones have in which a text message sent to an e-mail address magically “becomes” an e-mail.

You can enter the date and time in either order. Here are some other examples:

  • Call Dave (reminds you in three hours)
  • Pick up dry cleaning 5pm wed (time comes before date…that’s OK)
  • Make doctor's appt tom (reminds you tomorrow at 9am)
  • Pick up dinner 5pm (reminds you today at 5pm)
  • Send in taxes 4/15 9:30am (You do pay your taxes, right?)
  • Report for active duty 9/1/07 15:00 (Sept 1st of next year at 3pm)
  • Post files soon (reminds you in 10 minutes)

Those of you that use Backpack reminders already will recognize morning and afternoon corresponding to 9am and 2pm, respectively. I also added the keyword of night (or nite or even nit) to translate to 6:45pm. Call Dave later will work the same as Call Dave, reminding you in three hours. I also added soon to remind me in 10 minutes because you’d be surprised how quickly something flies out of my brain. Finally, you can enter the input text into the subject line of the e-mail or the first line of the body itself.

How can I use this for myself?

This is the tricky part. Essentially, you will need a web hosting account to make use of this. The script is written to work with my (awesome) host, Joyent, which can be configured to call the script when an e-mail comes in and feed it the message. This is definitely the most reliable way to do this and I highly recommend it.

If that doesn’t scare you, just download the Ruby script and configure your web host to launch it when an e-mail arrives at a certain address. In my case the message is passed to the script via good ol’ STDIN.

How does this work?

The parsing was not that hard, really, because Ruby’s such a cool language and has so many great features baked right in. This definitely would have been a bigger pain to write in Java, severely reducing the fun factor. Also, I’ll note that this took me about a week of nights and weekends to put together, and I’m not a Ruby expert.

I need to give credit where credit is due and point out that this was possible to put together because the good people at 37signals have released a really nice API for Backpack. But, more than possible I’d say it was easy to put together because they went one step further and created a sweet Ruby wrapper that made the Backpack calls drop-dead simple. The only way they could have been better is to add this feature into the official Backpack product and render my silly hackery irrelevant. (Hint hint!)

One gotcha: since there’s no way to determine which time zone your Backpack is in through the API, you may have to hard code some stuff in there to offset if your web host is in a different time zone than you.

Happy Backpacking!