Skip to content

Instantly share code, notes, and snippets.

@norberttech
Created September 16, 2019 21:43
Show Gist options
  • Save norberttech/a62654b7cf894bd64f753a0b9e90a2e8 to your computer and use it in GitHub Desktop.
Save norberttech/a62654b7cf894bd64f753a0b9e90a2e8 to your computer and use it in GitHub Desktop.
Azure Logic Apps connector that translates PagerDuty extension requests into Google Chat expected webhooks
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"For_each": {
"actions": {
"Condition": {
"actions": {
"HTTP": {
"inputs": {
"body": {
"text": "*event*: @{items('For_each')?['event']}\n*title*: `@{items('For_each')?['incident']?['title']}`\n*url*: <@{items('For_each')?['incident']?['html_url']}|url>"
},
"method": "POST",
"uri": "https://chat.googleapis.com/v1/spaces/XXXXXXXXX/messages?key=XXXXXXXXXXXXX&token=XXXXXXXXXXXXX"
},
"runAfter": {},
"type": "Http"
}
},
"expression": {
"and": [
{
"not": {
"equals": [
"@items('For_each')?['event']",
"incident.annotate"
]
}
},
{
"not": {
"equals": [
"@items('For_each')?['event']",
"incident.assign"
]
}
},
{
"not": {
"equals": [
"@items('For_each')?['event']",
"incident.escalate"
]
}
}
]
},
"runAfter": {},
"type": "If"
}
},
"foreach": "@body('Parse_JSON')?['messages']",
"runAfter": {
"Parse_JSON": [
"Succeeded"
]
},
"type": "Foreach"
},
"Parse_JSON": {
"inputs": {
"content": "@triggerBody()",
"schema": {
"properties": {
"messages": {
"items": {
"properties": {
"created_on": {
"type": "string"
},
"event": {
"type": "string"
},
"id": {
"type": "string"
},
"incident": {
"properties": {
"html_url": {
"type": "string"
},
"title": {
"type": "string"
}
},
"type": "object"
}
},
"required": [
"event",
"incident"
],
"type": "object"
},
"type": "array"
}
},
"type": "object"
}
},
"runAfter": {},
"type": "ParseJson"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"manual": {
"inputs": {
"schema": {}
},
"kind": "Http",
"type": "Request"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment