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:

- Give me something that'll haunt me when I'm out of style. - I don't wanna hurt anymore. - Please take my eyes off of you. 

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 settingstwitter_heroku_config_vars
  • 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.

twitter_heroku_scheduler.PNG

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s