If you follow my standard Twitter account, @LaurenInSpace, you’re missing out on the good stuff. @LaurenInEbooks is a computer-generated stream of garbled tweets that are often far more on point than what I actually have to say.
A friend of mine, who knows about my love of esoteric Internet phenomena, built @LaurenInEbooks as a gift. It’s inspired by @horse_ebooks, a Twitter account so famous for its poorly computer-generated tweets that it got profiled in the New Yorker, which revealed that it had gone from a weird spam effort to sell ebooks into a mysterious art project.
Horse_ebooks is an old joke by now. But it’s not too late for you to get in on this bizarre genre of word art. A computer-generated account which serves as your own personal Twitter bot Frankenstein is always fresh and funny.
Plus, for beginning coders like me, this project is a great way to dip your toe into Python and Ruby while sharpening your Git skills—and at the end, get a hilarious little bot for your troubles.
See also: GitHub For Beginners: Don’t Get Scared, Get Started
Some of my coworkers wanted in join in on the fun, so I decided toTwitter bots, too. However, I found the starter script I chose to use, Heroku Ebooks, significantly difficult to follow. Building on top of it, I decided to create a tutorial anybody can use.
A caveat: I built this tutorial on a Mac using its Terminal app, software which provides direct access to running software programs. I have not tested this tutorial for Windows machines, but if you need help, start with GitHub’s Windows instructions.
It took me three tries to perfect the process. By the third time, building a bot took me only 20 minutes to complete! Here’s how to easily build your own random Twitter bot—and learn a little code at your friends’ expense.
Set Up A Twitter Account
You’re going to need a place for these tweets to go, so build a new Twitter account with a funny name. If you add “ebooks” to the end, @horse_ebooks fans will instantly get the reference, but you can choose any variation you like. In order to verify the account, you’ll need an email address that isn’t already being used by Twitter, so I’d suggest a secondary email you rarely use. I just generated a new email address I’ll probably never check again over at my hosting service, Bluehost, but you can also sign up for a new one on Gmail, Yahoo Mail, or Outlook.com.
This new Twitter account also MUST have a mobile number connected to it. I used Google Vice, since they give you your first number for free. If I needed another I might have used Twilio, which also gives you your first number for free.
If you need to create a lot of accounts, Twilio will cost $1/month, which can add up fast. And I should also note that while Twitter allows you to create parody accounts, “mass account creation” is against the rules. Twitter also has rules on automated accounts which you should follow. So don’t go crazy with your bots.
This is also a good time to make a profile image. For @SelenaEbooks, I inverted the colors on her face to make a bizarro version of her Twitter image. I’m sure she just loves it.
Set Up A Twitter Developer Account
While still logged into your new Twitter account, navigate over to dev.twitter.com. The first thing you want to do is create a new app. For convenience, use the same name as your new account.
Once you’ve named and created your app, you’re going to immediately want to adjust its permissions to “Read and Write.” In order to post to Twitter from a program, it needs to have a mobile number connected to the account—which is why we needed to create one earlier.
Next, go to the API Keys page and click “Generate my Access Token,” and keep the window open while it works. You’ll need those keys and tokens in just a few minutes.
Clone The GitHub Repository
Whenever you are working on a coding project, you are always standing on the shoulders of giants. In this case, we’re borrowing an open source Ruby and Python script that GitHub user Tom Meagher has saved in a repository.
You need a copy of Tom’s repository on your computer. The easiest way to do this is to hit “Clone In Desktop” or “Download Zip.” Either way, you want to take the resulting folder, which will be called heroku_ebooks, and store it in the very top directory of your computer.