Sometimes when I’ve had a break from personal tech projects for a while I want to get back into the saddle but don’t want to commit to something massive. I want a bite-sized, single evening project with a definite output and often a Twitter bot is the perfect creation to fill that niche. Once you have the basic formula down pat, the process is pretty easy, with most of the hassle being in convincing Twitter to give you developer access if you want to go the manual route.
When it comes to ideas, as long as you follow the limits set out below you should be able to have your Twitter bot run wild and free for as long as you like. I’ve done a few over time, including:
- A Twitter text adventure game
- Cat facts
- Queer fortunes and affirmations (source)
- Parody Harry Potter announcements (source)
- A chicken clucking in different languages
The easiest ones are timed Twitter bots, ones that just post something a couple of times a day. Whether it’s emoji meadows, generated landscapes, or even just the lyrics to one of the greatest songs of all time, these bots are a great way to practice coding and creativity within a limited medium.
Ones that reply to tweets directed at the bot are possible, but the Twitter API for hooking into that kind of notification has changed a bunch over time, and often for the worse. Many times I’ve had bots stop working and the amount of work required to bring them back into play exceeded the enjoyment or satisfaction I would feel from doing it.
The main limits for Twitter are pretty simple:
- 280 character maximum (so long, 140 limit!).
- Can’t repeat a tweet regularly.
These are hard limits in that Twitter won’t let you violate them, but there’s many other soft limits surrounding things like replying to a tweet automatically that wasn’t initially directed at you, byzantine rules about posting images, and posting too quickly in response to something. These can get your account suspended or under review, sometimes not even immediately but some time later at the whim of whatever daemons watch over that unholy platform.
If you don’t want to muck around too much with writing all your own code, nor the hassle of trying to get access to Twitter’s developer tools for your account, there are services out there like Cheap Bots Done Quick that can help you get a timed-posting Twitter bot up and running using the interesting Tracery tools that let’s you author grammars for story generation. I haven’t used this one myself, but it has a strong pedigree of famous Twitter bots built around it.
Make Your Own
If you want to make your own, you’ll have to create a Twitter account and visit the Twitter Developer centre and using the banner menu apply for access to a developer account. There’ll be a bunch of questions you’ll have to figure out and at the moment there’s a few day turnaround on having your access approved. Once you do have access, you’ll need to create a new “app” and set up some information, then grab the secrets for your account.
There’s a bunch of different libraries to use the Twitter API for a bunch of different languages, but I tend to use
You will need something to host it on, but I run about 5-6 bots on the cheapest VPS from DigitalOcean with a few other projects and haven’t run into any problems. To keep them running while you’re not connected to the VPS I use PM2 which has served me well for a few years without issue.
Twitter bots are a great way to explore some of that blend of technical+creative output without committing to anything major. You don’t have to limit yourself to Twitter either, most social mediums have some API you can get access to, like I did recently with Tumblr. You can have fun with them, explore ideas, and if you get tired of it you can shut it down as well with no hassle.