Webhook Notification App Lerner Takes Top Twilio Prize at DevFest 2012

March 05, 2012
Written by
Meghan Murphy
Contributor
Opinions expressed by Twilio contributors are their own

Twilio Bug Logo
Developer Zhehao Mao
Developer Zhehao Mao

Last month, Columbia University students embarked on a week of development-focused events around building apps with real-life potential during DevFest 2012. We saw a ton of awesome hacks from the week but one twilio-powered developer, Zhehao Mao, took home the award for “Best Use of Twilio API” with his webhook notification app Lerner. Read more about the top apps developed from the week in this article by TechCrunch.

We had the pleasure of interviewing Zhehao about his app, DevFest 2012, and what’s next for this DOer. Read on for the full interview.

Twilio: How did you get involved with the Columbia DevFest?

Zhehao Mao: I am on the committee of the Application Development Initiative (ADI), the student group at Columbia that organized Devfest. I joined ADI at the beginning of my Freshman year (last year) and was present when the group was formally recognized by the Activities Board in the second semester of my Freshman year. At this year’s DevFest, I was in charge of ordering food for the first hackathon.

T: What was your inspiration for Lerner?

ZM: Lerner was inspired by the concept of webhooks, a general term for when a web service sends an HTTP POST request to a remote server as a notification of some activity. Twilio and Github are two prominent examples of web services that provide webhook notifications. Webhooks are very convenient, in that they eliminate the need for third party applications to continually poll a service to check for new activity. The one limitation of webhooks, however, is that they require a server with a publicly accessible IP address that can accept HTTP requests. I set out to build Lerner because I wanted to allow diverse clients, like smartphones, tablets, and PCs connected to a wifi network, to receive webhook notifications.

T: How did you build Lerner?

ZM: My first step in building Lerner was to decide on a protocol. My criteria for the protocol were

1. Simple and easy to implement
2. Well-documented
3. Lots of available client libraries
4. Extensible
5. Support simple RPC commands
6. Support a publish/subscribe model

I settled on using the Redis protocol, the protocol used by the Redis database, because it fit all of these criteria quite well. So I implemented a server speaking the Redis protocol that could do publish/subscribe in the same way as the Redis database. The server was implemented in Python, using Gevent for asynchronous networking.

After the pub/sub server was done, I had to implement a webserver to take the POST requests for the webhooks. I implemented support for two services, Github and Twilio, and a generic webhook callback that anybody could use. This was done using the Flask micro-framework.

The final step was to write a simple desktop client that would subscribe to the pub/sub server, run in the background, and pop up a desktop notification whenever a message was sent through the pipeline. I use ArchLinux on all my personal computers, so for obvious reasons I decided to write a Linux desktop client. I used libnotify for desktop notifications and the redis-py, the python redis client library, to talk to the server.

T: How does Lerner work?

ZM: Essentially, Lerner consists of three cooperating processes, a webserver, a pub/sub server, and a client. When the webserver receives a webhook POST request, it will process the request and publish the information a channel on the pub/sub server. The client subscribes to a channel (or channels) on the pub/sub server, and when a message is published to the channel, the server will forward the message to all subscribed clients. Since the client subscribes through a persistent connection, they are able to receive these messages in real time without polling and without having to bind to a publicly accessible port.

I made a handy network diagram for my DevFest demo. It’s available at http://zhehaomao.com/images/network-diagram.png.

T: What’s next for you?

ZM: Currently, Lerner only has three types of webhooks and only one client. I would like to see more clients and publishers hooked up to this platform. In particular, I see great potential for Lerner to be used with Continuous Integration platforms like Jenkins, Hudson, or BuildBot, and with server monitoring software like Nagios. I would also like to see clients written for other operation systems, such as Mac OS X, Windows, Android, and iOS. I have no inclination to write all of these myself. Rather, I would like the open-source community to build these things as it sees fit. Hopefully, the fact that I used an existing protocol with many good client libraries would encourage people to build these things.

Thanks Zhehao! Find Lerner on GitHub and for more information on this DOer, follow him on Twitter or check out his personal website.