{
  "name": "Process invoices and send weekly AI reports with OpenAI and Gmail",
  "nodes": [
    {
      "id": "2befd473-43b7-42bb-9fcd-925e35c58044",
      "name": "Invoice Upload Form",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -1824,
        96
      ]
    },
    {
      "id": "82dca76f-328a-40c2-8139-ec6affe6e513",
      "name": "Workflow Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        -1552,
        96
      ]
    },
    {
      "id": "8c6c66cc-ffa8-4184-bfad-ec96682e18e7",
      "name": "Store Raw Form Submission",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        -1328,
        96
      ]
    },
    {
      "id": "4dec86d9-c3bd-4384-b8a2-0785d7bb8f91",
      "name": "Extract Invoice Content",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -1024,
        96
      ]
    },
    {
      "id": "3fc45009-48db-4fce-9de3-c125f3222621",
      "name": "Extract Invoice Data with AI",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -800,
        96
      ]
    },
    {
      "id": "03f1a3b9-fedc-4c5f-9812-97129e98269f",
      "name": "Invoice Data Schema Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -592,
        320
      ]
    },
    {
      "id": "1c5937a1-63a7-4d9f-8dd0-8b1796d9cf4e",
      "name": "Validate Invoice Data",
      "type": "n8n-nodes-base.code",
      "position": [
        -416,
        96
      ]
    },
    {
      "id": "d4ace010-b345-493d-b3db-ecfbb3a115a4",
      "name": "Check Validation Result",
      "type": "n8n-nodes-base.if",
      "position": [
        -240,
        96
      ]
    },
    {
      "id": "ae5a40be-3e93-4dc8-b969-965d134278c8",
      "name": "Prepare Success Email Data",
      "type": "n8n-nodes-base.set",
      "position": [
        16,
        -48
      ]
    },
    {
      "id": "f5cd3484-3d2a-4034-aef6-085ab713559f",
      "name": "Store Validated Invoice",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        224,
        -48
      ]
    },
    {
      "id": "f67acac8-a840-4148-8b5b-6bd9c8e36e0d",
      "name": "Send Success Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        400,
        -48
      ]
    },
    {
      "id": "21d45666-aa82-4d19-9833-2c1751b8d6ec",
      "name": "Prepare Error Email Data",
      "type": "n8n-nodes-base.set",
      "position": [
        32,
        448
      ]
    },
    {
      "id": "825ad618-79fe-4941-8666-b266935c0f18",
      "name": "Send Error Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        304,
        448
      ]
    },
    {
      "id": "062eb808-d9ff-4e9f-b507-aa58246c8ce7",
      "name": "Weekly Report Schedule",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1856,
        848
      ]
    },
    {
      "id": "d2197dc0-6ffd-45f7-83b5-1a15c68f80fe",
      "name": "Fetch Weekly Invoices",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        -1648,
        848
      ]
    },
    {
      "id": "d3cc2957-8e93-459e-ae15-a537a72fcb65",
      "name": "Generate Weekly Report",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1312,
        848
      ]
    },
    {
      "id": "5a124c06-ecb7-44b1-ad1b-47b65913fb52",
      "name": "Send Weekly Report Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -880,
        848
      ]
    },
    {
      "id": "84897497-8775-4bbd-9472-ab7803562fb2",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2736,
        64
      ],
      "parameters": {
        "width": 544,
        "height": 560,
        "content": "## How it works\nThis workflow helps you automatically process invoices using AI.\n\nA user uploads an invoice file (PDF or image) through a form. The file is read and the text is extracted. Then AI pull"
      }
    },
    {
      "id": "ceda8874-d6f4-43c6-9a38-e502b493ff86",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1920,
        0
      ],
      "parameters": {
        "width": 272,
        "height": 304,
        "content": "## Form Input\nCollects user email and invoice file via form trigger."
      }
    },
    {
      "id": "9c41db39-f23f-464e-a515-bbeb1165b2ca",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1616,
        -64
      ],
      "parameters": {
        "width": 448,
        "height": 352,
        "content": "## Configuration and Submission Storage\nDefines report email and valid currencies used in validation. and \nStores raw form data for tracking and auditing purposes."
      }
    },
    {
      "id": "30b7e206-f747-46a4-a457-e1caa6d45d09",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1120,
        -64
      ],
      "parameters": {
        "width": 256,
        "height": 352,
        "content": "## File Extraction\nExtracts text content from uploaded invoice files."
      }
    },
    {
      "id": "6ec8389d-16e9-47e2-a970-b0d31b1649c4",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -816,
        -64
      ],
      "parameters": {
        "width": 352,
        "height": 352,
        "content": "## AI Processing\nAI converts extracted text into structured invoice data."
      }
    },
    {
      "id": "92d876b3-73b7-4444-a5e6-ccb6f66a76cf",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -448,
        -48
      ],
      "parameters": {
        "width": 336,
        "height": 320,
        "content": "## Validation\nChecks date format, currency, and total amount accuracy."
      }
    },
    {
      "id": "f0fd8081-f55c-499e-b20e-d425cf108499",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -48,
        -144
      ],
      "parameters": {
        "width": 592,
        "height": 288,
        "content": "## Success Path\nStores valid invoices and sends confirmation email."
      }
    },
    {
      "id": "ee0715f0-74ee-4d2d-87ec-53f5c1650662",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        336
      ],
      "parameters": {
        "width": 544,
        "height": 320,
        "content": "## Error Path\nSends email with validation errors for correction."
      }
    },
    {
      "id": "a7d71fc5-cb30-4a94-b8c4-d658b006f750",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1952,
        704
      ],
      "parameters": {
        "width": 480,
        "height": 320,
        "content": "## Weekly Trigger\nRuns weekly to process stored invoices for reporting."
      }
    },
    {
      "id": "9c113796-c4a5-4844-85a2-1bc58c6cb015",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1344,
        704
      ],
      "parameters": {
        "width": 320,
        "height": 320,
        "content": "## Report Generation\nAI generates a formatted weekly invoice summary report."
      }
    },
    {
      "id": "5395f5e9-3ad2-4fff-a989-93e6593dea29",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -992,
        704
      ],
      "parameters": {
        "width": 320,
        "height": 320,
        "content": "## Report Email\nSends weekly report to configured recipient."
      }
    },
    {
      "id": "e9f97f4b-4f7d-4e0c-9f84-b2c091f5705b",
      "name": "OpenAI GPT-5-mini Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -784,
        320
      ]
    },
    {
      "id": "88e5d798-a530-46ae-ac1c-2bbc331421f1",
      "name": "OpenAI GPT-5-mini Model for Reports",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1232,
        1072
      ]
    }
  ],
  "connections": {
    "Invoice Upload Form": {
      "main": [
        [
          {
            "node": "Workflow Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Weekly Invoices": {
      "main": [
        [
          {
            "node": "Generate Weekly Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Invoice Data": {
      "main": [
        [
          {
            "node": "Check Validation Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Weekly Report": {
      "main": [
        [
          {
            "node": "Send Weekly Report Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Weekly Report Schedule": {
      "main": [
        [
          {
            "node": "Fetch Weekly Invoices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Configuration": {
      "main": [
        [
          {
            "node": "Store Raw Form Submission",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Validation Result": {
      "main": [
        [
          {
            "node": "Prepare Success Email Data",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare Error Email Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Invoice Content": {
      "main": [
        [
          {
            "node": "Extract Invoice Data with AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI GPT-5-mini Model": {
      "ai_languageModel": [
        [
          {
            "node": "Extract Invoice Data with AI",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Store Validated Invoice": {
      "main": [
        [
          {
            "node": "Send Success Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Error Email Data": {
      "main": [
        [
          {
            "node": "Send Error Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store Raw Form Submission": {
      "main": [
        [
          {
            "node": "Extract Invoice Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Invoice Data Schema Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Extract Invoice Data with AI",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Success Email Data": {
      "main": [
        [
          {
            "node": "Store Validated Invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Invoice Data with AI": {
      "main": [
        [
          {
            "node": "Validate Invoice Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI GPT-5-mini Model for Reports": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Weekly Report",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}