Using Clubhouse's Webhooks to announce ticket completion in Slack via Microsoft Flow

This was written by our wonderful customer Tom Allen from Cooltrax.

 
Clubhouse is a great tool for software teams to manage their work. It includes a Slack integration that can pick up ticket URLs in chats and expand them with details, and can also generate a message feed of activity on those tickets.

What it can't do however, is narrow down that firehose to just a few types of activity that are of interest. This post shows how to use Microsoft Flow (similar to IFTTT or Zapier) and Clubhouse's webhooks to build it yourself.

In the gallery below, you can see the gist of the flow:
 
The flow's trigger is receipt of a JSON payload into a webhook destination. This webhook URL is added to Clubhouse's webhook integration in the Clubhouse settings.
 
The schema of that JSON is automatically created by posting in a sample payload from Clubhouse's webhooks API documentation (or just copy the code sample shown below)

A few conditions are checked - `actions` is present and set to `update`, `changes` exists under that and is set to `completed`, etc - and finally the inner block of JSON under `changes` is parsed to expose the fields of interest.


 

Finally, a message is posted to Slack that reports the activity type we're interested in.

 
 
Ultimately, the output ends up as a nicely formatted Slack message with a direct link back to the original ticket. The flow itself runs once per activity on any Clubhouse ticket, but only posts to Slack for those activities that we actually care about.
 
It would be great if Clubhouse would update their Slack integration to allow us to use multiple of them per workspace, and filter the output directly - but until that's possible, this hack has helped us raise the signal to noise ratio!

It's also possible to query the Clubhouse API directly from a flow (or an IFTTT, or a Zap). For example, I could have updated this to query the ticket details and pull out the owner's names, or the date it was started, etc. I'll leave that as an exercise for the reader...
 
 

JSON Schema for Base Webhook Payload

{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"changed_at": {
"type": "string"
},
"primary_id": {
"type": "integer"
},
"member_id": {
"type": "string"
},
"version": {
"type": "string"
},
"actions": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"entity_type": {
"type": "string"
},
"action": {
"type": "string"
},
"name": {
"type": "string"
},
"changes": {
"type": "object",
"properties": {
"started": {
"type": "object",
"properties": {
"new": {
"type": "boolean"
},
"old": {
"type": "boolean"
}
}
},
"workflow_state_id": {
"type": "object",
"properties": {
"new": {
"type": "integer"
},
"old": {
"type": "integer"
}
}
},
"owner_ids": {
"type": "object",
"properties": {
"adds": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
},
"required": [
"id",
"entity_type",
"action",
"name",
"changes"
]
}
},
"references": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"entity_type": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"id",
"entity_type",
"name"
]
}
}
}
}
 

JSON Schema for `changes` payload

{
"type": "object",
"properties": {
"started": {
"optional": true,
"type": "object",
"properties": {
"new": {
"type": "boolean"
},
"old": {
"type": "boolean"
}
}
},
"completed": {
"optional": true,
"type": "object",
"properties": {
"new": {
"type": "boolean"
},
"old": {
"type": "boolean"
}
}
}
}
}

Didn't find what you were looking for?

New post
Would you like to add your +1 to this post?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.