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.
While Sunlight prides itself on creating powerful, online tools that make government more transparent and accountable, we do so knowing that there is a segment of the public without access to the internet that we will never reach. Call on Congress is our attempt to bring information about Congress to anyone that can use a phone.
The service is built on top of Twilio, a simple cloud communications 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 their service. They have made it incredibly easy to do things that would otherwise be quite difficult to create. We can generate 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.
Twilio also has SMS features that, while not used on this project, are used on our other new service, Scout.
i18n and the Google Translate API
Call on Congress is Sunlight's first multilingual project. 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, multi-tiered 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 in 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 Say 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 the text-to-speech render the Google translated text until we drop language audio files into the application.
Dan is smart.
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:
- Member lookup by ZIP code and contact information is powered by our Congress API.
- Bill information comes from the Real Time Congress API.
- Campaign contributions and member biographies are provided by the Influence Explorer API.
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.
Give it a try! 1-888-907-6886
Call on Congress is open source and available on GitHub.Continue reading