Integrating K2 with Atlassain HipChat

Inspired from my Boss’s (Simon Allport)’s post Slack & K2 Integration I have tried integrating K2 with HipChat and have created a small sample POC for you to look at.

Just to introduce you HipChat, which is an Atlassian Product used for team messaging and Collaboration. For more information you can visit About HipChat.

And to explain about this Sample POC, I have created a sample LeaveApproval Process which will assign the approval task to some User and will send Task Notification in HipChat to that User.

To achieve this we need a HipChat account which we can create here SignUp.

Once the account has been created, login with those Credentials. After you login you need to click on Launch the web app button which would navigate to the page where you can create a room.

Create a room using the link (Create a room) and give it a name, here I have named it as Leave Approval Tasks, and I have added all the approvers (Use Invite Your team) who gets assigned with Leave Approval Requests. So whenever an approval task gets assigned to someone, K2 would send a Task Notification to this room. To make this happen we need create an integration to this room, to do this we need select the room on left panel and click on +Add integrations.


Now Select your room in the dropdown above and give your integration a name in the textbox below (Here I named it as Leave Approval Task) and click Create Button


Once you create an integration you will be redirected to a page as shown below where you would see a URL which you can use to Send Notifications to this particular room. Along with the Url you will see a authentication token which we need to use while sending notifications to this room.

Also at the bottom of the page you see a section Extend HipChat with your Commands, we would talk about this section later in this post as it would be a very useful feature that we can use.


Now our HipChat room is ready to receive notifications. Please make a note of Authentication token and room id from the URL as we are going to use them in code.

Alternatively we can generate authentication token for sending notification using the token generation page as shown below. This generated token can be used in API code.


Let us create an assembly which sends notification to the room which we have created above, this assembly uses HipChat API. So we need to add a reference to it.

For Installing HipChat API run below command in Nuget Package Manager Console. As HipChat API is built on ServiceStack.text 4.0.56 version we need to add the reference of that specific version too, else the code doesn’t work. So execute below commands for adding their references

Install-Package Hipchat-CS
Install-Package ServiceStack.Text -Version 4.0.56

Now add a method as shown below which takes few parameters and creates an HTML Text to send as a notification.

using System;
using HipchatApiV2;
using HipchatApiV2.Enums;

namespace POC.HipChat
 public class SendMessage
 public static string SendHipChatNotification(string UserName, string RequestID, string Originator, string SubmittedDate)

//Room Id – You can get from the integration 
 int RoomID = 0123456;
 //Auth Token which you see while creating Integration
 string Auth_Token = "xx**xxc**xxnhfM***WWE0K***IjEsy***ve";
 string htmlMessage, returnMessage;
 //Form the HTML of Notification with param values
htmlMessage = "<table border='1' style='border-style: solid; border-width: thin; width: 50%; background-color: greenyellow'><tr><td style='width: 7%'>" +
"<img src='link' height='40px' width='50px' /></td>" +
"<td style='width: 90%'>" +
 "<span id='spnMessage' style='font-family: Calibri'>Hey " + UserName + "!! A Leave Approval Request With Request ID : <b>" +
 RequestID + "</b> has been Submitted by <b>" + Originator + "</b> on <b>" + SubmittedDate + "</b> and is pending for your Approval. Please Act upon!!</span>" +

 var client = new HipchatClient(Auth_Token);
 client.SendNotification(RoomID, htmlMessage, RoomColors.Green, false, HipchatMessageFormat.Html);
 returnMessage = "Success";
 catch (Exception ex)
 returnMessage = "Failed " + ex.Message; 
 return returnMessage;


**once the assembly POC.HipChat is built copy the assembly along with HipchatApiV2 & ServiceStack.Text assemblies to C:ProgramFiles/K2BlackPearl/Bin folder

 Now Create an Endpoint Assembly Service Instance as shown below. Here I have named it as POC.HipChat


Once the service instance has been created, you should be able to see the DLL method as shown below.


Now create an SMO for the method using this service instance. Here I have named it as POC.HipChat.SMO


Now our SMO is ready to send Task Notifications to HipChat. Now it’s just calling this method when required to send task notification.

I have created a sample Leave Approval Process which assigns a task to user and sends the notification to room when it assigns the task, also a SmartForm to submit the Leave Request.


Submit Form


I have submitted few requests as you can see in process overview as below


Now let’s see how K2 workflow have sent Leave Approval Task notifications to room with the details in the below screen shot.

Here you see the notifications in HipChat Web Browser


And here as we can see it in HipChat Mobile Notification


This is how we can make use of HipChat to receive K2 Notifications.

Now we can extend this POC to send Task Notification along with actions Approve & Reject Links so that the user can perform the action directly from HipChat itself.

Also in HipChat we have a feature to Extend HipChat with our own Commands, which they call as slash ‘/’ Commands. These slash commands can be used to send requests and get a response back from any server.

Now using these /Commands we can create some custom commands to gettasklist, taskcount, or perform any operation based on our requirements, some thing like below

  • /TaskList                                             –             To Get all active Task List
  • /TaskList {UserName}                      –             To get the Task List of that particular user
  • /ActionTask {SN},{ActionName}    –             To Perform a task based on SN.

This is how we can make use of HipChat and its features to integrate with K2.


Author: Vijay

I'm a K2 Certified Developer, helping teams to automate, design, develop & maintain business process applications connecting across multiple platforms with multiple technologies.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s