Inspiration

The 2016 presidential election was marred by the apparent involvement of Russian hackers who built bots that spewed charged political discourse and made it their goal to create havoc on internet forums. Hacking of this kind will never be completely stopped, but if you can't beat them... why not join them? The Russian IRA shouldn't be the only one making politically motivated bots! This bot informs voters of their congresspeople's contact information so they can call their representative to lobby for issues they are passionate about.

What it does

Contactyourrep is a reddit bot that uses sentiment analysis and location information to comment congresspeople's contact information. If a comment contains a key word (i.e. city, or congressperson's name), and it registers a low sentiment score, the bot will comment the relevant contact information of the relative U.S. Representative's or Senator's constituent hotline. Try it out on r/contactyourrep

How I built it

The bot was created using the PRAW API, which allowed an easier connection with reddit's interface. I then integrated Phone2action's legislature look API which can provide location specific legislature information based on address. u/contactyourrep is triggered by the presence of a state or city keyword and politically charged words in the comment's body.

Challenges I ran into

Finding specific key words is not as easy as you would think. Also one occasion the bot would run a little wild during testing causing the PRAW API to disallow posting for periods of time. This meant it was harder to debug and I often had to edit large blocks of code at once.

Accomplishments that I'm proud of

This is my first reddit bot! It was a very fun project and now that I've been through the whole process I'm excited about the possibility of additional project's in various reddit communities.

What I learned

It is surprisingly easy to make a bot that can post relative content on social media. This has powerful implications for the integrity of our political discourse online. If I can make a bot that can inform angry voters in under 36 hours, imagine what a country's dedicated hacking force can accomplish (I'm looking at your Russia). Though I'm hoping to use this bot to inform people of contact information regardless of political creed, it would be simple to reconfigure this bot to only comment based on pro-democrat/republican content.

What's next for Contact Your Rep

After demoing at treehacks, I plan to keep u/contactyourrep active on r/politics, hopefully increasing political involvement.

Built With

  • api:-phone2action-legislature-lookup
  • api:-praw
  • api:-textblob
  • language:-python
Share this project:

Updates