Operator Error

adventures in software development and continuous learning

Send a Message to a HipChat Room Using cURL

If you are unfamiliar with HipChat, its a persistent chat room used for team collaboration. With its abundance of features, one that stands out is the ability to utilize the HipChat API to send notifications messages to your team rooms. Notifications are great for letting everyone on your team know an event of significance has occurred. Examples include commits to your source code repository, continuous integration results, or when an extremely angry user adds a new issue to the bug tracker.

Build passes!

While many web based services offer hooks to make sending notification message to HipChat easy (such as Github), what if you want to send a notification from an existing Bash script that you use everyday? Well you’re in luck, because the HipChat API makes this extremely easy to do using cURL!

NOTE: If you haven’t generated a HipChat API Token yet, learn to do so here.

hipchat.shView Gist
1
2
3
4
5
# Build Passes
curl -d "room_id=ourRoom&from=BuildBot&message=Build+Status:+Passing&color=green" https://api.hipchat.com/v1/rooms/message?auth_token=AUTH_TOKEN_HERE&format=json

# Build Fails
curl -d "room_id=ourRoom&from=BuildBot&message=Build+Status:+Failing&color=red&notify=1" https://api.hipchat.com/v1/rooms/message?auth_token=AUTH_TOKEN_HERE&format=json

NOTE: Make sure to change the parameters to fit your application and insert your authentication token!

HipChat API notification messages have some neat features, such as colors and notify. This makes it easy making it easy to instantly indicate to your team via HipChat if something erroneous has occurred (such as failed unit tests).

Be sure to check out the full HipChat API documentation for sending messages to rooms.

Comments