Backup video link: https://www.youtube.com/watch?v=DjbOWyimmW0
During the course of the pandemic, doomscrolling has become a big problem for people, as a constant feed of negative posts and news makes it hard to maintain a healthy mental state. We wanted to help with this problem by developing a Twitter bot that attempts to detect if the user is writing and/or reading too many negative tweets. If so, the bot will automatically send the user a helpful text with some positive news, mindfulness tips, and other resources to help the user get back into a more positive mental state.
- alternate url: use-tabs-not.space
What it does
Given a user, we analyze the sentiment of the user's recent Tweets. We then obtain a list of the accounts the user follows, and analyze the sentiments of the recent Tweets from those accounts as well. By considering both, we estimate the likelihood that the user may be in need of a positive reminder, and dispatch a text to them using Twilio. We also reach out to a friend to try to encourage having a conversation with someone the user may not have spoken to in a while.
How we built it
The backend/logic is constructed using Python with the Google Cloud Natural Language API. Tweets/Twitter friends/friend Tweets are fetched using Tweepy, the results of which are cached. The sentiment for each relevant Tweet is then assessed using the sentiment analysis tools available through the language_v1 package from Google Cloud. The user sentiment and average network sentiment (an average over the sentiments of the Tweets from the user's friends) is then returned.
These are then used to determine an appropriate action: for mild negative sentiment, we send a nice article, and for stronger negative sentiment, we send the friend DM and mindfulness tips.
Challenges we ran into
We tried to incorporate a database, but it really didn't want to play nice. Also, linking up the backend and the frontend was a challenge - there were issues getting APIs to work nonlocally using Heroku.
Accomplishments that we're proud of
I (Erik) am proud of having written a set of code that is able to fetch and analyze a relevant body of Tweets for a user. Also being able to incorporate the cloud service was quite exciting.
What we learned
How to set up and use Google Cloud, a technology which I (Erik) had no experience with previously.
What's next for Anti-doomscrolling Twitter bot
There are a few things to consider going further with this bot. First of all, it would likely be of benefit to do some experiments/clever thinking about how to construct the final sentiment metric. The current direct averaging of network sentiments and user sentiment may not be the best way to do it, but it's not immediately clear what would be the right way to do it. Also, there may be better approximations for what exactly a user is seeing on their feed. The tweets from their network may be a good quick proxy for what a user sees, but it doesn't account for tweets that show up on their feed for other reason, e.g. Tweets their friends like or comment on.
We can also make refinements to what the user gets upon action by the bot. For example, one thing we considered was that we could encourage and help the user craft a DM to get a conversation going with a friend they haven't talked to in a while.