{ "nodes": [ { "name": "Error Trigger", "type": "n8n-nodes-base.errorTrigger", "position": [ 450, 300 ], "parameters": {}, "typeVersion": 1, "id": "email-gmail-workflow-failure-alert-0" }, { "id": "email-gmail-workflow-failure-alert-1", "name": "Prepare failure details", "type": "n8n-nodes-base.code", "typeVersion": 2, "parameters": { "mode": "runOnceForAllItems", "jsCode": "const x=$input.first().json,w=x.workflow??{},e=x.execution??{},err=e.error??{};if(typeof w.name!=='string'||!w.name)throw Error('Missing workflow name');const name=w.name.replace(/[\\r\\n]+/g,' '),v=x=>typeof x==='string'&&x?x:'not available';return [{json:{subject:'Workflow failure: '+name,body:'Workflow: '+w.name+'\\nExecution URL: '+v(e.url)+'\\nLast node: '+v(e.lastNodeExecuted)+'\\nError: '+v(err.message)+'\\nStack trace: '+v(err.stack)}}];" } }, { "name": "Gmail", "type": "n8n-nodes-base.gmail", "position": [ 650, 300 ], "parameters": { "sendTo": "YOUR_ALERT_EMAIL", "subject": "={{ $json.subject }}", "message": "={{ $json.body }}", "emailType": "text", "options": { "appendAttribution": false } }, "typeVersion": 2, "id": "email-gmail-workflow-failure-alert-2" } ], "connections": { "Error Trigger": { "main": [ [ { "node": "Prepare failure details", "type": "main", "index": 0 } ] ] }, "Prepare failure details": { "main": [ [ { "node": "Gmail", "type": "main", "index": 0 } ] ] } }, "name": "Email a Workflow Failure Alert with Gmail", "active": false, "settings": { "executionOrder": "v1" }, "pinData": {} }