Tools:
Twitter API, Wordnik API, Node.js, JavaScript
Year:
2014

My second Twitter bot, A Tale of Two Tweets, was created to explore the WordNik API a little more. The bot is based on Charles Dickens’ work, A Tale of Two Cities, opening quote, “It was the best of times, it was the worst of times.”

The bot grabs two recent publics Tweets; one that includes the word “best” and the other including the word “worst”. It then looks for the word that follows “best” or “worst” and checks to see if those words are nouns. If they are, the plural form of words is used in the following format: “It was the best of {noun}. It was the worst of {noun}.”

Sometimes the results don’t make any sense, which is part of the fun of creating these bots. Other times the bots returns hilarious results, as shown below.

Tweet: It was the best of teams, it was the worst of divisions.

The bot uses the Worknik API to identify the parts of speech in a given tweet and then formats them in the singular form.

The bot runs as a Node.js app and as a worker on Heroku. It fails silently if it doesn’t find Tweets of the correct format. It just tries again in the next time interval.

To learn more about how the bot was created, see my three-part blog series on creating a Twitter bot:

Follow the bot on Twitter!

Check out the code in this project’s Github repository

Return to Work Samples