Desire Bot: A Twitter Bot That Re-Posts What the World Wants

I’m very proud to announce my latest project is live: @theDesireBot. It’s a Twitter bot that updates twice an hour, using the following criteria:

1) Re-posts a tweet that begins with “I just want…”
2) Identifies keywords from the original tweet, and searches Flickr for a matching photo.

I have to say that this project would not have come about so quickly, were it not for my finding an absolutely fantastic guide to creating Twitter bots, authored by Sarah Kuehnle.

Her trio of articles (Setting Up, Writing the Code, and Deploying Your Twitter Bot) were invaluable. They’re well-written, easy to follow, and provided clear, detailed instructions the whole way.

On top of it all, she also made her source code available, which I used as a basis for my own bot. There are a lot of Twitter bot tutorials out there, but I found hers the most comprehensive, the most straightforward, and the most fun (her .gif choices are great).

For Desire Bot, I got the opportunity to do a lot of new-ish things: working more via the command line, working more with GitHub and branches, working more with Node. I also got some exposure to Heroku, and did almost 100% of my project setup via the command line. This project has been a blast.

I also found out about Wordnik and its amazing developer API. I have just barely scratched the surface of what the API can do, and am excited about the ways I might use their service for future projects. Words!

So here’s a rough outline of what all goes on: First, I search Twitter for the phrase “I just want,” and ask for the first 100 matches. From there, I keep only those tweets that actually begin with the phrase. Then, I throw out any tweet that has a @mention, or #hashtag, or URL.

From there, I also run the tweet through Darius Kazemi’s wordfilter module, and throw out anything that gets flagged.

For better matching, I discard any word that’s three letters or less in length. Not 100% sold on this just yet, but for now all the words I work with have to be four letters or longer.

With the handful of tweets that make it this far, I create a list of words… and send those over to Wordnik, to find out more about each one. I then look at the responses and only keep the words that are nouns (or proper-nouns).

With this set of words, I have essentially what I need to do a search on Flickr. As of now, for accuracy, I’m only keeping tweets that have three nouns. Anything less feels too generic to me, and anything more oftentimes doesn’t match with an image.

When I send this list of three word searches to Flickr, I’m basically looking for photos that have all three of these words as tags for an image. Working with Flickr is a two-part process, where the first search is for a list of matches (and Flickr IDs), and a subsequent search for availalbe sizes for each ID. If there’s a “Medium” image size, that particular search makes the cut. Anything else gets discarded.

At this point, after a lot of culling, we’ve got tweets that match all the criteria we’ve set. We also should have a corresponding medium-sized image that’s been tagged with three of the nouns from the tweet. From this final list, I pick one at random… and the bot posts its message to Twitter.

I got the bot functionality done a week or so ago, but I’ve been spending more time lately trying to fine-tune the mechanics. I fixed a nasty bug earlier this morning, that introduced a mis-matching of the tweet and nouns. So I’ve been monitoring the bot today, checking to see if all the images do line up with the tweet and search terms.

Sometimes, the results are really funny. Sometimes, the photos are way off the mark. The joy and pain of bots, I guess. If you do the Twitter thing and are game for some silly updates every 30 minutes, I invite you to check out Desire Bot. And if you decide to follow the bot, I’d consider it a kindness.

I had an absolute blast with this project, and felt like I learned and grew a ton in the process. At times, it felt like I was walking down a murky path, only to emerge to unexpected patches of sunlight and an exhilarating view. I’ve felt very energized when working on this project, and have already started to think about more bots I might make. Don’t know that I can match the kind of bot output that tinysubversions has, but it may be fun to try…

One more time – a huge shout out to Sarah Kuehnle, whose tutorial was just killer. Definitely check out her posts if you want to make a bot of your own.

If you’re curious to look at my code, you can find the source for Desire Bot on Github.

PS: If you like that large photo on the Desire Bot page – the one with all the balloons? That was from an installation entitled “Half the Air in a Given Space,” back in 2012. Check out this blog post for a ton of fun photos from my visit.

On Profile Pictures and Yak Shaving
Box: Live Performance Between a Human and Two Industrial Robots, Using Projection Mapping
What If Twitter Came to Life?

This Post Has 3 Comments

  1. Another clever and beautiful project. I like the way you think, Jung!

    Ben Reply

  2. I’ve been noticing that a lot of the tweets from Desire Bot are about things that are really quite easily attainable (“I just want a bacon sandwich”) vs. things that are difficult to achieve (“I just want world peace”). That surprised me. I recently ran an experiment called, where I made a Taylor Swift prophecy machine to learn more about the questions people ask about the Internet, and I found something similar: people seemed to care more about asking things that they’ll know the answer to in a week or two, like “Will I pass my test?” than “Will we achieve world peace in my lifetime?”

    I wonder if this speaks to how people look at the Internet, as mainly a place to receive instant gratification.

    Edlyn Reply

    • I have always viewed Twitter as a very fleeting medium. Blame it on the 140 character limit, perhaps.

      It’s interesting that you’ve noticed this pattern. The bot logic really just pulls the text at random, so it’s mostly just a crapshoot what ends up getting published. But you’re right, as it does seem to all be attainable desires, shorter-term wishes.

      The one thing I keep seeing is that we all seem to really want more sleep and more ice cream. If I ever run for public office, I might have to make this part of my platform.

      avoision Reply

Leave A Reply