My name is Joël, I recently joined the Developer Evangelism team at Twilio. The main reason I joined Twilio was because it gave me the chance to help developers, which is one of the things I love to do.
What I didn’t expect when I joined was that I would have so many opportunities to make a meaningful impact so soon after starting.
One of these opportunities was a project where I helped the Utah Foster Care Foundation. For the past 10 years, the Utah Foster Care Foundation has held a Chalk Art Festival to “shine a spotlight on the needs of Utah children in foster care [...] and raise funds that benefit these deserving children and families. “
Recently, this festival has included a People’s Choice Award that allowed festival visitors to vote for their favorite entry via SMS. Naturally, this is where Twilio becomes a perfect fit.
Here’s How It Happened
The Utah Foster Care Foundation sent an email to firstname.lastname@example.org asking for an introduction to a Developer Evangelist. They explained that they used Twilio for SMS voting the year before and wanted to do the same thing again.
Initially I thought that we could make use of an existing application to handle the voting. However, as we covered the different options, it became apparent that they had some very unique requirements that other voting applications just couldn’t meet: They were expecting about 125 contestants to participate in 2 categories and the actual number of contestants couldn’t be known until the event started.
What the organizer had in mind was this: allow people to vote by sending an SMS with a 3 digit number, the first digit (“1″ or “2″) would determine the category, the remaining digits would determine the contestant in the category, and multiple votes were okay. After hearing the requirements (especially the one to allow people vote multiple times) I realized that writing the application myself would be pretty easy.
A Little Code Goes A Long Way
I started by forking the Twilio Hackpack for Heroku and Flask, a great set of templates for Twilio applications that run on Heroku.
$ git clone ‘git://github.com/RobSpectre/Twilio-Hackpack-for-Heroku-and-Flask.git’
Next I added a function for the ‘/sms’ route. This is where I would instruct Twilio to send SMS requests to. If the incoming SMS contains a 3 digit number, then I instruct MongoDB to increment a counter for that number and reply to the SMS with a “Thank you” message. If the SMS does not contain a 3 digit number, I reply with a message telling the voter that they need to send just a 3 digit number:
With this done, I wrote a function to allow the Chalk Art Festival organizer to see the voting result by visiting a URL that contains the phone number that is used for the voting. This function takes that phone number from the URL, queries MongoDB for all votes made to that number and then displays the results, sorted by the number of votes. Finally, the results are sent back to the user wrapped in the HTML <pre> tag – which keeps all the votes aligned without needing to use HTML tables or CSS.
Here is what the final ‘app.py’ file looks like:
Then, all that remained was to update the connect string on line 14 with credentials to my MongoHQ database and then run few more commands:
$ heroku create
$ git commit -a
$ git commit -am ‘updated app.py’
$ git push heroku master
This whole process took just under an hour. Once I was done, I showed what I wrote to the Utah Foster Care Foundation. After a few small tweaks to the wording, we were in business!
How did it go? Well, here is the final breakdown:
- Number of votes: 8505
- Peak number of votes per hour: 989
- Number of unique phone numbers that voted: 1288
So with a little code and ingenuity, we had a system that touched 1200 people.
A little code and ingenuity
I see this same sort rapid development and problem solving at an event I help organize called SuperHappyDevHouse. It's exhilarating to see how little projects that start at the event can grow into companies and communities.
Helping organize SuperHappyDevHouse is what helped me realize just how much I enjoy working with people, teaching, solving problems, and rolling up my sleeves to write code. It's how I ended up at Microsoft helping them work with startups in the Silicon Valley (and vice versa) and it's how I eventually ended up working as a Developer Evangelist.
Now I'm at Twilio and I want to help you do great things with our API. I'm based in San Francisco and would love to meet anytime.