{
  "name": "Classify Gmail invoice attachments with Google Gemini and forward to freee",
  "nodes": [
    {
      "id": "13c00125-be4d-46ed-9efe-72875929e7db",
      "name": "Workflow Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3152,
        1872
      ],
      "parameters": {
        "width": 400,
        "height": 724,
        "content": "## Classify and forward Gmail invoice attachments to freee with Google Gemini\n\nAutomatically analyze email attachments with AI and forward invoices/receipts to freee's File Box.\n\n## How it works\n\n1. P"
      }
    },
    {
      "id": "10ea6b19-c70d-4d34-bc45-d04c7fb92faf",
      "name": "Filter Section",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2608,
        2032
      ],
      "parameters": {
        "width": 480,
        "height": 292,
        "content": "### Receive & Filter\nPolls Gmail every minute and filters out emails without attachments using the Content-Type header."
      }
    },
    {
      "id": "7b93689a-ee1f-484e-ac10-bc23da8eb465",
      "name": "AI Section",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2064,
        1920
      ],
      "parameters": {
        "width": 600,
        "height": 328,
        "content": "### AI Classification\nExtracts text from the PDF attachment, then sends it along with the email body to Google Gemini to classify the document as invoice, receipt, or other."
      }
    },
    {
      "id": "c920d6b4-f715-4137-b83c-0a2720a614d6",
      "name": "Forward Section",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1264,
        1824
      ],
      "parameters": {
        "width": 480,
        "height": 300,
        "content": "### Forward to freee\nRe-fetches the original attachment and forwards the email to freee's File Box receiving address."
      }
    },
    {
      "id": "4f994f2b-b6d3-4b35-b25e-2b473f9fb52d",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -2560,
        2160
      ]
    },
    {
      "id": "87c2e3a2-51e5-4858-a5c2-34990b652b81",
      "name": "Has Attachment",
      "type": "n8n-nodes-base.if",
      "position": [
        -2336,
        2160
      ]
    },
    {
      "id": "2fa81cca-5513-4d6a-a2e0-ce8e8b2dbcf9",
      "name": "No Attachment - End",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -2016,
        2256
      ]
    },
    {
      "id": "090ec41a-d07b-4cad-9a3e-4ef779c4a16a",
      "name": "Is Invoice or Receipt",
      "type": "n8n-nodes-base.if",
      "position": [
        -1440,
        2064
      ]
    },
    {
      "id": "85086fde-9fe0-4c63-a49c-9d5e4c627036",
      "name": "Not Target - End",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -1216,
        2160
      ]
    },
    {
      "id": "9b09d5db-1d7b-4b5a-bde8-38c55eb90004",
      "name": "Forward to freee",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -992,
        1968
      ]
    },
    {
      "id": "3fb2f04b-59dc-4dd6-8a03-296d955dc741",
      "name": "Classify Invoice/Receipt (AI)",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        -1792,
        2064
      ]
    },
    {
      "id": "7c571379-c41f-47c8-ab12-c89e5035cbbf",
      "name": "Extract Text from PDF",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -2016,
        2064
      ]
    },
    {
      "id": "922d2b80-2e98-4ace-991f-a191a4ee71a8",
      "name": "Get Attachment",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -1216,
        1968
      ]
    }
  ],
  "connections": {
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Has Attachment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Attachment": {
      "main": [
        [
          {
            "node": "Forward to freee",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Attachment": {
      "main": [
        [
          {
            "node": "Extract Text from PDF",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Attachment - End",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text from PDF": {
      "main": [
        [
          {
            "node": "Classify Invoice/Receipt (AI)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Invoice or Receipt": {
      "main": [
        [
          {
            "node": "Get Attachment",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Not Target - End",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Classify Invoice/Receipt (AI)": {
      "main": [
        [
          {
            "node": "Is Invoice or Receipt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}