Wiiisdom Labs
Published in

Wiiisdom Labs

Why We Needed a BitBucket Bot (and How We Built Our Own Bot in a Matter of Hours)

What is BitBucket ?

BitBucket is a web-based version control repository hosting service for source code and development projects.

Bitbucket is more than just Git code management. Bitbucket gives teams one place to plan projects, collaborate on code, test, and deploy.

Atlassian (software company that acquired BitBucket in 2010)

What is Hangouts Chat ?

Hangouts Chat is Google’s message platform built for teams.

Hangouts Chat makes it easy for teams to be able to get their work done in one place. From direct messages to group conversations, Chat helps teams collaborate easily and efficiently. With dedicated, virtual rooms to house projects over time — plus threaded conversations — Chat makes it simple to track progress and follow up tasks.


What Is a Bot ?

A bot is a software application that runs automated tasks over the Internet faster than a person could do them. Bots are mainly used as:

  • Task helpers — boost productivity by automating processes and give the right info at the right time
  • Social tools — automatic posting/retweet engine to increase SEO or visibility
  • Commercial helpers — interact with customer, offer help, be present online around the clock

What Kind of Bot Did We Need ?

Here at GB and Smith, we are trying to rely less on email and more on team messaging. Unfortunately BitBucket doesn’t integrate with Hangouts Chat. So, once we started using Hangouts Chat, we had no way of knowing when a BitBucket pull request was created, commented on, or ready to be reviewed. BitBucket does integrate with Slack (another message platform), but we’re already heavily reliant on G Suite and unwilling to switch.

To solve the problem, we decided to build a bot that could provide information from a third-party tool (in this case, BitBucket) to a messaging platform (in this case, Hangouts Chat).

How Did We Build Our Bot ?

Working With an Existing Framework: Hubot

First, we tried to build our bot using Hubot. Developed by GitHub, Hubot is a nice NodeJS framework for building bots, which comes with a long list of adapters that can connect to existing messaging solutions. We thought it would be a simple matter of linking the interactions with Hangouts Chat to the set of scripts available for BitBucket pull requests, both of which already existed in Hubot. Unfortunately it wasn’t as easy as that because the Hangouts Chat adapter currently can’t speak asynchronously with Hangouts Chat. So we went back to the drawing board.

Working From Scratch: Plain NodeJS App

We started over from scratch, this time using a plain NodeJS app and basic building blocks (ExpressJS, Google API). The key was to use a service account for speaking asynchronously with Hangouts Chat, and a BitBucket webhook to send messages to our bot when an action occurred.

Simple schema

We now use our bot to integrate BitBucket with Hangouts Chat for the following actions:

  • Creating pull requests
  • Editing pull requests
  • Commenting on pull requests
  • More coming soon!

BitBucket actions are displayed in Hangouts Chat as cards that include links.

What’s Next For Our Bot?

Our bot serves an important function, but it isn’t perfect yet. For example, we can’t speak to our bot or interact with it. But we have big plans for our bot, and hope to someday:

  • Use another existing bot framework (e.g., BotKit)
  • Make it possible for users to interact with the bot (e.g., setting up a webhook directly from the bot discussion)
  • Add reviewer notifications (i.e., link BitBucket users to chat users, and be able to send notifications to reviewers instead of a room)
  • Make the bot available externally (Right now, it’s only available only for our G Suite domain.)
  • Improve hosting (Deploying the bot on Dokku was quick and easy — we just git pushed and it was live with an https certificate — but we can probably do better with a serverless deployment.)

No Ifs, Ands, or Bots About It!

In the end, building a bot to solve the problem of integrating BitBucket with Hangouts Chat proved to be quite simple for our team of talented developers. GB and Smith’s first homegrown bot may not be its last! Are you interested in this subject or the solutions that GB and Smith is developing for business intelligence products? If so, we’d love to hear from you, either in the comments below or on social media.




Content produced by engineers working at Wiiisdom.

Recommended from Medium

OpenTelemetry with Jaeger in .NET Core

A routemap for a platform for government services in Canada

Tutorial Fuzzy Logic Mamdani for Arduino

Tutorial Fuzzy Logic Mamdani for Arduino

Mastering Python in 3 Days : Day 1 — Installation

Understanding Database isolation level via examples — MySQL and Postgres

Reflections of an Old Project and a Second Chance

What Is Great About Developing Open Source and What Is Not?

Setting up kubernetes cluster on raspberry pi

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Julien Bras

Julien Bras

Innovation Team Leader @ Wiiisdom. Love testing & using new things. Dad of 3.

More from Medium

Changing our tech stack…

An Experience with AWS Amplify & ReactJs

What is React Native App Development? Is There any Future of It?

Event tracking with Mixpanel and NodeJs, The Callback in Async scope magic!