The Reason For the Teardrops on My Twitter Bot

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:

Let's Create a Twitter Bot!

Prerequisites

Execution

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.

If you struggle with this step, please refer to my twitter_hello_world example.
It posts to this account: TweetDev3l

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
    twitter_heroku_config_vars
  • Deploy branch, master

Validate your app by clicking the Open app button from within Heroku.
My working Twitter 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.
twitter_heroku_scheduler

Once enabled, your Twitter account should have a randomly generated tweet every hour!

Next Steps

  • 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 Fighters - Tay Fighters
    • System of a Down - System of a TayTay

Get In Touch

We'd love to hear from you! Whether you have a question about our services, need a consultation, or just want to connect, our team is here to help. Reach out to us through the form, or contact us directly via social media.


Previous
Previous

A Cultural Target State: Netflix

Next
Next

Posting to Facebook using Python