Sunlight Foundation Launches Two Twilio-Powered Apps to Help Prepare You for Election Season

June 18, 2012
Written by
admin
Contributor
Opinions expressed by Twilio contributors are their own

Twilio Bug Logo

Election season is upon us! As we inch ever closer to the voting booth this November we’ve already begun to see a large number of civic-focused apps, to help inform, educate and empower citizens. Just a couple of days ago, at the Personal Democracy Forum in NYC, members of the Sunlight Foundation took the stage to announce two new, very exciting, Twilio powered apps to the public and I was lucky enough to have a front row seat for the unveiling.

The Sunlight Foundation is a non-profit, nonpartisan organization that uses the power of the Internet to catalyze greater government openness and transparency, and provides new tools and resources for media and citizens, alike. Two new tools they’ve debuted at PDF are Scout and Call on Congress. Scout makes it easy to stay on top of what’s happening in government. The app provides a search and alert service to notify you whenever issues you care about are included in legislative or regulatory actions. Sign in, subscribe to things you care about, give it your email address or phone number and you’ll get an SMS any time there is an update.

Call on Congress makes connecting to Capitol Hill as easy as ordering pizza. By dialing into 1-888-907-6886 you can access a wealth of data, including finding out how your representatives are voting on bills and raising campaign money. This is especially signifcant, since certain portions of the population may not have or be comfortable with accessing information on the internet. This allows them to access information and connect to lawmakers using a comfortable phone interface.

How did they build it? We caught up with the developers of the Call on Congress app, Sunlight Foundation’s Jeremy Carbaugh and Dan Drinkard to talk about the tech behind the Call on Congress app.

Sunlight Foundation's Jeremy Carbaugh

What is Call on Congress?

Call on Congress is the Sunlight Foundation’s new free service to help anyone with a telephone connect with and learn about their lawmakers. Simply dial 1-888-907-6886 to find out how your representatives are voting on bills and raising campaign money and learn about upcoming bills in Congress.

To date, a computer has been required to access Sunlight’s web sites and data offerings. And while computer use and access to the internet is ever increasing, there is still a significant portion of the public that don’t have access to these resources.

What role does Twilio play in the Call on Congress app?

The service is built on top of the Twilio API that enables us to create interactive phone and SMS applications. Users can navigate through a series of menus, be connected directly to the office of their representatives, and even leave us voice messages.

I can’t express how awesome it is to work with Twilio. It is incredibly easy to do things that would otherwise be quite difficult to create. We can create dynamic responses that are spoken back to the user using Twilio’s text-to-speech feature. We can have recordings of a spoken script play for static content or even play music, if we had the need. We can even forward phone calls so that users can be connected directly to the office of their representative without having to write down the phone number and dial the call.

While Call on Congress primarily uses Twilio’s voice features, we used SMS on our other new service, Scout.

I hear that there’s also some other cool technology behind Call on Congress?

Yes! Call on Congress is also one of Sunlight’s first multilingual projects. The service is available in English, Spanish, and Esperanto… yes, Esperanto. This posed some unique challenges as we had to deal with both a static spoken script and dynamic text that would be read using Twilio’s text-to-speech feature.

Dan created an amazing, multitiered solution for this problem. Each bit of text used in the application is run through a series of steps to determine the proper response. All of the text is written in English is the code, but is internationalized by:

  • Creating an MD5 hash of the text
  • Determining the response language
  • Checking for a cached translated copy of the text if it is not in English
  • Generating a translated copy of the text using the Google Translate API
  • Generating an audio file name based on the MD5 hash and a slugged chunk of the text
  • Doing a HEAD request to S3 to see if an audio file exists for the chunk of text
  • Responding either with a Twilio command using the translated chunk of text or a Play command with the S3 URL of the audio file, if one exists

This method allows us to basically drop in new languages as we create the audio for them. We can launch a new language and have Twilio’s text-to-speech render the Google translated text until we drop language audio files into the application.

Dan is smart.

Dan is Smart

Your use of APIs is truly awesome, and you guys also have APIs of your own, right? Can you tell us some more about the Sunlight APIs?

One of the most exciting aspects about this project, at least for us internally, is that almost all of the features of this service are powered by our existing APIs:

Our friends at TurboVote are responsible for the API that allows us to provide information about local election offices.

Call on Congress is a great example of what can be done using our API offerings. We were able to create this application without having to do any scraping or collecting of data of our own. In fact, it’s a great example of what can be done entirely with APIs. Call on Congress is nothing more than a cache and the logic that combines the Twilio, Google Translate, and Sunlight APIs into a single application.