Welcome to the xMatters community!

We created this site for our customers and partners and we encourage you to explore, engage, and learn. To ensure that this community is fun and helpful, professional and respectful participation is expected... and troll-like behavior won't be tolerated.

GIG: Would you like your xM On Call info displayed HipChat or Slack?

xMatters is versatile. You can hook anything into xMatters up to and including the kitchen sinkoven. So, when our friend Kirk needed a little help getting On Call information into HipChat, I managed to whip together a script to do just that. But then why stop there? I already had code for talking to Slack (and we also have a fully built integration here), so I thought it would be cool to see them both in one place.

The trick to this is actually in the calls to the xMatters API. Since we can abstract those calls into a function (and maybe some day into a shared function....;) then all we have to do is parse out the group name from the incoming data from the slash command from either system and pass it into our function and Voila!

The following will assume you've set up (or will set up) slash commands (links: Hipchat or Slack, or check the xMatters integration install docs Hipchat or Slack).

Hipchat

First, we'll pick apart the Hipchat code. Create a new inbound integration that runs a script, like so:

To tell xMatters where to put this, login to the Hipchat admin page and click the integrations button. Click Build Your Own. Select the room and give the integration a name. Then copy the "Send messages to this room by posting to this URL" url into a new endpoint in the integration builder in xMatters and name it "Hipchat".

Slack

To do the same in Slack, again, create a new inbound integration in your Slack Comm Plan:

Finally, you'll need to create an inbound webhook into Slack. From within Slack click the team name > Apps & Integrations. Then click Build in the upper right corner > Make a custom integration. (Or click here). Click Incoming Webhook and select a channel. Then copy the Webhook URL into a new endpoint in the integration builder in xMatters and name it "Slack".

Conclusion

If you inspect each code block, you will see that they are largely the same! The only differences are around how we communicate back to the source system. HipChat has its API and Slack has its own, but we've abstracted much of that out and we can just focus on the xMatters API calls, which are the same regardless of where the originating request came from.

The end result:

There are some definite improvements that could be made. Pointedly around the start and end time. I suppose we could add another xM API call to get the timezone of the xMatters user making the request (if they exist... er, exist in xMatters) and modify the start time into their timezone.

I could also see improvements around the formatting. UI design isn't my strong suit (but I'm learning!!). This is where it gets a little tricky though. HipChat can support HTML tags but Slack instead uses a form of markdown. The script above just formats using raw strings and new lines. Functional, but don't tell the UX people!