A Tale of Two Tweets

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 bot returns hilarious results, as shown below.

URLhttps://twitter.com/taleoftwotweets
Githubhttps://github.com/ursooperduper/taleoftwotweets
Tools: Twitter API, Wordnik API, Node.js, JavaScript
Year: 2014

twotweets-1

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 that match the prescribed 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:

twotweets-2