CircleCI Notifications on Hangouts Chat

Ismail Demirbilek
2 min readOct 15, 2018

--

Google, now has its Slack alternative for their G Suite members. By now, I mean March 2018. It’s just me migrating to Hangouts Chat, this week.

Our entire team was on G Suite and we were using Slack on free plan. I came across Chat recently and decided to move on with it.

Migration included channels (rooms), members and of course bots. We were using Github, Netlify & CircleCI bots mainly among others with Slack. They were flawless and I wanted them to be same with Chat.

Github was easy. Chat has its own Github bot. OAuth and done, check.

Netlify and CircleCI on the other hand was not ready to plug & play. Hangouts Chat has its very good webhooks api. So I started to look for the possible solutions of sending post test / deploy notifications from CircleCI. Though haven’t find a good way with 2.0 api.

However I found out workflow steps can be limited to run on success and fail statuses with when attribute.

So I have managed to post messages after successful and failed builds with curl.

Long waited notification

Yes, Chat has handsome card messages via webhooks api.

Configure Webhook

  • In a Chat room click to top most room menu, and select “Configure Webhooks”.
  • Click Add another.
  • Fill the form and done.

You can copy the newly added webhook URL. And you should see the docs.

Configure CircleCI

Following is my config.yml to build and deploy our application whenever a git tag is pushed. Last two steps were added to send build status notification that is seen above.

You probably noticed the environment variables like $CIRCLE_CI_BUILD_NUMBER. Those are exposed in CircleCI build environment. And here you’ll find all of them documented.

There is also $CHAT_WEBHOOK_URLvariable. As expected, this is the URL of webhook we just added one step before. It can be exposed with CircleCI project settings page.

That’s it I guess. Hope you like the read.

--

--