The heart of tech is coming to the heart of the Mediterranean. Join TNW in València this March 🇪🇸

This article was published on April 14, 2015

The Twitter Sorting Hat that picks your Harry Potter house and the bot builder behind it

The Twitter Sorting Hat that picks your Harry Potter house and the bot builder behind it

There’s no shortage of online takes on the Sorting Hat from Harry Potter – including on JK Rowling’s own expansion site Pottermore – but there’s something particularly appealing about one of the latest to emerge.

@Sortingbot is a Twitter account that adds you to a queue when you follow it and eventually generates a custom rhyme assigning you to one of Hogwarts houses.

While it’s able to create serviceable rhymes, the bot’s inability to distinguish the exact meanings of the words it chooses often leads to enjoyable gibberish. If you miss the semantic car crashes once offered by the now defunct @Horse_ebooks, you’ll like the Sorting Bot.

Darius Kazemi (@tinysubversions) is the owner of the human brain behind the bot’s algorithmic poetry. He put it together by studying the Sorting Hat’s songs from the ‘Harry Potter’ books. They use a loose iambic tetrameter, arranged into ABCB rhyming quatrains.

Here’s part of the song it sings to Harry in ‘The Philosopher’s Stone’:

You might belong in Gryffindor,
Where dwell the brave at heart,
Their daring, nerve and chivalry,
Set Gryffindors apart…

He then used an all-in-one text processing and generation tool called RiTa to power the bot and coupled it with a project he runs called Corpora, which builds lists, to grab a collection of common animals.

After a fair amount of struggling with adjectives, adding error handling for occasions when RiTa fails to find a rhyme, and working out how to ensure the stresses are right, Kazemi had a working bot.

How does it assign your house? At random. Sadly there’s no Twitter API to explore the content of your character or delve into your soul.

Kazemi told TNW that he thinks the random element is a good thing:

It was important to me to make the actual house assignment random, because I think beautiful interactions happen when people encounter the random – it’s impossible to ‘game’ a purely random draw, and I think that adding chaos and serendipity into people’s lives is a worthwhile goal.

As for what led him to build the bot, beyond Rowling’s work, he says it’s all about his friends and other bot makers:

The inspiration was seeing my friend Hannah Foell play Sorting Hat to people on Twitter. It seemed like a fun game and I thought it would make a cool interaction — I’d just made @yearlyawards in December and the response was great so I had my eyes open for another thing in the “follow the bot and get something custom” format. (The pioneer of which is @irondavy, who made @robotuaries)

Robotuaries is definitely a gloomy forerunner to the Sorting Bot. It generated a custom obituary for any user that followed it, but seems to have died itself in February last year. Its creator, David Cole, is Director of Design at Q+A startup Quora, so he might just be a little busy to keep it going. I’ve asked him.

Though building bots is an idle pastime for most, it’s practically a vocation for Kazemi. His other projects include Confused Friends, a Tumblr bot that pulls scenes from ‘Friends’, runs the subtitles through Bing Translator and creates a GIF of the output…


…and a huge list of Twitter bots that variously post old school hip hop flyers, weird automated conversations, Marxist startup ideas, random tweets from Twitter’s first 90 days, and quotes from French philosopher Bruno Latour mashed together with messages from the #swag hashtag. You can see the exhaustive list of his projects here.

As Twitter increasingly becomes a place where brands encourage us to buy things or just push their latest bacon-wrapped treats, it’s worth celebrating the sheer oddity of creators like Kazemi. I’m sure he’d be in Gryffindor.

Feature image credit: Warner Bros. 

Read nextYou Just Lost The Game