How (and Why) I Wrote My First Twitterbot

This week, I wrote my first twitterbot.

For a while, I’ve been interested in Twitter robots – not spambots that auto-follow everyone who mentions Justin Bieber, but those that do something interesting with language or online data, such as Metaphor-a-minute, which uses the Wordnik API to generate random metaphors, or Library of Aleph, which tweets captions (without the photos) from the Library of Congress’s photo collection.

I’ve wanted to create a twitterbot, but didn’t think of an idea until this week while listening to one of my favorite songs, Elvis Costello’s “(What’s So Funny ’Bout) Peace, Love, and Understanding?”, and about to tweet (for the 2nd time) my favorite lines:

So where are the strong?
And who are the trusted?

It struck me that questions found in song lyrics could make a good Twitter account. Questions in song alternate between the profound:

– and the ridiculous:

A single line from a song can also be rich in memories and connotations. I now had my idea for my twitterbot.

How I Wrote It

There are a ton of “how to” options online. Because I want to learn more about Node.js, I chose this tutorial from Christian Paulsen to create the basic structure and functionality of the twitterbot.

Next, I needed questions. I put out a call on Facebook for my friends’ favorite questions from songs and ended up receiving more than 150 suggestions. I put all these into a text file and created a script that selects a random line and posts it on Twitter. If you’re interested in this sort of thing, I put the script on Github.

To automate posting the questions to Twitter, I downloaded LaunchControl, a small utility that lets you create and edit automated tasks on a Mac. Technically, LaunchControl just provides a GUI for Mac’s launchd process – see more here – but it makes launchd’s fairly confusing format much more readable. I have the script scheduled to run every three hours at the moment.

This process isn’t perfect – it runs whenever our computer is being used, but not if it’s asleep or off. So one of my next steps is to convert an old Mac into an always-on home server that can (among other things) run the Twitterbot 24–7. I’d also like to make the posting a bit less random by avoiding repeated questions too frequently or grouping some multiline questions together.

Overall, the project was very fast (started on Thursday night, finished by Saturday morning) and tremendous fun, and I’m collecting ideas for other bots. I’d like to try pulling texts from an API or a public domain source (Book of Common Prayer, perhaps?) for my next one.

Oh, and be sure to follow Lyrical Questions on Twitter.

Fasting from Snark

The cover of the poem The Hunting of the Snark

The cover of Lewis Carroll’s The Hunting of the Snark

This past weekend, I attended a Via de Christo men’s retreat near Seymour, Indiana. This is the Lutheran version of the Cursillo 3-day retreat that originated in Spain among Catholics in the 1940s and has since spread around the world.

My sponsor, Greg Geiser, asked me to leave my phone at home for the weekend, so that I would be able to focus more easily on the retreat, rather than spending my free time checking email, Twitter, Facebook, etc., etc. This request became easier to obey when I dropped my iPhone in the church parking lot and shattered the screen a few days before the retreat. We were also asked to put away our watches for the weekend, to help us focus on each moment as it came and rely on the retreat staff for our schedule, instead of anticipating the next meal or tracking how long an activity was taking. So, for a period of about 84 hours, I didn’t have any means of telling the time or checking in with my usual media feeds.

Two observations stuck with me from this experience of leaving my phone at home.

I too often use social media to “check out” of my immediate location. Throughout the retreat, there were several period of down time — waiting in line for meals, waiting for the next activity to start, walking from one building to another — when I was tempted to pull out my phone and check Twitter or Google Reader. Then I remembered that I didn’t have my phone. Instead, I had to be present wherever I happened to be. This led to several conversations that I would not have otherwise had, as well as a beautiful early morning view of snow falling on a lake that I would have missed completely if I were laying in bed reading Twitter.

Social media fuels my natural snarkiness and allows me to indulge in dehumanizing sarcasm. The men at the retreat were, in many ways, a microcosm of the church, comprising a wide range of education and income levels, as well as a few with rather “unique” theological perspectives. I wish I was more mature than this, but several times a sarcastic thought crossed my mind. Without Facebook or Twitter to record my passive-aggressive sarcasm, though, my sarcasm had nowhere to bloom, and the thought was killed on the vine. As the weekend went on, I found the sarcastic coming less and less often, and the other men became brothers in Christ to me, rather than punchlines to a joke. (Well, most of them did, anyway.)

Upon returning to the real world, I’ve been less tempted to use social media to distance myself from my surroundings or depersonalize other people. As the residual effects of the retreat fade, here’s hoping that this weekend marked a change in my relationship with technology.

Two Quick Updates

Just a quick update, one ministry-related and one for blog housekeeping.

  1. Pray for my travel next weekend to the CCO Jubilee Conference in Pittsburgh. I’m visiting this highly-recommended student conference to see if ESN might be able to partner with CCO in some way.
  2. I’ve added a new feature to my website that will import my Emerging Scholars Blog posts into this blog. I’m also experimenting with adding my new Tumblr feed to my blog for quick asides and commentary – though that be unnecessary, since Tumblr is supposed to send updates to my Twitter account automatically, and that feed already shows up in my sidebar. You should notice an increased number of posts from the blog – I’ll see if there is a way for you to subscribe only to my “old school” posts.