Skip to content

Instantly share code, notes, and snippets.

Created July 7, 2016 21:13
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
A custom event transformer to create incidents from Cisco Spark
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment