How to push notifications into your HipChat Room

Hi geeks! The post reviews the whole process in order to create your own HipChat notifications for your team room.

For this tutorial, let’s suppose that we make regular new releases of our product, and for it, we have already created a script that automatically deploys a new version of our source code. Now, we would also like to notify the corresponding stakeholders  (aka product managers, designers, testers, etc) that the new version has been successfully released.  So let’s do it!

Prerequisites

  • NodeJS v4 or higher
  • A Unix computer
  • A HipChat room to notify

Step 1, download the another-hipchat-notifier plugin

In your terminal

npm install -g another-hipchat-notifier

Verify that it was correctly installed, run

ahn --help

Step 2, create your own HipChat room API token

In order to effectively notify to a HipChat room, you will need first to create an API token. Only administrators of the room can do that, so in case you don’t have this privilege, ask one of them.

1. Go to http://www.hipchat.com and login using your credentials

Screen Shot 2016-05-26 at 7.31.40 PM

2. Find the “Rooms” tab and click it

Screen Shot 2016-05-26 at 7.32.27 PM-shadow

3. Look for the room name you would like to notify and click it. Find the “tokens” section.

Screen Shot 2016-05-26 at 7.50.42 PM-shadow

4. Create a new token by specifying the Label and Scope.

Label: the name that will figure in the notification

Scope: needs to be “Send notification”

Screen Shot 2016-05-26 at 7.53.18 PM

Hit the “Create” button, you will see that the new token has been created. Save a copy of it for use later!

Step 3, configuring the another-hipchat-notifier tool

First of all, let’s create a directory for the configuration needed:

mkdir release-notifier

Then, let’s create a config.json file that contains the settings needed to push the notifications.

touch config.json

Open the file with your preferred editor, and add the following content

{
 "req-body": {
   "from": "Release Notifier",
   "message_format": "text",
   "color": "red",
   "notify": "true"
 },
 "settings": {
   "api-token": "...",
   "room": "HipchatTest"
 }
}

The “req-body” value follows request body format of the room notification Hipchat v2 API.

In the “settings” section, we will configure the API token and room name values with those obtained in the Step 2.

Now, let’s write the message we want to communicate to our room.

You have 2 options:

Option 1, inline message:

ahn --config=./config.json --message=”Hi @all, I’m glad to announce that a new release has been made"

Option 2, create a text file

touch message.txt

Open the message.txt file with your preferred editor, then add the message you would like, for  example:

Screen Shot 2016-05-26 at 8.06.50 PM

Since we chose the “message-format” as “text” we’re able to include @mentions, emoticons, pastes and auto-detected URLs (Twitter, YouTube, images, etc). For further information check the room notification Hipchat v2 API.

Everything is ready.  Let’s test our configuration:

ahn --config=./config.json --template=./message.txt

 

1 thought on “How to push notifications into your HipChat Room”

Leave a Reply

Your email address will not be published. Required fields are marked *