Rechnung erstellen

Fortgeschritten

Dies ist ein Finance, AI, IT Ops-Bereich Automatisierungsworkflow mit 12 Nodes. Hauptsächlich werden If, Set, Code, Webhook, EmailSend und andere Nodes verwendet, kombiniert mit KI-Technologie für intelligente Automatisierung. Rechnungen generieren, in Google Drive speichern und per E-Mail mit JS+Google Sheets an Kunden senden

Voraussetzungen
  • HTTP Webhook-Endpunkt (wird von n8n automatisch generiert)
  • Google Drive API-Anmeldedaten
  • Möglicherweise sind Ziel-API-Anmeldedaten erforderlich
  • Google Sheets API-Anmeldedaten
Workflow-Vorschau
Visualisierung der Node-Verbindungen, mit Zoom und Pan
Workflow exportieren
Kopieren Sie die folgende JSON-Konfiguration und importieren Sie sie in n8n
{
  "id": "K4XpJbwBJYnDiYkF",
  "meta": {
    "instanceId": "b3c467df4053d13fe31cc98f3c66fa1d16300ba750506bfd019a0913cec71ea3",
    "templateCredsSetupCompleted": true
  },
  "name": "Generate Invoices",
  "tags": [],
  "nodes": [
    {
      "id": "e56cbf88-1e0d-4dd7-a269-091ad2ce8420",
      "name": "Webhook Simulator",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -240,
        20
      ],
      "webhookId": "7f884a07-861e-49da-bb0e-1ac6ca40ea00",
      "parameters": {
        "path": "7f884a07-861e-49da-bb0e-1ac6ca40ea00",
        "options": {}
      },
      "typeVersion": 2
    },
    {
      "id": "b01307f7-b5cb-421e-833a-0889925bb09c",
      "name": "Rechnungs-ID generieren",
      "type": "n8n-nodes-base.code",
      "position": [
        -20,
        20
      ],
      "parameters": {
        "jsCode": "function generateOrderID(length = 6) {\n  const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';\n  let result = 'INV-';\n  for (let i = 0; i < length; i++) {\n    result += chars.charAt(Math.floor(Math.random() * chars.length));\n  }\n  return result;\n}\n\nreturn [\n  {\n    json: {\n      order_id: generateOrderID()\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "bf50ca10-4021-4e6f-9c08-56fd84ce13ed",
      "name": "Prüfen ob ID bereits existiert",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        200,
        20
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json.order_id }}",
              "lookupColumn": "Invoice ID"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1QW_Lg1aoEBku8GaxwPbZfBY5ITAuSdvoAXRyNdCEujM/edit#gid=0",
          "cachedResultName": "Invoices"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1QW_Lg1aoEBku8GaxwPbZfBY5ITAuSdvoAXRyNdCEujM",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1QW_Lg1aoEBku8GaxwPbZfBY5ITAuSdvoAXRyNdCEujM/edit?usp=drivesdk",
          "cachedResultName": "Uppfy Shop Invoices"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "d0qeLhShx9sGXalR",
          "name": "Google Sheets"
        }
      },
      "typeVersion": 4.5,
      "alwaysOutputData": true
    },
    {
      "id": "c63871fa-ca0f-4069-ac0d-422d39018a9e",
      "name": "Falls nicht vorhanden",
      "type": "n8n-nodes-base.if",
      "position": [
        420,
        20
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "cee7659a-cea3-494a-b4f3-c76d035a3a32",
              "operator": {
                "type": "string",
                "operation": "empty",
                "singleValue": true
              },
              "leftValue": "={{ $json.row_number }}",
              "rightValue": ""
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "feb9ed84-a62c-4cec-bf36-b53a76711bcd",
      "name": "Felder setzen",
      "type": "n8n-nodes-base.set",
      "position": [
        740,
        -140
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "1bd457b4-2c15-433a-96b3-5fabb8566866",
              "name": "order_id",
              "type": "string",
              "value": "={{ $('Generate Invoice ID').item.json.order_id }}"
            },
            {
              "id": "15c51334-b127-485e-9be4-051b086d74b2",
              "name": "customer_name",
              "type": "string",
              "value": "={{ $('Webhook Simulator').item.json.customer_name }}"
            },
            {
              "id": "8c4f2d5c-09c8-4b8c-a77f-ab3c1d752c13",
              "name": "customer_email",
              "type": "string",
              "value": "={{ $('Webhook Simulator').item.json.customer_email }}"
            },
            {
              "id": "ea1bbfe4-c12d-450f-9bee-fff8710eed42",
              "name": "products",
              "type": "array",
              "value": "={{ $('Webhook Simulator').item.json.products }}"
            },
            {
              "id": "025d0783-7eb0-4ac4-b373-39f744692cfd",
              "name": "total",
              "type": "number",
              "value": "={{ $('Webhook Simulator').item.json.total }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0532fa4b-cdd9-4857-8701-6a5baf48fd7c",
      "name": "Rechnungs-HTML erstellen",
      "type": "n8n-nodes-base.code",
      "position": [
        740,
        100
      ],
      "parameters": {
        "jsCode": "const { order_id, customer_name, customer_email, products, total } = $json;\n\n// Format products table rows\nconst productRows = products.map((item, index) => {\n  const subtotal = item.quantity * item.price;\n  return `\n    <tr>\n      <td style=\"padding: 8px; border: 1px solid #ccc;\">${index + 1}</td>\n      <td style=\"padding: 8px; border: 1px solid #ccc;\">${item.name}</td>\n      <td style=\"padding: 8px; border: 1px solid #ccc;\">${item.quantity}</td>\n      <td style=\"padding: 8px; border: 1px solid #ccc;\">$${item.price.toFixed(2)}</td>\n      <td style=\"padding: 8px; border: 1px solid #ccc;\">$${subtotal.toFixed(2)}</td>\n    </tr>\n  `;\n}).join('');\n\nconst html = `\n<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\">\n  <title>Invoice ${order_id}</title>\n</head>\n<body style=\"font-family: Arial, sans-serif; color: #333; max-width: 700px; margin: auto; padding: 20px; border: 1px solid #ddd;\">\n  <h2 style=\"text-align: center;\">Invoice</h2>\n  <p><strong>Order ID:</strong> ${order_id}</p>\n  <p><strong>Customer Name:</strong> ${customer_name}</p>\n  <p><strong>Email:</strong> ${customer_email}</p>\n\n  <table style=\"width: 100%; border-collapse: collapse; margin-top: 20px;\">\n    <thead>\n      <tr>\n        <th style=\"padding: 8px; border: 1px solid #ccc;\">#</th>\n        <th style=\"padding: 8px; border: 1px solid #ccc;\">Product</th>\n        <th style=\"padding: 8px; border: 1px solid #ccc;\">Qty</th>\n        <th style=\"padding: 8px; border: 1px solid #ccc;\">Unit Price</th>\n        <th style=\"padding: 8px; border: 1px solid #ccc;\">Subtotal</th>\n      </tr>\n    </thead>\n    <tbody>\n      ${productRows}\n    </tbody>\n    <tfoot>\n      <tr>\n        <td colspan=\"4\" style=\"text-align: right; padding: 8px; border: 1px solid #ccc;\"><strong>Total:</strong></td>\n        <td style=\"padding: 8px; border: 1px solid #ccc;\"><strong>$${total.toFixed(2)}</strong></td>\n      </tr>\n    </tfoot>\n  </table>\n\n  <p style=\"margin-top: 40px; text-align: center;\">Thank you for your order!</p>\n</body>\n</html>\n`;\n\nreturn [\n  {\n    json: {\n      html\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "5a3adb6a-9f64-477e-9622-3d2b9ef2e6de",
      "name": "HTML zu PDF",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -20,
        320
      ],
      "parameters": {
        "url": "https://html2pdf2.p.rapidapi.com/html2pdf",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "html",
              "value": "={{ $json.html }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "x-rapidapi-host",
              "value": "html2pdf2.p.rapidapi.com"
            },
            {
              "name": "x-rapidapi-key",
              "value": "\"your_rapid_api_key\""
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "cebf6d0d-d43f-4e50-abc0-79ff8da1817a",
      "name": "PDF zu GDrive hochladen",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        420,
        320
      ],
      "parameters": {
        "name": "={{ $('Set Fields').item.json.order_id }} - {{ $('Set Fields').item.json.customer_name }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "root",
          "cachedResultName": "/ (Root folder)"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "l8Cc2MEVE7foBfbK",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "b181eddc-e786-4d44-a334-e1b581b3981f",
      "name": "Rechnung per E-Mail an Kunden",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        640,
        320
      ],
      "webhookId": "cdc852fc-03b9-4a89-ba56-879064da5cbb",
      "parameters": {
        "html": "=Hello  {{ $('Set Fields').item.json.customer_name }},\n\nPlease pay this invoice\n\n\n{{ $('Create Invoice HTML').item.json.html }}\n\n\n<!DOCTYPE html>\n<html>\n<head>\n    <style>\n        .button {\n            display: inline-block;\n            background-color: #4CAF50;\n            border: none;\n            border-radius: 4px;\n            color: white;\n            padding: 15px 32px;\n            text-align: center;\n            text-decoration: none;\n            font-size: 16px;\n            font-weight: bold;\n            margin: 4px 2px;\n            cursor: pointer;\n            font-family: Arial, sans-serif;\n        }\n    </style>\n</head>\n<body>\n    <div style=\"text-align: center;\">\n        <a href=\"YOUR_PAYMENT_LINK_HERE\" class=\"button\">Pay Now</a>\n    </div>\n</body>\n</html>\n\n",
        "options": {
          "appendAttribution": false
        },
        "subject": "={{ $('Set Fields').item.json.order_id }} - New Invoice from Uppfy Shop ",
        "toEmail": "={{ $('Set Fields').item.json.customer_email }}",
        "fromEmail": "Uppfy Shop <your_from_email>"
      },
      "credentials": {
        "smtp": {
          "id": "xcnAVXwtuOa1IOqE",
          "name": "SMTP account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "883e32b6-a812-44c8-b525-97e819af90bd",
      "name": "Details zu Rechnungsblatt hinzufügen",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        860,
        320
      ],
      "parameters": {
        "columns": {
          "value": {
            "Status": "Unpaid",
            "Invoice ID": "={{ $('Set Fields').item.json.order_id }}",
            "Invoice URL": "={{ $('Upload PDF to GDrive').item.json.webViewLink }}",
            "Invoice Amt.": "=${{ $('Set Fields').item.json.total }}",
            "Customer Name": "={{ $('Set Fields').item.json.customer_name }}",
            "Customer Email": "={{ $('Set Fields').item.json.customer_email }}"
          },
          "schema": [
            {
              "id": "Invoice ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Invoice ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Customer Name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Customer Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Customer Email",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Customer Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Invoice Amt.",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Invoice Amt.",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Invoice URL",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Invoice URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Invoice ID"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1QW_Lg1aoEBku8GaxwPbZfBY5ITAuSdvoAXRyNdCEujM/edit#gid=0",
          "cachedResultName": "Invoices"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1QW_Lg1aoEBku8GaxwPbZfBY5ITAuSdvoAXRyNdCEujM",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1QW_Lg1aoEBku8GaxwPbZfBY5ITAuSdvoAXRyNdCEujM/edit?usp=drivesdk",
          "cachedResultName": "Uppfy Shop Invoices"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "d0qeLhShx9sGXalR",
          "name": "Google Sheets"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "cd06d6c9-903d-4af8-8327-eb36ba3bc73a",
      "name": "PDF von API herunterladen",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        200,
        320
      ],
      "parameters": {
        "url": " https://rhodium-tecnologia-html2pdf.s3.amazonaws.com/public/pdfs/1747392997249.pdf",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "7d308e22-9b2d-4993-8aad-cc701303d38d",
      "name": "Haftnotiz",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -280,
        -160
      ],
      "parameters": {
        "width": 180,
        "height": 320,
        "content": "## Pinned Data to Simulate Webhook Query"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {
    "Webhook Simulator": [
      {
        "json": {
          "total": 65,
          "products": [
            {
              "name": "T-shirt",
              "price": 25,
              "quantity": 2
            },
            {
              "name": "Hat",
              "price": 15,
              "quantity": 1
            }
          ],
          "customer_name": "Jane Doe",
          "customer_email": "jane@example.com"
        }
      }
    ]
  },
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "dec45f2b-cb36-4f86-a8cc-d3c498ae7aa2",
  "connections": {
    "feb9ed84-a62c-4cec-bf36-b53a76711bcd": {
      "main": [
        [
          {
            "node": "0532fa4b-cdd9-4857-8701-6a5baf48fd7c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5a3adb6a-9f64-477e-9622-3d2b9ef2e6de": {
      "main": [
        [
          {
            "node": "cd06d6c9-903d-4af8-8327-eb36ba3bc73a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "c63871fa-ca0f-4069-ac0d-422d39018a9e": {
      "main": [
        [
          {
            "node": "feb9ed84-a62c-4cec-bf36-b53a76711bcd",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "b01307f7-b5cb-421e-833a-0889925bb09c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "e56cbf88-1e0d-4dd7-a269-091ad2ce8420": {
      "main": [
        [
          {
            "node": "b01307f7-b5cb-421e-833a-0889925bb09c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0532fa4b-cdd9-4857-8701-6a5baf48fd7c": {
      "main": [
        [
          {
            "node": "5a3adb6a-9f64-477e-9622-3d2b9ef2e6de",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "b01307f7-b5cb-421e-833a-0889925bb09c": {
      "main": [
        [
          {
            "node": "bf50ca10-4021-4e6f-9c08-56fd84ce13ed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "cebf6d0d-d43f-4e50-abc0-79ff8da1817a": {
      "main": [
        [
          {
            "node": "b181eddc-e786-4d44-a334-e1b581b3981f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "cd06d6c9-903d-4af8-8327-eb36ba3bc73a": {
      "main": [
        [
          {
            "node": "cebf6d0d-d43f-4e50-abc0-79ff8da1817a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "b181eddc-e786-4d44-a334-e1b581b3981f": {
      "main": [
        [
          {
            "node": "883e32b6-a812-44c8-b525-97e819af90bd",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "bf50ca10-4021-4e6f-9c08-56fd84ce13ed": {
      "main": [
        [
          {
            "node": "c63871fa-ca0f-4069-ac0d-422d39018a9e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Häufig gestellte Fragen

Wie verwende ich diesen Workflow?

Kopieren Sie den obigen JSON-Code, erstellen Sie einen neuen Workflow in Ihrer n8n-Instanz und wählen Sie "Aus JSON importieren". Fügen Sie die Konfiguration ein und passen Sie die Anmeldedaten nach Bedarf an.

Für welche Szenarien ist dieser Workflow geeignet?

Fortgeschritten - Finanzen, Künstliche Intelligenz, IT-Betrieb

Ist es kostenpflichtig?

Dieser Workflow ist völlig kostenlos. Beachten Sie jedoch, dass Drittanbieterdienste (wie OpenAI API), die im Workflow verwendet werden, möglicherweise kostenpflichtig sind.

Workflow-Informationen
Schwierigkeitsgrad
Fortgeschritten
Anzahl der Nodes12
Kategorie3
Node-Typen9
Schwierigkeitsbeschreibung

Für erfahrene Benutzer, mittelkomplexe Workflows mit 6-15 Nodes

Autor
Joseph

Joseph

@mjomba

Automation expert specializing in building smart, scalable workflows using tools like n8n, Make, and Airtable. I help businesses save time, reduce manual work, and grow faster with tailored automation solutions. Feel free to reach out at joseph@uppfy.com to discuss your project. I am also on x.com/juppfy

Externe Links
Auf n8n.io ansehen

Diesen Workflow teilen

Kategorien

Kategorien: 34