This was a fun project I built to raise more awareness and stop misinformation about Covid-19 on Twitter. It replies to tweets in real time.
type: personal
stack: typescript, node.js
code: github-repo
live: view-live-bot
The main purpose of this project was to improve my comprehension of TypeScript and APIs in general, I spent a good amount of time making sure I was using the best practices for writing API calls and manipulating data.
For this project, I chose to use Node.js since it has a great open-source eco-system as well as being able to handle multiple connections at one time. Which made it the best choice for this application.
TypeScript was mainly chosen because I wanted to learn more about it, but also because it is type-safe, meaning errors are caught early (unlike javascript :D )
Requirements:
- Listen to COVID-19 specific tweets created
- Determine whether there is misinformation or not
- Reply with correct information about the disease
- Keep track of whether tweets are being replied to or not
Complications:
- Determining which Twitter API version to use for my needs
- Finding the right balance for Twitter stream rule set
- Wait for a bit before replying so the bot won't get banned
- Reply character limit of 200 made it challenging to reply clearly
I normally work through coding projects and logic by creating lists like above. Here I've written down some necessary elements that my program needs to find a solution for. I also noted a few complications that arose once my app was up and running.
In this case, I noticed that in order for the bot to work properly it required both read and write permissions from Twitter, so I read through their API documentation and figured out the steps to gain permissions that allowed the bot to read and reply to tweets. Another small problem was that the bot was replying way too quickly which banned the account, I was forced to have the bot wait based on a timer and then reply.
I still have some imporovements I'd love to make with this project. I'd really like to spread more awareness by re-tweeting from health organizations about any developing new facts or news about covid. This will also allow me to re-factor my code to keep up with any changes in the Twitter API.