I developed a Twitter bot using the Markov chain model. The motivation behind this project was to put the skills I've been learning into practical use. This bot tweets in a manner reminiscent of my friend at specific intervals.
To optimize costs and explore new learning opportunities, I migrated the infrastructure technology from AWS to Google Cloud Platform (GCP). The technologies I used include Docker, Google Kubernetes Engine (GKE), and Google Cloud Storage.
I implemented scheduled tasks for the Twitter bot using GKE's CronJobs:
-
fetch_tweets_cronjob: Scheduled to run every Sunday night at midnight (Japan time).
- Utilizes the Twitter API to fetch the latest tweets (up to 100) from my friend’s Twitter account.
- Appends the newly fetched tweets to the existing tweet data obtained from Google Storage.
- Performs text preprocessing, including tokenization, to prepare the data for the Markov chain model.
-
generate_tweets_cronjob: Scheduled to run every morning at 7 AM (Japan time).
- Uses the tweet data retrieved from Google Storage to automatically generate new tweets using the Markov chain model.
- Tweets the generated content.
- Language: Python (Markov chain)
- Cloud Platform: Google Cloud Platform (GCP) (Compute Engine, Cloud Storage, Container Registry, Google Kubernetes Engine - GKE)
- Containerization & Orchestration: Docker, Kubernetes
Check out the bot's tweets here: @UbotInSeattle
Feel free to explore the bot's tweets and its underlying technologies!