Adding Some Colour to Microsoft Teams Notifications

Now that the basic link is in place between On-Premise TFS and Microsoft Teams it’s time to tinker.

The first thing that I wanted to do was add some visual feedback to the notifications, specifically notifications for builds.

This can be achieved by adding the “themeColor” property to our output (the Card Reference documentation suggests not to use this for status, but it works well enough )

I want two new statuses, failed build should be red whilst partial failures should be orange.

To do this I needed to update the output section for each endpoint as below:

Build Failure

var output = {};

output["title"] = "Build Failed";
output["text"] = detail;
output["themeColor"] = "ff0000";

Partial Build Failure

var output = {}; 

output["title"] = "Build Partial Failure";
output["text"] = detail;
output["themeColor"] = "ff9900";

This results in a nice visible orange and red bar at the top of each post:

build-failure-coluration

 

Bridging On-Premise TFS and Microsoft Teams using Web Hooks and Node.js

At the beginning of this year Microsoft release their Slack competitor Microsoft Teams. After having recently migrated Exchange,Skype and SharePoint to Office 365 this seemed a natural next step for us.

My main use for Slack was as a central point for notifications from other applications such as StatusCake and Team Foundation Server. Unfortunately whilst the web hooks were compatible with Microsoft’s online offering of Visual Studio Team Services the output from an on-premise Team Foundation Server (in this case TFS 2015 Update 2) was different. This killed the usefulness of Teams for us completely.

Fast forward to now and I decided to revisit this issue and see if any progress had been made. Unfortunately Microsoft still does not have official support for this however I came across this post which gave me some hope I might be able to work around this.

Taking this code and making some modifications I was able to create a node.js based Windows service that translates the JSON from TFS and forwards it to Microsoft Teams in a format it understands.

Here’s how I did it.

Continue reading