My First Twitterbot

This semester, I am teaching an undergraduate Digital History Methods course in collaboration with a graduate class taught by Andrew Torget at the University of North Texas.

At the beginning of the semester, we did some general readings about digital history, and also some historiographical readings about runaway slave advertisements, which is the topic we chose to focus on for the course. In order to give students hands-on experience with digitization work, we also worked through homework assignments that required students to create a JSON representation of a runaway ad and to collect ads from historical newspapers on the Portal to Texas History, a wonderful digitization project at UNT.

At this point, students in the two classes have collected around 400+ ads from Texas newspapers, and are working on text mining projects with the collected transcripts. In the meantime, however, my class began an interesting discussion about what it would look like to "tweet" the runaway ads. Most runaway ad sites typically display the ads shorn of their context in the original newspapers, including this promising project at Stephen F. Austin. What would happen, we wondered, if we made our transcribed ads available with links to the original context on the page, and also inserted the ads into a very different contemporary context—the Twitter stream.

The result was @TxRunawayAds and a great introductory essay about our rationale written collaboratively by students in the Rice DH class.

To help with the process of tweeting an ad each day, I channeled Mark Sample, king of the Twitterbots, and wrote my first ever script to post to Twitter using Python. You can see the script here. It basically excerpts text from a randomly selected text file containing one of our ad transcriptions, and uses the metadata contained in the text file name to reassemble a permalink to the Portal to Texas History. It checks to make sure that the tweet is not too long before posting to Twitter. (This tutorial was very helpful, if you’re interested in building something like this yourself.)

So far, so good. But for the last week, I’ve been having to run the Adbot script manually from my computer to post a new tweet to the feed. So this morning I looked into setting up a launchd job on my Mac to have the script run automatically every day at a set time. I learned most of what I know about launchd from Nathan Grigg, and I think his site also directed me to LaunchControl, an easy-to-use GUI for managing jobs. So I downloaded that software this morning and was able in a few minutes to set up a job that looks like this:

LaunchControl screen shot

LaunchControl screen shot

If all goes well, then that should be all I need to do in order to have my Twitterbot script run automatically every day at 10:30 in the morning. We will see in about an hour if it works!