{
  "name": "Extract Invoice Data (PDF/Image) to Google Sheets with LDX hub AnalyzeDoc",
  "tags": [],
  "nodes": [
    {
      "id": "13cf1006-5b97-48fd-a68c-6f0ae1842588",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "options": {
          "buttonLabel": "Extract"
        },
        "formTitle": "Invoice \u2192 Google Sheets",
        "formFields": {
          "values": [
            {
              "fieldName": "invoice_file",
              "fieldType": "file",
              "fieldLabel": "Invoice File",
              "multipleFiles": false,
              "requiredField": true,
              "acceptFileTypes": ".pdf,.jpg,.jpeg,.png"
            }
          ]
        },
        "formDescription": "Upload an invoice (PDF, JPEG, or PNG). LDX hub AnalyzeDoc extracts the key fields and appends them as one row to a Google Sheet."
      },
      "typeVersion": 2.5
    },
    {
      "id": "33450d01-50f0-4dd9-8cd9-5252b23653f9",
      "name": "AnalyzeDoc: Extract Invoice Fields",
      "type": "n8n-nodes-ldxhub.ldxHub",
      "position": [
        224,
        0
      ],
      "parameters": {
        "model": "google/gemini-3.5-flash@high",
        "resource": "analyzeDoc",
        "output_format": "json",
        "system_prompt": "Extract the following fields from the provided invoice document.\n\nRules:\n- Dates: ISO 8601 format (YYYY-MM-DD).\n- Monetary amounts (subtotal, tax, total): plain numbers without currency symbols or thousands separators.\n- currency: ISO 4217 code (e.g. \"USD\", \"EUR\", \"JPY\").\n- Phone or fax numbers, if any: do not start the value with a \"+\" (use \"81-3-1234-5678\" or \"(+1234567890\") so they stay readable as text in spreadsheets.\n- vendor_tax_id: the vendor's tax registration number (VAT ID, EIN, or a local equivalent such as a Japanese qualified invoice issuer number).\n- If a field is not present in the document, use an empty string \"\" for text fields and 0 for amounts.\n\nFields:\n- invoice_number: the invoice identifier\n- issue_date: date the invoice was issued\n- due_date: payment due date\n- vendor_name: name of the issuing company\n- vendor_address: full address of the issuing company\n- vendor_tax_id: vendor's tax registration number\n- bill_to: name of the billed customer or company\n- subtotal: amount before tax\n- tax: tax amount\n- total: total amount due\n- currency: currency of the amounts\n- payment_terms: payment terms as written (e.g. \"Net 30\")",
        "example_output": "{\"invoice_number\":\"\",\"issue_date\":\"\",\"due_date\":\"\",\"vendor_name\":\"\",\"vendor_address\":\"\",\"vendor_tax_id\":\"\",\"bill_to\":\"\",\"subtotal\":1234.56,\"tax\":123.45,\"total\":1358.01,\"currency\":\"\",\"payment_terms\":\"\"}",
        "pollingSettings": {
          "serverWaitSeconds": 10,
          "pollingMaxAttempts": 180
        },
        "binaryPropertyName": "invoice_file"
      },
      "credentials": {
        "ldxHubApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1425676c-e888-4731-a7d6-d88b7d8f6f68",
      "name": "Parse Extracted JSON",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        448,
        0
      ],
      "parameters": {
        "options": {},
        "operation": "fromJson",
        "binaryPropertyName": "invoice_file"
      },
      "typeVersion": 1
    },
    {
      "id": "820bfc3e-6ec5-4186-b1b4-90c5517cb1b5",
      "name": "Append Row to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        672,
        0
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [],
          "mappingMode": "autoMapInputData",
          "matchingColumns": []
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "84bcb0b4-004f-4880-9d96-170f1cb008a1",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        -160
      ],
      "parameters": {
        "color": 7,
        "width": 500,
        "height": 760,
        "content": "## Invoice \u2192 Google Sheets\nUpload an invoice via the built-in form \u2014 **LDX hub AnalyzeDoc** (vision AI) reads the PDF/image and appends the extracted fields as one row to your Google Sheet.\n\n**Setup**\n1. Install the verified community node `n8n-nodes-ldxhub` (v0.10.0 or later) and create an **LDXhub API** credential \u2014 get a free API key at https://gw.portal.ldxhub.io (25,000 credits/month, no credit card).\n2. Create a Google Sheet with this header row:\n`invoice_number, issue_date, due_date, vendor_name, vendor_address, vendor_tax_id, bill_to, subtotal, tax, total, currency, payment_terms`\n3. In **Append Row to Google Sheets**, select your Google credential, spreadsheet, and sheet.\n4. Activate the workflow and open the form URL \u2014 that's it."
      },
      "typeVersion": 1
    },
    {
      "id": "08cd39b0-a2ae-4110-ad6d-9cfdd9d2ff62",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        -360
      ],
      "parameters": {
        "color": 7,
        "width": 360,
        "height": 320,
        "content": "## Customize the extraction\nEdit **System Prompt** and **Example Output** in the AnalyzeDoc node to change the fields \u2014 the Example Output defines the output schema.\nTip: write amounts with decimals (e.g. 1234.56) so they stay numeric. Works with invoices in any language."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "connections": {
    "On form submission": {
      "main": [
        [
          {
            "node": "AnalyzeDoc: Extract Invoice Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Extracted JSON": {
      "main": [
        [
          {
            "node": "Append Row to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AnalyzeDoc: Extract Invoice Fields": {
      "main": [
        [
          {
            "node": "Parse Extracted JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}