{ "kind": "open-flow-workflow", "version": 1, "name": "Notify Workflow Errors by Mattermost and SMS", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_55b9addd5bcc302e": { "name": "Receive a workflow failure", "kind": "error", "sourceFlowIds": [] }, "n_c86c8fd5eb73ad77": { "inputs": { "workflow": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_55b9addd5bcc302e", "output": "workflow" } ] }, "error": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_55b9addd5bcc302e", "output": "error" } ] }, "channelId": { "kind": "value", "value": "YOUR_MATTERMOST_CHANNEL_ID" }, "to": { "kind": "value", "value": "YOUR_RECIPIENT_NUMBER" }, "from": { "kind": "value", "value": "YOUR_TWILIO_NUMBER" } }, "name": "Prepare error alerts", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "workflow" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "error" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "channelId" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "to" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "from" } ], "outputs": [ { "jsonSchema": { "type": "string", "minLength": 1, "description": "A Mattermost object ID." }, "nullable": false, "handle": "channelId" }, { "jsonSchema": { "type": "string", "description": "The destination phone number in E.164 format." }, "nullable": false, "handle": "to" }, { "jsonSchema": { "type": "string", "description": "The Twilio phone number sending the message." }, "nullable": false, "handle": "from" }, { "jsonSchema": { "type": "string", "minLength": 1, "description": "The Markdown message body to post." }, "nullable": false, "handle": "message" }, { "jsonSchema": { "type": "string", "description": "The text body of the outbound message." }, "nullable": false, "handle": "sms" } ], "name": "Prepare error alerts", "moduleId": "n_ccc514a4b913e69a", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_8ecef4ab9eca647d": { "inputs": { "channelId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c86c8fd5eb73ad77", "output": "channelId" } ] }, "message": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c86c8fd5eb73ad77", "output": "message" } ] } }, "name": "Post the error to Mattermost", "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 the error to Mattermost", "executor": { "kind": "connector", "action": "mattermost.create_post" } } }, "n_0d3664f76fb9a907": { "inputs": { "to": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c86c8fd5eb73ad77", "output": "to" } ] }, "from": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c86c8fd5eb73ad77", "output": "from" } ] }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c86c8fd5eb73ad77", "output": "sms" } ] } }, "name": "Send the SMS alert", "kind": "task", "task": { "inputs": [ { "description": "The destination phone number in E.164 format.", "jsonSchema": { "type": "string", "description": "The destination phone number in E.164 format." }, "nullable": false, "handle": "to" }, { "description": "The Twilio phone number sending the message.", "jsonSchema": { "type": "string", "description": "The Twilio phone number sending the message." }, "nullable": false, "handle": "from" }, { "description": "The text body of the outbound message.", "jsonSchema": { "type": "string", "description": "The text body of the outbound message." }, "nullable": false, "handle": "body" } ], "outputs": [ { "description": "The Twilio message SID.", "jsonSchema": { "type": "string", "description": "The Twilio message SID." }, "nullable": false, "handle": "messageSid" }, { "description": "The Twilio account SID that owns the message.", "jsonSchema": { "type": [ "string", "null" ], "description": "The Twilio account SID that owns the message." }, "nullable": true, "handle": "accountSid" }, { "description": "The delivery status of the message.", "jsonSchema": { "type": [ "string", "null" ], "description": "The delivery status of the message." }, "nullable": true, "handle": "status" }, { "description": "The destination phone number.", "jsonSchema": { "type": [ "string", "null" ], "description": "The destination phone number." }, "nullable": true, "handle": "to" }, { "description": "The sender phone number.", "jsonSchema": { "type": [ "string", "null" ], "description": "The sender phone number." }, "nullable": true, "handle": "from" }, { "description": "The text body of the message.", "jsonSchema": { "type": [ "string", "null" ], "description": "The text body of the message." }, "nullable": true, "handle": "body" } ], "name": "Send the SMS alert", "executor": { "kind": "connector", "action": "twilio.send_message" } } } }, "edges": [ { "source": "n_55b9addd5bcc302e", "target": "n_c86c8fd5eb73ad77" }, { "source": "n_c86c8fd5eb73ad77", "target": "n_8ecef4ab9eca647d" }, { "source": "n_8ecef4ab9eca647d", "target": "n_0d3664f76fb9a907" } ] } }, "modules": { "n_ccc514a4b913e69a": { "name": "Prepare error alerts", "imports": [], "source": "export default function workflowErrorAlert({workflow,error,channelId,to,from}){if(!workflow||typeof workflow.name!=='string'||!workflow.name||typeof workflow.flowId!=='string'||!workflow.flowId)throw Error('Missing workflow identity');if(typeof channelId!=='string'||!channelId.trim()||channelId==='YOUR_MATTERMOST_CHANNEL_ID')throw Error('Configure Mattermost channel');for(const n of [to,from])if(typeof n!=='string'||!/^\\+[1-9]\\d{7,14}$/.test(n))throw Error('Configure Twilio numbers in E.164 format');const name=workflow.name.replace(/[\\r\\n]+/g,' '),id=workflow.flowId.replace(/[\\r\\n]+/g,' '),node=typeof error?.nodeId==='string'&&error.nodeId?error.nodeId:'not available',base=`The workflow named '${name}' with the ID ${id} has encountered an error.`;return{channelId,to,from,sms:base,message:base+' The failed node ID was '+node+'.'};}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }