{ "id": "kubWVFN16Jar4v4Q", "name": "Audiobook Notification Router", "nodes": [ { "parameters": {}, "id": "workflow-trigger", "name": "Execute Workflow Trigger", "type": "n8n-nodes-base.executeWorkflowTrigger", "typeVersion": 1.1, "position": [ 100, 300 ] }, { "parameters": { "operation": "send", "sendTo": "admin@ben.io", "subject": "={{ $json.emailSubject }}", "message": "={{ $json.emailHtmlBody }}", "options": {} }, "id": "send-gmail", "name": "Send Gmail", "type": "n8n-nodes-base.gmail", "typeVersion": 2.1, "position": [ 700, 200 ], "credentials": { "gmailOAuth2": { "id": "Os1ux3h3zFlC2XkG", "name": "Gmail account" } } }, { "parameters": { "assignments": { "assignments": [ { "id": "status", "name": "status", "value": "sent", "type": "string" } ] } }, "id": "return-status", "name": "Return Status", "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ 900, 200 ] }, { "id": "685a8518-fcbf-4a0c-84d0-3ab4dacb61a4", "name": "Build Email HTML (Item)", "type": "n8n-nodes-base.functionItem", "typeVersion": 1, "position": [ 500, 200 ], "parameters": { "functionCode": "const torrentCount = Number($json.torrent_count) || 0;\nconst torrents = Array.isArray($json.torrents) ? $json.torrents : [];\n\nfunction getMAMStatus(t) {\n return t.mam_torrent_id\n ? `✅ Yes`\n : '❌ No';\n}\n\nconst rows = torrents.length\n ? torrents.map(t => `\n \n ${t.title || ''}\n ${t.seeders ?? ''}\n ${t.size || ''}\n ${getMAMStatus(t)}\n ${t.link ? `Download` : ''}\n \n `).join('')\n : 'No torrents this run';\n\nconst emailHtmlBody = `\n

${torrentCount} New Audiobook Torrent(s) Found

\n \n \n \n \n \n \n \n \n \n \n \n ${rows}\n \n
TitleSeedersSizeOn MAM?Links
\n`;\n\nreturn {\n emailSubject: `${torrentCount} New Audiobook Torrent(s) Found`,\n emailHtmlBody,\n torrentCount,\n};" } } ], "connections": { "Send Gmail": { "main": [ [ { "node": "Return Status", "type": "main", "index": 0 } ] ] }, "Execute Workflow Trigger": { "main": [ [ { "node": "Build Email HTML (Item)", "type": "main", "index": 0 } ] ] }, "Build Email HTML (Item)": { "main": [ [ { "node": "Send Gmail", "type": "main", "index": 0 } ] ] } }, "settings": { "saveExecutionProgress": true, "saveManualExecutions": true, "saveDataErrorExecution": "all", "saveDataSuccessExecution": "all", "executionOrder": "v1" }, "triggerCount": 0, "versionId": "8496ee58-493a-4604-bba1-e06c5b27879a", "owner": { "type": "personal", "projectId": "FeLO36wNUAcn61Wj", "projectName": "Ben W ", "personalEmail": "admin@ben.io" }, "parentFolderId": "kUg4HIPXraph3M0E", "isArchived": false }