Say Hello to Hubot
For the past year or so we’ve been telling people about Hubot, our amazing Campfire bot. We have a lot of fun working on Hubot. He makes us laugh, he…
For the past year or so we’ve been telling people about Hubot, our amazing Campfire bot. We have a lot of fun working on Hubot. He makes us laugh, he ships our code, he is the interface to our CI server, and a whole lot more. Over the last year, he’s grown bigger and messier. So we decided to rewrite him from scratch, open source him, and share him with everyone.
Meet Hubot.
What we’ve come up with is a nicer implementation of the previous Hubot. One that we think a lot of our users will enjoy working with if they want to automate everyday tasks. Even better though, you can host your own Hubot on Heroku for free. Hubot scripts can be written in CoffeeScript or Javascript and he can persist data to Redis with Heroku’s free Nano addon.
github/hubot
Hubot is a library and an executable that wraps up all the logic of connecting to chat servers. Right now there are adapters for Campfire and IRC, but adding stuff like Hipchat or other services should be pretty trivial. The main hubot library is where the core of Hubot lives, but it just scratches the surface.
github/hubot-scripts
These are where Hubot’s scripts reside. This is where the magic happens. The fun stuff, the serious stuff, the weird stuff… hubot-scripts is designed as a place where we can share scripts with the entire community at large. You can browse it for interesting scripts, drop them into your own bot, and contribute your own work to the repository.
Hubot internals
At his core, Hubot simply idles in various rooms and waits for specific strings to go by in the chat.
robot.hear /problem??/i, (msg) ->
msg.send "http://cl.ly/BG7R/trollface.jpg"
With this snippet, Hubot will listen for the phrase problem?
, and then dutifully embed the classic trollface image into the chat.
Sometimes listening for strings isn’t what you want. Sometimes you want to command Hubot to do your bidding. For that, the robot has a different method.
robot.respond /(image|img)( me)? (.*)/i, (msg) ->
imagery = msg.match[3]
msg.http('http://ajax.googleapis.com/ajax/services/search/images')
.query(v: "1.0", rsz: '8', q: query)
.get() (err, res, body) ->
images = JSON.parse(body)
images = images.responseData.results
msg.send msg.random images
This snippet pulls down a random image from Google Image Search. Something like hubot image me pugs
would find a random pug image and paste it into the channel.
Every Hubot is powered by npm so you can easily bring in whatever Javascript libraries you want. Check out the scripts directory to see some more script examples.
YourBot
We really love Hubot. It’s a shared side project that everyone at GitHub can (and does!) contribute to on a regular basis. For us, Hubot’s much more than just a repository and a collection of scripts… he’s part of our culture.
We’re giving you the core of Hubot, and some of the scripts that make up Hubot. But it’d be a shame if you just stopped there. Build out some of your own scripts. Let your company take your bot however you’re destined to take it. We bet you’ll enjoy it as much as we do.
Written by
Related posts
![](https://github.blog/wp-content/uploads/2023/10/Collaboration-DarkMode-2.png?resize=400%2C212)
2024 is the biggest global election year in history. What’s at stake for developers?
GitHub is considering what is at stake for our users and platform, how we can take responsible action to support free and fair elections, and how developers contribute to resilient democratic processes.
![](https://github.blog/wp-content/uploads/2023/10/AI-DarkMode-2.png?resize=400%2C212)
GitHub named a Leader in the Gartner first-ever Magic Quadrant for AI Code Assistants
This year, as part of its annual Magic Quadrant series, Gartner published a first-of-its-kind report analyzing the state of play in the AI Code Assistants market–and named GitHub a Leader.
![AI in software development 2024 survey results with colorful graphics and percentages.](https://github.blog/wp-content/uploads/2024/08/ai-survey-header.png?resize=400%2C212)
Survey: The AI wave continues to grow on software development teams
We surveyed 2,000 people on software development teams at enterprises in the U.S., Brazil, India, and Germany about the use, experience, and expectations around generative AI tools in software development.