Building a Chat Integration for Cisco Spark in Minutes

by David Hayes July 12, 2016 | 4 min read

In time for day two of Cisco Live, we thought it would be timely to build an integration for Cisco Spark and PagerDuty. So we did–and it only took a few minutes, and we were able to easily embed custom rules and functionality. We did this via the PagerDuty Custom Event Transformer–a very cool feature we launched a few weeks ago that enables you to convert a payload sent by any tool that can send an HTTP request into one understood by PagerDuty. In other words, you can integrate virtually anything with PagerDuty.

This Spark – PagerDuty integration is just one proof point out of many more similar examples to come, that we can easily integrate with any ChatOps (or other) tool to optimize any workflow and extend functionality in any way a customer may desire.

Like many tools, Cisco Spark works great with PagerDuty out of the box, and you can send PagerDuty incidents into your Spark chat rooms. Today we’re going to build an integration that enables the reverse–it will enable you to trigger PagerDuty incidents from within Spark.

I’m going to do a few things differently from our other native Slack->PD & Hipchat->PD integrations to show off the fact that, with the Custom Event Transformer, you can very easily structure integrations to enable custom functionality, and the possibilities are endless.

My new Cisco Spark – PagerDuty integration will have the following features:

  • This integration will have a dedicated room, any requests for help in that room will trigger PD (instead of filtering for slash commands)
  • All the chat messages in that room will get rolled into the same PD incident (by using the room as the incident_key)
  • That incident can be closed manually from PD or by saying “thanks”

There are a few things specific to Cisco Spark webhooks that I’ll convert:

  • All URLs are base64 encoded
  • Since I’m using the web client, I’ll change URLs from “ciscospark://us/ROOM/” to “”

Let’s see how that all comes together. To try this yourself, create a Custom Event Transformer with the following code:

  function transform(PD) {
    var webhook = PD.inputRequest.body
    var message = webhook.text || "Error: Not a Spark chat message";
    var room_link = ciscospark2web(b64decode(webhook.roomId)); // clean up the link
    var normalized_event = {
      incident_key: room_link, //So that all messages from a room de_dupee into the same incident
      event_type: PD.Trigger,
      description: message,
      details: {
        email: webhook.personEmail
      client: "Cisco Spark",
      client_url: room_link

    // If the message is "thanks" => automatically close the incident
    if (message.toLowerCase() == "thanks") {
      normalized_event.event_type = PD.Resolve;

    // Create the PD event

  // Helper functions:
  function b64decode(b) {
    return new Buffer(b || "", "base64").toString("utf8");

  function ciscospark2web(url) {
    // from: ciscospark://us/ROOM/31ce2d70-3f09-11e6-946f-11a974144a8d
    // to:
    return url.replace("ciscospark://us/ROOM/", "")
    // TODO: Links to 1-1 chats & direct to messages

Hit save and your integration will look like this:

Plugging it into Cisco Spark

Once you’ve created your Custom Event Transformer in PagerDuty, point a Cisco Spark “Outbound webhook” at the




How does it look in action?

Here are a few chat messages in Spark:


And in PagerDuty: Notice that the second message is appended to the log, just like I had wanted!



And if the requester says “Thanks,” it’ll automatically close in PagerDuty.


To sum it up, our Spark – PagerDuty integration was easily configured as an outbound webhook in a couple clicks, and it adhered to all the custom rules and functionality that I defined in my code.

Tips for writing your own Custom Event Transformer

Again, the best part of all this is that you can do this too, and for any use case.

I typically use Runscope API Traffic Inspector to proxy all my webhooks around because it lets me see, modify and re-send them. So during development, I’ll point tools at You can see one of the Spark events I tested.

Learn more about Custom Event Transformer and get started with creating your own to integrate anything with PagerDuty. And to all of those at Cisco Live, enjoy the rest of your time at the conference and be sure to find us at Booth #1611 for a live demo, and for those of you in the Bay Area on Sept 13th, be sure to stop by and visit us at our very own PagerDuty Summit, where leaders from Google, Linkedin, IBM and Yahoo will share their key learnings for building a modern operations environment.