{ "kind": "open-flow-workflow", "version": 1, "name": "Acknowledge a PagerDuty Incident from Mattermost", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_4915fd37d93ad686": { "name": "Receive a Mattermost action", "kind": "webhook", "bodyFields": [ { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "channel_id" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "context" }, { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "user_id" }, { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "user_name" }, { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "channel_name" }, { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "team_id" }, { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "team_domain" }, { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "team_name" }, { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "post_id" }, { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "trigger_id" }, { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "type" }, { "jsonSchema": { "type": "string" }, "nullable": true, "handle": "data_source" } ], "method": "POST", "options": { "responseData": "{}", "responseHeaders": { "Content-Type": "application/json" }, "responseStatusCode": 200 } }, "n_dde0ee1f5c764c1e": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_4915fd37d93ad686", "output": "body" } ] }, "secret": { "kind": "unset" }, "from": { "kind": "value", "value": "YOUR_PAGERDUTY_EMAIL" } }, "name": "Validate the action", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "secret" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "from" } ], "outputs": [ { "jsonSchema": { "type": "string", "minLength": 1, "description": "PagerDuty resource ID." }, "nullable": false, "handle": "incidentId" }, { "jsonSchema": { "type": "string", "minLength": 1, "description": "A Mattermost object ID." }, "nullable": false, "handle": "channelId" }, { "jsonSchema": { "type": "string", "format": "email", "description": "Email address of the PagerDuty user acknowledging the incident. PagerDuty requires this header for write operations." }, "nullable": false, "handle": "from" } ], "name": "Validate the action", "moduleId": "n_3d13f386a26f577c", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_63051d76c571d4d8": { "inputs": { "incident_id": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_dde0ee1f5c764c1e", "output": "incidentId" } ] }, "from": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_dde0ee1f5c764c1e", "output": "from" } ] } }, "name": "Acknowledge the incident", "kind": "task", "task": { "inputs": [ { "description": "PagerDuty resource ID.", "jsonSchema": { "type": "string", "minLength": 1, "description": "PagerDuty resource ID." }, "nullable": false, "handle": "incident_id" }, { "description": "Email address of the PagerDuty user acknowledging the incident. PagerDuty requires this header for write operations.", "jsonSchema": { "type": "string", "format": "email", "description": "Email address of the PagerDuty user acknowledging the incident. PagerDuty requires this header for write operations." }, "nullable": false, "handle": "from" } ], "outputs": [ { "description": "PagerDuty incident record.", "jsonSchema": { "type": "object", "properties": { "id": { "type": "string", "minLength": 1, "description": "PagerDuty resource ID." }, "type": { "type": "string", "description": "PagerDuty incident object type." }, "summary": { "type": "string", "description": "Incident summary." }, "self": { "type": "string", "format": "uri", "description": "API URL for the incident." }, "html_url": { "type": "string", "format": "uri", "description": "Web URL for the incident." }, "incident_number": { "type": "integer", "description": "PagerDuty incident number." }, "title": { "type": "string", "description": "Incident title." }, "description": { "type": "string", "description": "Incident description." }, "status": { "type": "string", "enum": [ "triggered", "acknowledged", "resolved" ], "description": "Incident status." }, "urgency": { "type": "string", "enum": [ "high", "low" ], "description": "Incident urgency." }, "created_at": { "type": "string", "description": "Timestamp in ISO 8601 format." }, "updated_at": { "type": "string", "description": "Timestamp in ISO 8601 format." }, "service": { "type": "object", "properties": { "id": { "type": "string", "minLength": 1, "description": "PagerDuty resource ID." }, "type": { "type": "string", "description": "PagerDuty service reference type." }, "summary": { "type": "string", "description": "Service display summary." }, "self": { "type": "string", "format": "uri", "description": "API URL for the service." }, "html_url": { "type": "string", "format": "uri", "description": "Web URL for the service." } }, "additionalProperties": true, "description": "PagerDuty service reference." }, "assignments": { "type": "array", "items": { "type": "object", "properties": { "at": { "type": "string", "description": "Timestamp in ISO 8601 format." }, "assignee": { "type": "object", "properties": { "id": { "type": "string", "minLength": 1, "description": "PagerDuty resource ID." }, "type": { "type": "string", "description": "PagerDuty user reference type." }, "summary": { "type": "string", "description": "User display summary." }, "self": { "type": "string", "format": "uri", "description": "API URL for the user." }, "html_url": { "type": "string", "format": "uri", "description": "Web URL for the user." } }, "additionalProperties": true, "description": "PagerDuty user reference." } }, "additionalProperties": true, "description": "PagerDuty incident assignment." }, "description": "Current incident assignments." }, "escalation_policy": { "type": "object", "properties": { "id": { "type": "string", "minLength": 1, "description": "PagerDuty resource ID." }, "type": { "type": "string", "description": "PagerDuty escalation policy reference type." }, "summary": { "type": "string", "description": "Escalation policy display summary." }, "self": { "type": "string", "format": "uri", "description": "API URL for the escalation policy." }, "html_url": { "type": "string", "format": "uri", "description": "Web URL for the escalation policy." } }, "additionalProperties": true, "description": "PagerDuty escalation policy reference." } }, "additionalProperties": true, "description": "PagerDuty incident record." }, "nullable": false, "handle": "incident" } ], "name": "Acknowledge the incident", "executor": { "kind": "connector", "action": "pagerduty.acknowledge_incident" } } }, "n_484210e5c708e21c": { "inputs": { "incident": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_63051d76c571d4d8", "output": "incident" } ] }, "incidentId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_dde0ee1f5c764c1e", "output": "incidentId" } ] } }, "name": "Confirm the incident status", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "properties": { "id": { "type": "string", "minLength": 1, "description": "PagerDuty resource ID." }, "type": { "type": "string", "description": "PagerDuty incident object type." }, "summary": { "type": "string", "description": "Incident summary." }, "self": { "type": "string", "format": "uri", "description": "API URL for the incident." }, "html_url": { "type": "string", "format": "uri", "description": "Web URL for the incident." }, "incident_number": { "type": "integer", "description": "PagerDuty incident number." }, "title": { "type": "string", "description": "Incident title." }, "description": { "type": "string", "description": "Incident description." }, "status": { "type": "string", "enum": [ "triggered", "acknowledged", "resolved" ], "description": "Incident status." }, "urgency": { "type": "string", "enum": [ "high", "low" ], "description": "Incident urgency." }, "created_at": { "type": "string", "description": "Timestamp in ISO 8601 format." }, "updated_at": { "type": "string", "description": "Timestamp in ISO 8601 format." }, "service": { "type": "object", "properties": { "id": { "type": "string", "minLength": 1, "description": "PagerDuty resource ID." }, "type": { "type": "string", "description": "PagerDuty service reference type." }, "summary": { "type": "string", "description": "Service display summary." }, "self": { "type": "string", "format": "uri", "description": "API URL for the service." }, "html_url": { "type": "string", "format": "uri", "description": "Web URL for the service." } }, "additionalProperties": true, "description": "PagerDuty service reference." }, "assignments": { "type": "array", "items": { "type": "object", "properties": { "at": { "type": "string", "description": "Timestamp in ISO 8601 format." }, "assignee": { "type": "object", "properties": { "id": { "type": "string", "minLength": 1, "description": "PagerDuty resource ID." }, "type": { "type": "string", "description": "PagerDuty user reference type." }, "summary": { "type": "string", "description": "User display summary." }, "self": { "type": "string", "format": "uri", "description": "API URL for the user." }, "html_url": { "type": "string", "format": "uri", "description": "Web URL for the user." } }, "additionalProperties": true, "description": "PagerDuty user reference." } }, "additionalProperties": true, "description": "PagerDuty incident assignment." }, "description": "Current incident assignments." }, "escalation_policy": { "type": "object", "properties": { "id": { "type": "string", "minLength": 1, "description": "PagerDuty resource ID." }, "type": { "type": "string", "description": "PagerDuty escalation policy reference type." }, "summary": { "type": "string", "description": "Escalation policy display summary." }, "self": { "type": "string", "format": "uri", "description": "API URL for the escalation policy." }, "html_url": { "type": "string", "format": "uri", "description": "Web URL for the escalation policy." } }, "additionalProperties": true, "description": "PagerDuty escalation policy reference." } }, "additionalProperties": true, "description": "PagerDuty incident record." }, "nullable": false, "handle": "incident" }, { "jsonSchema": { "type": "string", "minLength": 1 }, "nullable": false, "handle": "incidentId" } ], "outputs": [ { "jsonSchema": { "type": "string", "minLength": 1, "description": "The Markdown message body to post." }, "nullable": false, "handle": "message" } ], "name": "Confirm the incident status", "moduleId": "n_1dcbcd739353df88", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_c5482642f1d27fff": { "inputs": { "channelId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_dde0ee1f5c764c1e", "output": "channelId" } ] }, "message": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_484210e5c708e21c", "output": "message" } ] } }, "name": "Post confirmation to the channel", "kind": "task", "task": { "inputs": [ { "description": "A Mattermost object ID.", "jsonSchema": { "type": "string", "minLength": 1, "description": "A Mattermost object ID." }, "nullable": false, "handle": "channelId" }, { "description": "The Markdown message body to post.", "jsonSchema": { "type": "string", "minLength": 1, "description": "The Markdown message body to post." }, "nullable": false, "handle": "message" }, { "description": "Optional root post ID for replying in a thread.", "jsonSchema": { "type": "string", "minLength": 1, "description": "Optional root post ID for replying in a thread." }, "nullable": true, "handle": "rootId", "value": null }, { "description": "Optional Mattermost post props object.", "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "Optional Mattermost post props object." }, "nullable": true, "handle": "props", "value": null } ], "outputs": [ { "description": "A Mattermost post object.", "jsonSchema": { "type": "object", "properties": {}, "additionalProperties": true, "description": "A Mattermost post object." }, "nullable": false, "handle": "post" }, { "description": "The raw Mattermost API JSON response.", "jsonSchema": { "description": "The raw Mattermost API JSON response." }, "nullable": false, "handle": "raw" } ], "name": "Post confirmation to the channel", "executor": { "kind": "connector", "action": "mattermost.create_post" } } } }, "edges": [ { "source": "n_4915fd37d93ad686", "target": "n_dde0ee1f5c764c1e" }, { "source": "n_dde0ee1f5c764c1e", "target": "n_63051d76c571d4d8" }, { "source": "n_63051d76c571d4d8", "target": "n_484210e5c708e21c" }, { "source": "n_484210e5c708e21c", "target": "n_c5482642f1d27fff" } ] } }, "modules": { "n_3d13f386a26f577c": { "name": "Validate the action", "imports": [], "source": "export default function planAcknowledgement({body,secret,from}){\n if(typeof secret!=='string'||secret.length<24||secret==='YOUR_ACTION_SECRET')throw Error('Configure a strong action secret');const received=body?.context?.action_secret;if(typeof received!=='string'||received!==secret)throw Error('Invalid action secret');const incident=body?.context?.pagerduty_incident,channel=body?.channel_id;if(typeof incident!=='string'||!incident.trim()||typeof channel!=='string'||!channel.trim())throw Error('Missing incident or channel');if(typeof from!=='string'||!/^\\S+@\\S+\\.\\S+$/.test(from)||from==='YOUR_PAGERDUTY_EMAIL')throw Error('Configure PagerDuty user email');return{incidentId:incident,channelId:channel,from};\n}\n" }, "n_1dcbcd739353df88": { "name": "Confirm the incident status", "imports": [], "source": "export default function confirmAcknowledgement({incident,incidentId}){if(!incident||incident.id!==incidentId||incident.status!=='acknowledged')throw Error('PagerDuty did not confirm acknowledgement');return{message:'💪🏼 Incident status has been changed to Acknowledged on PagerDuty.'};}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }