{
  "name": "Generate invoices, save to Drive and send email to customer with JS + G Sheets",
  "nodes": [
    {
      "id": "e56cbf88-1e0d-4dd7-a269-091ad2ce8420",
      "name": "Webhook Simulator",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -240,
        20
      ]
    },
    {
      "id": "b01307f7-b5cb-421e-833a-0889925bb09c",
      "name": "Generate Invoice ID",
      "type": "n8n-nodes-base.code",
      "position": [
        -20,
        20
      ]
    },
    {
      "id": "bf50ca10-4021-4e6f-9c08-56fd84ce13ed",
      "name": "Check if ID Already Exists",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        200,
        20
      ]
    },
    {
      "id": "c63871fa-ca0f-4069-ac0d-422d39018a9e",
      "name": "If Does not Exist",
      "type": "n8n-nodes-base.if",
      "position": [
        420,
        20
      ]
    },
    {
      "id": "feb9ed84-a62c-4cec-bf36-b53a76711bcd",
      "name": "Set Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        740,
        -140
      ]
    },
    {
      "id": "0532fa4b-cdd9-4857-8701-6a5baf48fd7c",
      "name": "Create Invoice HTML",
      "type": "n8n-nodes-base.code",
      "position": [
        740,
        100
      ]
    },
    {
      "id": "5a3adb6a-9f64-477e-9622-3d2b9ef2e6de",
      "name": "HTML to PDF",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -20,
        320
      ]
    },
    {
      "id": "cebf6d0d-d43f-4e50-abc0-79ff8da1817a",
      "name": "Upload PDF to GDrive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        420,
        320
      ]
    },
    {
      "id": "b181eddc-e786-4d44-a334-e1b581b3981f",
      "name": "Email Invoice to Customer",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        640,
        320
      ]
    },
    {
      "id": "883e32b6-a812-44c8-b525-97e819af90bd",
      "name": "Append Details to Invoices Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        860,
        320
      ]
    },
    {
      "id": "cd06d6c9-903d-4af8-8327-eb36ba3bc73a",
      "name": "Download PDF from API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        200,
        320
      ]
    },
    {
      "id": "7d308e22-9b2d-4993-8aad-cc701303d38d",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -280,
        -160
      ],
      "parameters": {
        "width": 180,
        "height": 320,
        "content": "## Pinned Data to Simulate Webhook Query"
      }
    }
  ],
  "connections": {
    "Set Fields": {
      "main": [
        [
          {
            "node": "Create Invoice HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTML to PDF": {
      "main": [
        [
          {
            "node": "Download PDF from API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Does not Exist": {
      "main": [
        [
          {
            "node": "Set Fields",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Generate Invoice ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook Simulator": {
      "main": [
        [
          {
            "node": "Generate Invoice ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Invoice HTML": {
      "main": [
        [
          {
            "node": "HTML to PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Invoice ID": {
      "main": [
        [
          {
            "node": "Check if ID Already Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload PDF to GDrive": {
      "main": [
        [
          {
            "node": "Email Invoice to Customer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download PDF from API": {
      "main": [
        [
          {
            "node": "Upload PDF to GDrive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Invoice to Customer": {
      "main": [
        [
          {
            "node": "Append Details to Invoices Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if ID Already Exists": {
      "main": [
        [
          {
            "node": "If Does not Exist",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}