Over the past year, major changes in American politics have left a lot of people feeling like they should be doing more to get involved.

Political advocacy can take a lot of forms. It can be passive or active, partisan or nonpartisan, personal or large-scale. As engineers, we are uniquely empowered to apply our skills to important causes. This post describes how I built a simple, open-source app using Twilio’s Voice API that’s handled over 10,000 calls to senators and representatives in Congress (or just jump to the finished code) You can also watch me code this application in this video of my SIGNAL 2017 talk.

Getting started

Our stack is Node/Express, Twilio, and an API from the Sunlight Foundation that allows us to look up representatives for a given zip code.

Here’s how it works:

User calls our Twilio phone number Phone number asks them for their zip code User enters their zip code Phone number connects them with their representatives

The phone number calls representatives one after the other. After the user inputs a zip code, we call their first representative. Once that call is complete, we automatically dial their second representative (and third, and so on).

In order to create this call flow a simple Node app uses the Twilio API to do the following:

Define an Express route that takes new inbound communications from Twilio. Ask the user for their zip code. Receive the zip code input from Twilio. Look up representatives for this zip code and have Twilio forward the call to their phone numbers.

Create an Express route to accept new inbound calls

Start by setting up a boilerplate Express app in index.js: