Last Monday, I tweeted out about the Twitter bot I had created, @LawsMass. Using Glitch and the Open States API, the bot tweets out pieces of legislation currently being worked on in Massachusetts. Since then, I’ve gotten asked these questions a few times and decided to put it all in one place:
Adding legislature information
I decided against including the bills’ sponsor information in the tweet because there is typically more than one sponsor listed for each bill. This poses two issues:
- The bill title, link, and list of sponsors would likely span multiple tweets, which I didn’t want.
- I know that, for myself, if I was faced with choosing one sponsor over another, I wouldn’t reach out to any of them, for fear of choosing the “wrong one.”
In @LawsMass’ bio, I referred users to @Resistbot, a bot that will find out who represents you in Congress, and deliver your message to them (in under 2 minutes). My thought here is that it is more likely for people to be vocal about bills they do(n’t) agree with if it is as seamless as possible.
Reversing the posts
Many people have asked why I chose to reverse the bills after the API call. Take a look at the code to follow along with this explanation (starting at line 40).
After we query the API, we’re going through each bill object and constructing a new object with only the information we want (the title and url). We’re then pushing each new object into the allBills array. By reversing our data at the onset, we’re ensuring that all new bills are added to the end of our array, so that all older bills keep the same index. Every time the API gets queried, we add 1 to the count variable, and then we tweet out the status in that index. For instance, the first go around we tweeted out formattedStatus, made count = 1, and the second time we tweeted formattedStatus, made count = 2, so on and so forth.
Another common question I had was why I decided against having a date check, thus only tweeting out bills after say, January 1, 2018. I wanted to see all of the legislation the API had record of to be able to track and find patterns in the bills. There was a subthread where it was discussed how interesting it was that so many of the bills had to do with sick banks and commendations for government employees. These types of bills seemed to be passed through more quickly than other types. For me, the point of this project was to not only bring awareness of the current, but to see patterns of the past as well.
— — — — — — — — — — — — — — — — — — — — — — —
So those are a few of my decisions. The wonderful thing about Glitch is that you are free to remix the code, and update to how you see fit. You can make a bot that tracks certain types of bills, or tracks particular sponsors — whatever you want. And I certainly hope you do that! And I also hope you let me know, because I would love to see what you build :)
I am honestly so humbled by the amount of positive feedback I’ve received! To hear that people are making their first bot using this code — I can’t describe how excited I am. Thank you all for your hard work, likes, collaboration, and retweets. I have a few more projects like this lined up that I’m excited to share with you all. Please feel free to get in touch with me at any time for questions or concerns or to collaborate!
Thank you, thank you ❤ !