Heaven Knows

Today, a bunch of Twitter’s most active and (IMO) best bot makers got together at Bot Summit, organized by Darius Kazemi to talk about, well, bots.

Awesome bots are a big part of why I’m on Twitter. The sheer weirdness of these little text robots, walking around like people online, makes Twitter a lot of fun for me. Similarly, the awesome people who make the awesome bots have made Twitter awesome for me by being great friends, nice online acquaintances, or at least great people to follow.

I’ve never made a bot before, and so I felt like I’d be a little lost at Bot Summit. So I made one today! Allow me to introduce: @mozerablebot!

In his current iteration @mozerablebot grabs a random noun off Wordnik, then sings about how it makes him miserable, just like getting a job made Morrissey miserable. On an average day, he does this about 5 times a day.

It feels good to have made something. I’m glad I made a simple bot to start with so I could learn how to set up hosting and to work with Twitter and Wordnik without thinking too hard about what the bot itself should be like. I did a pretty good job not getting bogged down in little details so I could get the big-picture stuff rolling.

As simple as he is, he’s already surprised and delighted me with his unexpected misery. I hope you enjoy him too! (and read on if you’re interested in a more technical account!)

Technical Details

If you want to have a look at the code, it’s up on GitHub. I welcome feedback on my work there or on Twitter. Teach me what you know about bots!

This was a great exercise for for me. The idea is conceptually simple and, modulo the complexities of working with web APIs, simple to implement. I didn’t get distracted doing anything too fancy with natural language or, for example, responding to replies. It’s just a simple script that, when run, tweets as appropriate.

That simplicity let me focus on learning the ropes with Red Hat’s OpenShift platform. I learned about OpenShift at All Things Open, so I thought I’d give it a try. It took a little poking around to figure out how to use it, but the system is simple enough that I feel like I actually understand it, and I’m ready to spin up more bots pretty easily. The Cron cartridge was a good find for me. I was able to set up a shell script to call the tweet script. Placing the shell script in the cartridge’s minutely directory set the script to be called every minute.

That script determines when @mozerablebot actually tweets with the condition [ $[$RANDOM % 1440] -lt 5 ]. So, every minute, there’s a 5-in-1440 chance it’ll actually tweet. There are 1440 minutes in a 24-hour day, so it’ll tweet 5 times on an average day. There’ll presumably be some days when it tweets relatively frequently, and others when it doesn’t tweet at all. Time will tell if that’s good or bad. Avoiding bikeshedding and Just Shipping Itβ„’ were important personal goals for this little project, and I’d rather have it out the door and see how it goes than fuss too much over this kind of decision.

I used the list of words from Darius Kazemi’s awesome wordfilter to filter out any words from Wordnik that might hurt someone. If it weren’t for that prior work, one of three things would have happened:

So, thanks, Darius, for helping me avoid those problems!