{
  "name": "Auto-File Gmail Invoice Attachments Into Google Sheets",
  "nodes": [
    {
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1,
      "parameters": {
        "simple": false,
        "filters": {
          "q": "has:attachment invoice OR receipt"
        }
      },
      "notes": "Only messages with attachments.",
      "position": [
        260,
        300
      ]
    },
    {
      "name": "Extract Fields",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1,
      "parameters": {
        "resource": "text",
        "operation": "message",
        "modelId": "gpt-4o-mini",
        "messages": {
          "values": [
            {
              "role": "user",
              "content": "Extract vendor, amount and invoice date as JSON from this email: {{ $json.text }}"
            }
          ]
        }
      },
      "notes": "Swap in Anthropic or any LLM node if you prefer.",
      "position": [
        500,
        300
      ]
    },
    {
      "name": "Google Sheets — Store File",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "parameters": {
        "operation": "upload"
      },
      "notes": "File the attachment or log the row.",
      "position": [
        740,
        300
      ]
    },
    {
      "name": "Respond / Finish",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "parameters": {},
      "notes": "End of flow — extend with extra steps as needed.",
      "position": [
        980,
        300
      ]
    }
  ],
  "connections": {
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Extract Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Fields": {
      "main": [
        [
          {
            "node": "Google Sheets — Store File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets — Store File": {
      "main": [
        [
          {
            "node": "Respond / Finish",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
