{
  "name": "Process email invoices with OCR, GPT-4, Slack, QuickBooks and Google Sheets",
  "nodes": [
    {
      "id": "558bd0c1-8a24-4b46-ab80-93245682fef8",
      "name": "Invoice Email Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -1184,
        96
      ]
    },
    {
      "id": "2f998f59-b9c4-4e7a-a3fd-48a2c3a11011",
      "name": "Workflow Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        -880,
        96
      ]
    },
    {
      "id": "35acbac0-ec82-4a76-b5d9-3b14e0ba068e",
      "name": "Capture Invoice Metadata",
      "type": "n8n-nodes-base.set",
      "position": [
        -720,
        96
      ]
    },
    {
      "id": "43e8d16f-26f2-4d53-b3c7-4d335d423589",
      "name": "Check File Type",
      "type": "n8n-nodes-base.if",
      "position": [
        -432,
        96
      ]
    },
    {
      "id": "8582e588-c4e2-43fb-ad1a-633b4a7fa75c",
      "name": "Extract Text from PDF",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -80,
        -16
      ]
    },
    {
      "id": "a62d04a5-7ea0-46a1-a134-e3db5f99d194",
      "name": "OCR for Images",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -80,
        192
      ]
    },
    {
      "id": "63d81b7b-381a-4175-8d14-293fcc9b74b7",
      "name": "Merge OCR Results",
      "type": "n8n-nodes-base.merge",
      "position": [
        224,
        96
      ]
    },
    {
      "id": "2da77dd8-9952-45fc-97a7-71540ec81281",
      "name": "AI Invoice Extractor",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        480,
        96
      ]
    },
    {
      "id": "243f0c32-34b8-4759-b9e0-f954b6e7a3bb",
      "name": "OpenAI GPT-4",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        448,
        320
      ]
    },
    {
      "id": "330bba5d-8e1a-4995-bcec-7639b57a9f42",
      "name": "Invoice Schema Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        576,
        320
      ]
    },
    {
      "id": "7bc970a4-4ad1-4159-b5a4-4839c9740eaa",
      "name": "Validate and Recalculate Totals",
      "type": "n8n-nodes-base.code",
      "position": [
        880,
        96
      ]
    },
    {
      "id": "0004ac1f-05d3-49de-9ba9-8174f32d4516",
      "name": "Mask PII Data",
      "type": "n8n-nodes-base.code",
      "position": [
        1120,
        96
      ]
    },
    {
      "id": "3392ea76-e057-4a34-8b8b-9e48d64f6e81",
      "name": "Check if Review Needed",
      "type": "n8n-nodes-base.if",
      "position": [
        1392,
        96
      ]
    },
    {
      "id": "ebee130e-ad08-4b50-b4b4-1e2671064759",
      "name": "Wait for Human Review",
      "type": "n8n-nodes-base.wait",
      "position": [
        2016,
        -208
      ]
    },
    {
      "id": "98f2f9df-273a-4ade-bf0b-284354ce2b69",
      "name": "Send Review Request",
      "type": "n8n-nodes-base.slack",
      "position": [
        1824,
        -208
      ]
    },
    {
      "id": "703bbaa6-08bd-4aea-b088-a47621f95b16",
      "name": "Create QuickBooks Bill",
      "type": "n8n-nodes-base.quickbooks",
      "position": [
        2416,
        128
      ]
    },
    {
      "id": "af8ca67d-4b89-438c-911f-8d8fd872845a",
      "name": "Log to Audit Trail",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2864,
        128
      ]
    },
    {
      "id": "532be0b0-4097-465a-87dc-6a7ce8700051",
      "name": "Send Success Notification",
      "type": "n8n-nodes-base.slack",
      "position": [
        3120,
        128
      ]
    },
    {
      "id": "2313ccc7-7d6a-4cf9-98e2-209b97a1373c",
      "name": "Prepare Audit Log Entry",
      "type": "n8n-nodes-base.set",
      "position": [
        2688,
        128
      ]
    },
    {
      "id": "5c5cb05c-fd9c-43b2-b52d-a72f615bd29f",
      "name": "OpenAI GPT-4 for Parser",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        656,
        528
      ]
    },
    {
      "id": "7b0d715c-d7d6-480b-9cd5-6881ef73f397",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1296,
        -32
      ],
      "parameters": {
        "width": 320,
        "height": 320,
        "content": "## Email Trigger\nWatches inbox and downloads invoice attachments automatically."
      }
    },
    {
      "id": "2c11c5ff-21cd-4f6a-a529-e1c3375110e1",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -928,
        -32
      ],
      "parameters": {
        "width": 336,
        "height": 336,
        "content": "## Configuration\nStores OCR API, thresholds, Slack channel, and audit sheet settings. and Extracts sender info, timestamp, file hash, and vendor details."
      }
    },
    {
      "id": "33e0643c-a529-481e-ab04-f5c9bad57d76",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        -192
      ],
      "parameters": {
        "width": 320,
        "height": 576,
        "content": "## File Processing\nRoutes PDF to extractor or images to OCR API for text extraction."
      }
    },
    {
      "id": "0f6d8ca1-4844-4d92-b39d-59615b61337f",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        -64
      ],
      "parameters": {
        "width": 320,
        "height": 320,
        "content": "## AI Extraction\nAI extracts structured invoice data with confidence scores."
      }
    },
    {
      "id": "154488fb-3e0d-44fe-8ebe-130eb5455da0",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        816,
        -48
      ],
      "parameters": {
        "width": 464,
        "height": 320,
        "content": "## Validation and Masking\nRecalculates totals and checks for mismatches and Masks sensitive data like PAN, GST, and bank details."
      }
    },
    {
      "id": "35f6626f-fc9f-4452-84a9-c62734144635",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1328,
        -48
      ],
      "parameters": {
        "width": 320,
        "height": 320,
        "content": "## Review Check\nFlags invoices needing human review based on validation or confidence."
      }
    },
    {
      "id": "4ad1c7d4-cf81-4e40-acc4-3dbd5092c09f",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1744,
        -368
      ],
      "parameters": {
        "width": 496,
        "height": 320,
        "content": "## Human Review\nSends Slack alert and waits for approval if issues are found."
      }
    },
    {
      "id": "cdeed72c-3983-4827-9446-eddae4e1bfb0",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2384,
        -16
      ],
      "parameters": {
        "width": 224,
        "height": 320,
        "content": "## Accounting Sync\nCreates bill in QuickBooks for approved invoices."
      }
    },
    {
      "id": "1e9d1916-ef4c-4e57-b12c-1dce1236c238",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2656,
        -16
      ],
      "parameters": {
        "width": 352,
        "height": 320,
        "content": "## Audit Logging\nLogs processing details and results to Google Sheets."
      }
    },
    {
      "id": "ba17386f-97fe-4872-82fc-eb1a4434142d",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1920,
        -16
      ],
      "parameters": {
        "width": 480,
        "height": 368,
        "content": "## How it works\nMonitors email for invoice attachments, extracts data using OCR and AI, validates totals, masks sensitive fields, and decides whether to auto-process or send for review.\n\n## Setup\nConn"
      }
    },
    {
      "id": "81d06077-6579-4d81-86a1-8d92c61f81ab",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3040,
        -16
      ],
      "parameters": {
        "width": 352,
        "height": 320,
        "content": "## Notifications\nSends success message after invoice is processed."
      }
    }
  ],
  "connections": {
    "OpenAI GPT-4": {
      "ai_languageModel": [
        [
          {
            "node": "AI Invoice Extractor",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Mask PII Data": {
      "main": [
        [
          {
            "node": "Check if Review Needed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OCR for Images": {
      "main": [
        [
          {
            "node": "Merge OCR Results",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Check File Type": {
      "main": [
        [
          {
            "node": "Extract Text from PDF",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "OCR for Images",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge OCR Results": {
      "main": [
        [
          {
            "node": "AI Invoice Extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log to Audit Trail": {
      "main": [
        [
          {
            "node": "Send Success Notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Review Request": {
      "main": [
        [
          {
            "node": "Wait for Human Review",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Invoice Extractor": {
      "main": [
        [
          {
            "node": "Validate and Recalculate Totals",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text from PDF": {
      "main": [
        [
          {
            "node": "Merge OCR Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Invoice Email Trigger": {
      "main": [
        [
          {
            "node": "Workflow Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Invoice Schema Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Invoice Extractor",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Human Review": {
      "main": [
        [
          {
            "node": "Create QuickBooks Bill",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if Review Needed": {
      "main": [
        [
          {
            "node": "Send Review Request",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create QuickBooks Bill",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create QuickBooks Bill": {
      "main": [
        [
          {
            "node": "Prepare Audit Log Entry",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Configuration": {
      "main": [
        [
          {
            "node": "Capture Invoice Metadata",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI GPT-4 for Parser": {
      "ai_languageModel": [
        [
          {
            "node": "Invoice Schema Parser",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Audit Log Entry": {
      "main": [
        [
          {
            "node": "Log to Audit Trail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Capture Invoice Metadata": {
      "main": [
        [
          {
            "node": "Check File Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate and Recalculate Totals": {
      "main": [
        [
          {
            "node": "Mask PII Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}