What happens if we combine the corpus of Taylor Swift lyrics as the source for Markov Chain sentence generator with a Heroku Scheduler Python task that posts hourly to Twitter? How about a, Taylor Swift Random Lyrics Generator!
Here are some interesting tweets:
- Give me something that'll haunt me when I'm out of style.
#TaylorSwift - I don't wanna hurt anymore. #TaylorSwift - Please take my eyes off of you. #TaylorSwift
Let’s Create a Twitter Bot!
- GitHub Account
- Twitter Account
- Heroku Account
- Must sign up freemium account (requires Credit Card information)
Twitter Hello World Example
First, get a “Hello world!” Python tweet example working.
Introduction to Tweepy Twitter for Python
The Tweepy tutorial shows how to create an account and retrieve your api secrets.
Heroku Application Setup
Now that you can post to Twitter, leverage my GitHub project to get started, python-heroku-random-taylor-swift-lyrics. Fork it (and/or contribute) if you want!
- Setup a new app within Heroku dashboard
- Connect it to your GitHub account and project
- Be sure to scale it to at least one web node! Heroku Scaling
- Set environment variables through Heroku settings
- Deploy branch, master
Validate your app by clicking the Open app button from with Heroku.
My working Twtiter post example can be found here: https://random-taylor-swift-lyrics.herokuapp.com/twitter
Heroku Scheduler Setup
Within Heroku resources, add Heroku Scheduler.
Add a new job that looks like the following.
Once enabled, your Twitter account should have a randomly generated tweet every hour!
- Refine Markov Chain algorithm
- Create a random choice of “trending” hashtags and mentions
- Combine Taylor Swift lyrics corpus with other non-related bands
- Metallica – Metal Swift
- 50 Cent – Taylor Cent
- Foo Fights – Tay Fighters
- System of a Down – System of a TayTay