{ "meta": { "instanceId": "fcf18fc485cc336a31bc65574fd28e124660f468281b7aad773616b17903afe6", "templateCredsSetupCompleted": true }, "nodes": [ { "id": "de602925-4d9d-4045-9d9d-ed37dfb65490", "name": "HTML to PDF", "type": "@custom-js/n8n-nodes-pdf-toolkit.html2Pdf", "position": [ 460, -20 ], "parameters": { "htmlInput": "=\n\n\n \n \n Invoice\n \n\n\n\n
\n
\n

Invoice

\n

Invoice #{{ $('Set data').item.json['Invoice No'] }}

\n
\n\n
\n
\n

Billed To:

\n {{ $json.bill_to }}\n
\n
\n

From:

\n {{ $json.from }}\n

Email: {{ $('Set data').item.json.Email }}

\n
\n
\n\n \n \n \n \n \n \n \n \n \n \n {{ $json.details }}\n \n \n \n \n \n
DescriptionUnit PriceQuantityTotal
Total Amount${{ $json.total }}
\n\n
\n

Thank you for doing business with us!

\n

If you have any questions regarding this invoice, please contact us at {{ $('Set data').item.json.Email }}.

\n Contact Us\n
\n
\n\n\n" }, "credentials": { "customJsApi": { "id": "SZkqeEHVYyWhaGem", "name": "CustomJS account" } }, "typeVersion": 1 }, { "id": "5a8efc8a-c60b-4616-a17a-6275cc326978", "name": "Preprocess", "type": "n8n-nodes-base.code", "position": [ 240, -20 ], "parameters": { "mode": "runOnceForEachItem", "jsCode": "const input = $input.item.json\nconst bill_to = input['Bill To'].split('\\n').map(item => '

' + item + '

')\nconst from = input['From'].split('\\n').map(item => '

' + item + '

')\nconst details = input['Details'].map(item => {\n const price = item.price*item.qty\n return `\n \n ${item.description}\n $${item.price}\n ${item.qty}\n $${price}\n \n `\n})\nconst total = input['Details'].reduce((val, next) => {\n\treturn val+next.price*next.qty\n}, 0)\nreturn {\n bill_to: bill_to.join('\\n'),\n from: from.join('\\n'),\n details: details.join('\\n'),\n total\n}" }, "typeVersion": 2 }, { "id": "7da4fb46-1f74-44d8-8392-16fc90f23928", "name": "Set data", "type": "n8n-nodes-base.set", "position": [ 20, -20 ], "parameters": { "options": {}, "assignments": { "assignments": [ { "id": "5342001f-a513-46c3-b31f-4590e8514411", "name": "Invoice No", "type": "string", "value": "1" }, { "id": "ec357d39-c697-4bb8-8d9d-1bc303352dd0", "name": "Bill To", "type": "string", "value": "John Doe\n1234 Elm St, Apt 567\nCity, Country, 12345" }, { "id": "88d6b470-4075-43ec-a684-a4adfd889278", "name": "From", "type": "string", "value": "ABC Corporation\n789 Business Ave\nCity, Country, 67890" }, { "id": "061a8020-644a-4cec-bade-3bcd7e15adee", "name": "Details", "type": "array", "value": "[ { \"description\": \"Web Hosting\", \"price\": 150, \"qty\": 2 }, { \"description\": \"Domain\", \"price\": 15, \"qty\": 5 } ]" }, { "id": "1c2c6c4b-6aa5-4656-8cae-43ffac71d478", "name": "Email", "type": "string", "value": "support@mycompany.com" } ] } }, "typeVersion": 3.4 }, { "id": "a6d39cc4-b9c2-4eed-b4a6-46d622a87c14", "name": "Webhook", "type": "n8n-nodes-base.webhook", "position": [ -200, -20 ], "webhookId": "526fd864-6f85-4cde-97aa-39b61a3e5b83", "parameters": { "path": "526fd864-6f85-4cde-97aa-39b61a3e5b83", "options": {}, "responseMode": "responseNode" }, "typeVersion": 2 }, { "id": "c7d1cc1d-88e3-463a-886f-182a2ba72b11", "name": "Respond to Webhook", "type": "n8n-nodes-base.respondToWebhook", "position": [ 660, -20 ], "parameters": { "options": {}, "respondWith": "binary" }, "typeVersion": 1.1 } ], "pinData": {}, "connections": { "Webhook": { "main": [ [ { "node": "Set data", "type": "main", "index": 0 } ] ] }, "Set data": { "main": [ [ { "node": "Preprocess", "type": "main", "index": 0 } ] ] }, "Preprocess": { "main": [ [ { "node": "HTML to PDF", "type": "main", "index": 0 } ] ] }, "HTML to PDF": { "main": [ [ { "node": "Respond to Webhook", "type": "main", "index": 0 } ] ] } } }