{ "kind": "open-flow-workflow", "version": 1, "name": "Email a Workflow Failure Alert with Gmail", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_2adb26e3d1d63a85": { "name": "Receive a workflow failure", "kind": "error", "sourceFlowIds": [] }, "n_0d3a1b6a2a9593f8": { "inputs": { "workflow": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_2adb26e3d1d63a85", "output": "workflow" } ] }, "execution": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_2adb26e3d1d63a85", "output": "execution" } ] }, "error": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_2adb26e3d1d63a85", "output": "error" } ] } }, "name": "Prepare failure details", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "workflow" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "execution" }, { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "error" } ], "outputs": [ { "jsonSchema": { "type": "string", "description": "Email subject line." }, "nullable": true, "handle": "subject" }, { "jsonSchema": { "type": "string", "description": "Email body content." }, "nullable": true, "handle": "body" } ], "name": "Prepare failure details", "moduleId": "n_292d1b32b54b378c", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_f158a15b51bafd3a": { "inputs": { "to": { "kind": "value", "value": "YOUR_ALERT_EMAIL" }, "subject": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_0d3a1b6a2a9593f8", "output": "subject" } ] }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_0d3a1b6a2a9593f8", "output": "body" } ] }, "isHtml": { "kind": "value", "value": false } }, "name": "Send failure email", "kind": "task", "task": { "inputs": [ { "description": "Primary recipient email address.", "jsonSchema": { "type": "string", "description": "Primary recipient email address." }, "nullable": true, "handle": "to", "value": null }, { "description": "Additional To recipients.", "jsonSchema": { "type": "array", "items": { "type": "string", "description": "An array item." }, "description": "Additional To recipients." }, "nullable": true, "handle": "extraRecipients", "value": null }, { "description": "Cc recipients.", "jsonSchema": { "anyOf": [ { "type": "string", "description": "A union variant." }, { "type": "array", "items": { "type": "string", "description": "An array item." }, "description": "A union variant." } ], "description": "Cc recipients." }, "nullable": true, "handle": "cc", "value": null }, { "description": "Bcc recipients.", "jsonSchema": { "anyOf": [ { "type": "string", "description": "A union variant." }, { "type": "array", "items": { "type": "string", "description": "An array item." }, "description": "A union variant." } ], "description": "Bcc recipients." }, "nullable": true, "handle": "bcc", "value": null }, { "description": "Email subject line.", "jsonSchema": { "type": "string", "description": "Email subject line." }, "nullable": true, "handle": "subject", "value": null }, { "description": "Email body content.", "jsonSchema": { "type": "string", "description": "Email body content." }, "nullable": true, "handle": "body", "value": null }, { "description": "Set to true when the body content is already HTML.", "jsonSchema": { "type": "boolean", "description": "Set to true when the body content is already HTML." }, "nullable": true, "handle": "isHtml", "value": null }, { "description": "Attachments and CID inline images. Up to 25,000,000 decoded bytes in total and 35,000,000 MIME bytes.", "jsonSchema": { "type": "array", "items": { "type": "object", "properties": { "filename": { "type": "string", "description": "Attachment filename; omit for an unnamed attachment." }, "mimeType": { "type": "string", "description": "MIME type without parameters; defaults to application/octet-stream." }, "contentBase64": { "type": "string", "description": "Standard padded Base64 content. Empty string represents a zero-byte file. Supply this or fileUrl." }, "fileUrl": { "type": "string", "format": "uri", "description": "Public URL to download the attachment. Supply this or contentBase64." }, "contentId": { "type": "string", "minLength": 1, "description": "Bare Content-ID without cid: or angle brackets; reference it as cid: in HTML." }, "disposition": { "type": "string", "enum": [ "inline", "attachment" ], "description": "Defaults to inline when contentId is set, otherwise attachment. Inline requires contentId." } }, "additionalProperties": false, "description": "An attachment or CID inline resource.", "oneOf": [ { "required": [ "contentBase64" ] }, { "required": [ "fileUrl" ] } ] }, "maxItems": 100, "description": "Attachments and CID inline images. Up to 25,000,000 decoded bytes in total and 35,000,000 MIME bytes." }, "nullable": true, "handle": "attachments", "value": null }, { "description": "Verified Gmail send-as alias to use in the From header.", "jsonSchema": { "type": "string", "description": "Verified Gmail send-as alias to use in the From header." }, "nullable": true, "handle": "fromEmail", "value": null } ], "outputs": [ { "description": "Gmail message ID.", "jsonSchema": { "type": "string", "description": "Gmail message ID." }, "nullable": false, "handle": "messageId" }, { "description": "Gmail thread ID.", "jsonSchema": { "type": "string", "description": "Gmail thread ID." }, "nullable": true, "handle": "threadId" } ], "name": "Send failure email", "executor": { "kind": "connector", "action": "gmail.send_email" } } } }, "edges": [ { "source": "n_2adb26e3d1d63a85", "target": "n_0d3a1b6a2a9593f8" }, { "source": "n_0d3a1b6a2a9593f8", "target": "n_f158a15b51bafd3a" } ] } }, "modules": { "n_292d1b32b54b378c": { "name": "Prepare failure details", "imports": [], "source": "export default function prepare({workflow,execution,error}){if(typeof workflow?.name!=='string'||!workflow.name||typeof execution?.runId!=='string'||!execution.runId||typeof error?.message!=='string')throw Error('Missing failure details');const name=workflow.name.replace(/[\\r\\n]+/g,' '),v=x=>typeof x==='string'&&x?x:'not available';return{subject:'Workflow failure: '+name,body:`Workflow: ${workflow.name}\\nRun ID: ${execution.runId}\\nNode ID: ${v(error.nodeId)}\\nJob ID: ${v(error.jobId)}\\nPath: ${Array.isArray(error.path)?JSON.stringify(error.path):'not available'}\\nError code: ${v(error.code)}\\nError: ${error.message}`}}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }