Choosing My First Drink With SendGrid, Foursquare, Node.js and Socket.io


Posted on

I turned 21 on Saturday at PayPal Battle Hack NYC. Not being from the city, I wanted to find out where to go to get my first drink. I knew I had a chance to get up and speak at the beginning of the event, so I decided to create an app to help me figure out where I should go Saturday evening. I’m sharing it here in case you ever find yourself in a strange city (21st birthday or not) and want to find out where to go eat or get a drink.

The app is built on Node.js with the Express framework. It displays a list of nearby venues, grabbing my location and venue information from Foursquare and then uses SendGrid’s Parse Webhook to gather votes for the best place to go.

Foursquare

I integrated with Foursquare to find the five bars closest to the event. Not knowing precisely where I was going to be, I also pulled my last Foursquare checkin to figure out where I was.

SendGrid

To gather votes, I used SendGrid’s Parse Webhook. This webhook has SendGrid’s servers process emails your app recieves and then POST them to your server. I asked Battle Hack participants to email me with the venue’s letter (A-E) in the subject.
To setup where the webhook should POST data to, go to the Parse Webhook section of the SendGrid control panel. Enter your app’s information (namely to POST data to YOURDOMAIN.TLD/email), point your MX record to mx.sendgrid.net and you’re good to go! (Keep in mind DNS can take up to fourty-eight hours to propagate.)

Socket.io

Finally, the frontend needs to tally votes, to do this it needs to recieve information from Socket.io. This data is then processed and tallied.

Tying It All Together

Once everything is connected, there’s one part that’s missing: the frontend look and feel. That’s not included in this article, but you can see the full working app on Github.
In the end, the nice folks at Battle Hack sent me to Top of the Strand, which was far too classy for my startup-tee-clad 21st birthday.
Photo by Maura Teague


Nick Quinlan is a SendGrid Developer Evangelist based out of San Francisco. He works to make developers lives easier by providing them with the help they need to grow their ideas. Give him a shout, @YayNickQ.

Nick Quinlan on Twitter
Have thoughts on this post?
Chat with us about it on Twitter and Google+