HubSpot Engineering

Latest posts

Writing lately

Wooster Scripting for Fun & Profit

In this post

One of my favorite things about working at HubSpot is everyone's great sense of humor. The developer chatroom chronicles most of our zany antics, and it's facilitated by our very own robotic butler, Wooster Bot (named after Bertie Wooster, and based off of GitHub's Hubot).

#These bros want a chat bot...

Wooster is pretty smart; we've taught him how to evaulate mathematical expressions, translate text between languages, kick off new builds, generate a whole slew of different meme photos, and even tell us what today's specials are at the deli across the street. Any employee can add more functionality to Wooster by writing a node.js script. What else can we do with Wooster?

##JFDI

David Cancel, our fearless leader Chief Product Officer, is known for his poignant, humorous, and often quotable hashtags:

.@antrod lots of books and events cause a new sucker is born every day. #FAKERZ

David Cancel (@dcancel) April 9, 2012

Boston Startupers beware. #GeekswithGuns is back. #actlikeyouknow

David Cancel (@dcancel) April 5, 2012

The @HubSpot sales team is making it rain like a Lil Wayne video today! #majorleagues

David Cancel (@dcancel) March 30, 2012

So we figured, let's harness this corpus for some laughs.

#A man's gotta have a code.

We can implement this easily in CoffeeScript:

CoffeeScript
module.exports = (robot) ->   # twitter API url  url = 'https://api.twitter.com/1/statuses/' +    'user_timeline.json?include_entities=true' +    '&screen_name=dcancel&count=199'   # respond when someone says "@wooster dc"  robot.response /dc$/i, (msg) ->     # hit twitter API    msg.http(url).get() (err, res, body) ->       # catch HTTP errors      if err        return       # parse response JSON      data = JSON.parse body       # catch API errors      if data.error        msg.send "Error: " + data.error                return       # get list of hashtags      hashtags = tweet.entities.hashtags for tweet in data       # flatten hashtag list      hashtags = [].concat.apply [], hashtags       # respond with a random hashtag      if hashtags.length > 0        index = Math.floor(Math.random() * hashtags.length)        msg.send '#' + hashtags[index].text

Our final implementation makes use of Redis as a backing store to minimize how often we hit the Twitter API, but this was left out to improve clarity.

#Hello World

After deploying to our new Wooster script, we're in serendipitous hashtag heaven!

Newsletter

For Agents

View Markdown

Share

More posts

Automated Code Review: The 6-Month Evolution

Discover the evolution of HubSpot's Sidekick automated code review system and its impact on developer efficiency.

Cloud Coding Agents at HubSpot

Discover how HubSpot engineers use cloud coding agents like Claude Code to transform software development with AI, from planning to implementation to code review.

Moving Mountains: How We Migrated from Enzyme to React Testing Library

How we migrated 76,000 tests from Enzyme to React Testing Library, modernizing our stack and allowing teams to ship changes with more confidence.