---
title: "First Time Node.js or: How I Built a Simple Instant Message API in an Evening"
description: "With the news that Tropo is shutting down their instant messaging API, we're in a pickle. We're already using IM to get instant notifications of the things that are important to us internally, and we have a bunch of people using it too."
image: "https://images.ctfassets.net/lzny33ho1g45/1q3004JsPW2uepoZ1xdoIr/fa0b282eb9d41b3a7221e14d0b00f72c/Group_14894.jpg"
---

# First Time Node.js or: How I Built a Simple Instant Message API in an Evening

With the news that Tropo is shutting down their instant messaging API, we're in a pickle. We're already using IM to get instant notifications of the things that are important to us internally, and we have a bunch of people using it too.

With the news that Tropo is shutting down their instant messaging API, we're in a pickle. We're already using IM to get instant notifications of the things that are important to us internally, and we have a bunch of people using it too.

But now what? Well, we do what any self-respecting software engineer does: **we build one ourselves!**

## Project requirements.

All we really need is the ability to send out notifications via OSCAR (which is [AIM]()) and Jabber (which covers [GTalk]() among others). That makes it a lot easier to get started, as we won't be worried about that nasty back-and-forth logic that is the hallmark of a bot. Its just one way, out.

Further, we need to be able to interact with it via a simple REST API, that way we can plug it in along side the dozens of other [services we natively integrate with](https://zapier.com/apps). Not that complicated it would see.

## Choosing the tech.

I'm used to Python and Django, so my first though was Twisted, a non-blocking server written in [Python](https://zapier.com/blog/python-automation). As I started to dig around, I noticed that Twisted is no lightweight beast. The XMPP (Jabber) and AIM protocol was there with Twisted Words, but it wasn't the cleanest. It would probably work, but I was fighting it and the learning curve was steep.

So I explored some of the other options like Ruby's EventMachine and Node.js. EventMachine seemed awesome (I'm a bit jealous it isn't a Python project...) but my Ruby chops are horrible. That would have ended in frustration.

However, Node.js had promise. I mean, I know Javascript fairly well and there were plenty of libs to handle OSCAR and XMPP. So I thought, "Why not?". I figured I would just spend a couple hours and see if I want to use Node.js to build it. Away I went...

_Spoiler: those couple hours I set aside to learn Node.js left me with... a finished product. _[_Wow!_](https://twitter.com/#!/bryanhelmig/status/164546347201073152)

## Getting started.

First thing was first: install Node. I'm on a Mac, so using brew: `brew install nodejs`. As always, brew made that easy. I had known about npm, the pip of the Node world, so I installed that too according to their docs: `curl http://npmjs.org/install.sh | sh`. Easy.

Let's try something that I am familiar with: a single endpoint API. Easy, right? So, having heard of the Node web framework _express_ at a talk given by local good fellow [James Carr](https://twitter.com/#!/jamescarr), I installed it globally (assuming that meant system wide): `npm install -g express`. Easy again.

I also wanted to use Coffeescript, so using coffee script (which apparently is the new hotness) `npm install -g coffee-script`. Easy again. After that a simple command compiles to js: `coffee --watch --compile index.coffee`, which you run with node: `node index.js`.

_Disclaimer: I had used Coffeescript before, so my Node virginity isn't as pure as I've suggested._

## The build.

Then I just followed the express docs to get something logging to the console (baby steps, right?):