How to Write Twitter Bots
A twitterbot workshop using Tracery and CheapBotsDoneQuick
- Look at some twitter bots, understand how they work
- Learn Tracery, a simple method of Mad Libs-style text generation
- Make our own generators using Tracery
- Learn how to use Cheap Bots Done Quick, a beginner-friendly platform for hosting twitter bots
- Turn our generators into real functioning bots
Let's look at some twitter bots
- @TwoHeadlines by Darius Kazemi
- @FellasBot by Darius Kazemi
- @the_ephemerides by Allison Parrish
- @thinkpiecebot by Nora Reed
- @wigglebunch by Nora Reed
- @you_have_died by Nora Reed
- @thielspotting by Todd Anderson
- @MagicRealismBot by Chris Rodley
- @softlandscapes by George Buckenham
Tracery is a text generation library created by Kate Compton. It's basically a big list of lists and templates you use to generate text in a Mad Libs-style, where certain parts of a sentence are selected at random from a larger group.
- Online Tracery Editor
- Corpora big lists of stuff!
- Lets looks at some of the JSON files included in this repo and plug them in!
Time to try making our own. Break into groups and come up with an idea for your generator. Good bots have a simple narrow theme that is then expanded on to have a lot of possibility.
- Start with a recent news headline, a fun meme, or a subject you're interested.
- Make a starter template sentence
- Make lists of things that could be swapped out
Cheap Bots, Done Quick
- Create a new Twitter account. Putting in a phone number will keep your account from getting shut down.
- Log in to Cheap Bots Done Quick with your new twitter account
- Paste in the grammar from your tracery generator
- Test to make sure it works
- Set how often you want to tweet
- Go back into the twitter account and make a nice profile and banner image and description (let people know it's a bot)
Some Ethical Guidelines
To quote Leonard Richardson and an axiom of the botmaking community, "Bots should punch up". If you're bot makes jokes at someone's expense, make sure they're higher status than you, aka it's cool to make bots that make fun of corporations, politicians and celebrities, but its not cool to make bots that bully and harass regular people, especially groups of people that put up with a lot of that harassment already.
You can make more advanced Twitter bots that do things like markov text generation, uploading images, replying, and showing p5/processing images by programming them yourself in Node or Python. Dan Shiffman's The Coding Train has a great set of videos on making a Twitter bot in Node.js