Skip to content
A simple tweetbot that generates content with Markov chains
Branch: master
Clone or download
Pull request Compare This branch is 4 commits ahead, 1 commit behind tdhopper:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

markovBot is a simple Twitter bot that will generate a sentence using Markov chains and then tweet it.

Follow @_murakamibot and @jamesjoycebot to see it in action!

Getting Started


Install the markovify and tweepy packages:

pip install markovify

pip install tweepy

Fill corpus of example text

This project comes with a copy of Charles Dickens's A Tale of Two Cities as its example corpus.

Lots of good sources are available from Project Gutenberg.

Save the text file as corpus.txt

Test Markov chain

python to see an example tweet.

Connecting Twitter

Create a Twitter account.

Sign in to the Apps page and get four pieces of data:

  • Consumer Key
  • Consumer Secret
  • Access Token
  • Access Token Secret


make credentials_file

And edit the twitter_credentials.json file with the above four pieces of data.

Change the PUBLISH variable in from False to True to have the bot post to Twitter.

Deploy to AWS Lambda (Optional)

Steps for setting up auto-tweet account (using OS X or Linux):

  1. Add PyPI dependencies to requirements.txt.
  2. Run make prepare to generate
  3. In the AWS console, create a Python 2.7 function with tweet.send_tweet as the handler. Upload to use as the code. Add a "Scheduled Event" event source.
You can’t perform that action at this time.