AutomationFlowsAI & RAG › Process Email Invoices with OCR and AI

Process Email Invoices with OCR and AI

Original n8n title: Process Email Invoices with Ocr, Gpt-4, Slack, Quickbooks and Google Sheets

ByResilNext @rnair1996 on n8n.io

This workflow automates invoice processing directly from your email inbox.

Event trigger★★★★★ complexityAI-powered31 nodesGmail TriggerHTTP RequestAgentOpenAI ChatOutput Parser StructuredSlackQuickBooksGoogle Sheets
AI & RAG Trigger: Event Nodes: 31 Complexity: ★★★★★ AI nodes: yes Added:

This workflow corresponds to n8n.io template #14272 — we link there as the canonical source.

This workflow follows the Agent → Gmail Trigger recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "nodes": [
    {
      "id": "558bd0c1-8a24-4b46-ab80-93245682fef8",
      "name": "Invoice Email Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -1184,
        96
      ],
      "parameters": {
        "simple": false,
        "filters": {
          "labelIds": [
            "AP Inbox"
          ]
        },
        "options": {
          "downloadAttachments": true
        },
        "pollTimes": {
          "item": [
            {
              "mode": "everyX",
              "unit": "minutes",
              "value": 5
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "2f998f59-b9c4-4e7a-a3fd-48a2c3a11011",
      "name": "Workflow Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        -880,
        96
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "ocrApiUrl",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__OCR API endpoint URL (e.g., OCR.space or Google Vision)__>"
            },
            {
              "id": "id-2",
              "name": "validationTolerance",
              "type": "number",
              "value": 1
            },
            {
              "id": "id-3",
              "name": "confidenceThreshold",
              "type": "number",
              "value": 0.85
            },
            {
              "id": "id-4",
              "name": "slackChannel",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Slack channel ID for notifications__>"
            },
            {
              "id": "id-5",
              "name": "auditSheetId",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Google Sheets ID for audit log__>"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "35acbac0-ec82-4a76-b5d9-3b14e0ba068e",
      "name": "Capture Invoice Metadata",
      "type": "n8n-nodes-base.set",
      "position": [
        -720,
        96
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "invoiceSource",
              "type": "string",
              "value": "email"
            },
            {
              "id": "id-2",
              "name": "receivedTimestamp",
              "type": "string",
              "value": "={{ $now.toISO() }}"
            },
            {
              "id": "id-3",
              "name": "fileHash",
              "type": "string",
              "value": "={{ $binary.attachment_0 ? $hash($binary.attachment_0.data, 'sha256') : '' }}"
            },
            {
              "id": "id-4",
              "name": "vendorName",
              "type": "string",
              "value": "={{ $json.from?.name || $json.from?.address || 'Unknown' }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "43e8d16f-26f2-4d53-b3c7-4d335d423589",
      "name": "Check File Type",
      "type": "n8n-nodes-base.if",
      "position": [
        -432,
        96
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": false,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "id-1",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $('Capture Invoice Metadata').item.json.attachment_0.mimeType }}",
              "rightValue": "pdf"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "8582e588-c4e2-43fb-ad1a-633b4a7fa75c",
      "name": "Extract Text from PDF",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -80,
        -16
      ],
      "parameters": {
        "options": {},
        "operation": "pdf",
        "binaryPropertyName": "attachment_0"
      },
      "typeVersion": 1.1
    },
    {
      "id": "a62d04a5-7ea0-46a1-a134-e3db5f99d194",
      "name": "OCR for Images",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -80,
        192
      ],
      "parameters": {
        "url": "={{ $('Workflow Configuration').first().json.ocrApiUrl }}",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "file",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "attachment_0"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "63d81b7b-381a-4175-8d14-293fcc9b74b7",
      "name": "Merge OCR Results",
      "type": "n8n-nodes-base.merge",
      "position": [
        224,
        96
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineAll"
      },
      "typeVersion": 3.2
    },
    {
      "id": "2da77dd8-9952-45fc-97a7-71540ec81281",
      "name": "AI Invoice Extractor",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        480,
        96
      ],
      "parameters": {
        "text": "={{ $json.extractedText || $json.ParsedResults?.[0]?.ParsedText || '' }}",
        "options": {
          "systemMessage": "You are an invoice data extraction specialist. Extract structured data from the provided invoice text and return it in the exact JSON schema format.\n\nYour task:\n1. Extract all invoice header fields (invoice number, date, due date, vendor details)\n2. Extract all line items with description, quantity, rate, and amount\n3. Extract tax information and totals\n4. Flag any fields with low confidence\n5. Do NOT perform calculations - only extract what you see\n6. Return ONLY the structured JSON output\n\nIMPORTANT: If a field is unclear or missing, set it to null and mark confidence as low."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3
    },
    {
      "id": "243f0c32-34b8-4759-b9e0-f954b6e7a3bb",
      "name": "OpenAI GPT-4",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        448,
        320
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "gpt-4o"
        },
        "options": {},
        "builtInTools": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "330bba5d-8e1a-4995-bcec-7639b57a9f42",
      "name": "Invoice Schema Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        576,
        320
      ],
      "parameters": {
        "autoFix": true,
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"invoiceNumber\": {\n      \"type\": \"string\",\n      \"description\": \"The invoice number\"\n    },\n    \"invoiceDate\": {\n      \"type\": \"string\",\n      \"description\": \"The date the invoice was issued\"\n    },\n    \"dueDate\": {\n      \"type\": \"string\",\n      \"description\": \"The payment due date\"\n    },\n    \"vendorName\": {\n      \"type\": \"string\",\n      \"description\": \"The name of the vendor\"\n    },\n    \"vendorGST\": {\n      \"type\": \"string\",\n      \"description\": \"The vendor's GST number\"\n    },\n    \"vendorPAN\": {\n      \"type\": \"string\",\n      \"description\": \"The vendor's PAN number\"\n    },\n    \"vendorBankAccount\": {\n      \"type\": \"string\",\n      \"description\": \"The vendor's bank account number\"\n    },\n    \"subtotal\": {\n      \"type\": \"number\",\n      \"description\": \"The subtotal amount before tax\"\n    },\n    \"taxAmount\": {\n      \"type\": \"number\",\n      \"description\": \"The tax amount\"\n    },\n    \"taxRate\": {\n      \"type\": \"number\",\n      \"description\": \"The tax rate percentage\"\n    },\n    \"total\": {\n      \"type\": \"number\",\n      \"description\": \"The total amount including tax\"\n    },\n    \"lineItems\": {\n      \"type\": \"array\",\n      \"description\": \"Array of line items on the invoice\",\n      \"items\": {\n        \"type\": \"object\",\n        \"properties\": {\n          \"description\": {\n            \"type\": \"string\",\n            \"description\": \"Description of the line item\"\n          },\n          \"quantity\": {\n            \"type\": \"number\",\n            \"description\": \"Quantity of the item\"\n          },\n          \"rate\": {\n            \"type\": \"number\",\n            \"description\": \"Rate per unit\"\n          },\n          \"amount\": {\n            \"type\": \"number\",\n            \"description\": \"Total amount for the line item\"\n          }\n        }\n      }\n    },\n    \"confidence\": {\n      \"type\": \"object\",\n      \"description\": \"Field-level confidence scores\",\n      \"properties\": {\n        \"invoiceNumber\": {\n          \"type\": \"number\"\n        },\n        \"invoiceDate\": {\n          \"type\": \"number\"\n        },\n        \"dueDate\": {\n          \"type\": \"number\"\n        },\n        \"vendorName\": {\n          \"type\": \"number\"\n        },\n        \"vendorGST\": {\n          \"type\": \"number\"\n        },\n        \"vendorPAN\": {\n          \"type\": \"number\"\n        },\n        \"vendorBankAccount\": {\n          \"type\": \"number\"\n        },\n        \"subtotal\": {\n          \"type\": \"number\"\n        },\n        \"taxAmount\": {\n          \"type\": \"number\"\n        },\n        \"taxRate\": {\n          \"type\": \"number\"\n        },\n        \"total\": {\n          \"type\": \"number\"\n        }\n      }\n    }\n  }\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "7bc970a4-4ad1-4159-b5a4-4839c9740eaa",
      "name": "Validate and Recalculate Totals",
      "type": "n8n-nodes-base.code",
      "position": [
        880,
        96
      ],
      "parameters": {
        "jsCode": "const invoice = $input.first().json;\nconst tolerance = $('Workflow Configuration').first().json.validationTolerance;\n\n// Recalculate line totals\nlet calculatedSubtotal = 0;\nconst validatedLineItems = [];\n\nfor (const item of invoice.lineItems || []) {\n  const calculatedAmount = (item.quantity || 0) * (item.rate || 0);\n  const amountMatch = Math.abs(calculatedAmount - (item.amount || 0)) <= tolerance;\n  \n  validatedLineItems.push({\n    ...item,\n    calculatedAmount,\n    amountMatch\n  });\n  \n  calculatedSubtotal += calculatedAmount;\n}\n\n// Recalculate tax and total\nconst calculatedTax = calculatedSubtotal * ((invoice.taxRate || 0) / 100);\nconst calculatedTotal = calculatedSubtotal + calculatedTax;\n\n// Validation checks\nconst subtotalMatch = Math.abs(calculatedSubtotal - (invoice.subtotal || 0)) <= tolerance;\nconst taxMatch = Math.abs(calculatedTax - (invoice.taxAmount || 0)) <= tolerance;\nconst totalMatch = Math.abs(calculatedTotal - (invoice.total || 0)) <= tolerance;\n\nconst validationPassed = subtotalMatch && taxMatch && totalMatch;\n\nreturn {\n  json: {\n    ...invoice,\n    lineItems: validatedLineItems,\n    validation: {\n      calculatedSubtotal,\n      calculatedTax,\n      calculatedTotal,\n      subtotalMatch,\n      taxMatch,\n      totalMatch,\n      validationPassed,\n      tolerance\n    }\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "0004ac1f-05d3-49de-9ba9-8174f32d4516",
      "name": "Mask PII Data",
      "type": "n8n-nodes-base.code",
      "position": [
        1120,
        96
      ],
      "parameters": {
        "jsCode": "const invoice = $input.first().json;\n\n// PII masking functions\nfunction maskPAN(pan) {\n  if (!pan || pan.length < 10) return pan;\n  return 'XXXX-XXXX-' + pan.slice(-4);\n}\n\nfunction maskBankAccount(account) {\n  if (!account || account.length < 4) return account;\n  return 'XXXX-XXXX-' + account.slice(-4);\n}\n\nfunction maskGST(gst) {\n  if (!gst || gst.length < 6) return gst;\n  return 'XXXX-XXXX-' + gst.slice(-6);\n}\n\n// Store original values (encrypted in production)\nconst originalPII = {\n  vendorPAN: invoice.vendorPAN,\n  vendorBankAccount: invoice.vendorBankAccount,\n  vendorGST: invoice.vendorGST\n};\n\n// Apply masking\nconst maskedInvoice = {\n  ...invoice,\n  vendorPAN: maskPAN(invoice.vendorPAN),\n  vendorBankAccount: maskBankAccount(invoice.vendorBankAccount),\n  vendorGST: maskGST(invoice.vendorGST),\n  _originalPII: originalPII,\n  _piiMasked: true\n};\n\nreturn { json: maskedInvoice };"
      },
      "typeVersion": 2
    },
    {
      "id": "3392ea76-e057-4a34-8b8b-9e48d64f6e81",
      "name": "Check if Review Needed",
      "type": "n8n-nodes-base.if",
      "position": [
        1392,
        96
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "id-1",
              "operator": {
                "type": "boolean",
                "operation": "true"
              },
              "leftValue": "={{ !$json.validation?.validationPassed || Object.values($json.confidence || {}).some(c => c < $('Workflow Configuration').first().json.confidenceThreshold) }}"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "ebee130e-ad08-4b50-b4b4-1e2671064759",
      "name": "Wait for Human Review",
      "type": "n8n-nodes-base.wait",
      "position": [
        2016,
        -208
      ],
      "parameters": {
        "resume": "webhook",
        "options": {},
        "responseMode": "lastNode"
      },
      "typeVersion": 1.1
    },
    {
      "id": "98f2f9df-273a-4ade-bf0b-284354ce2b69",
      "name": "Send Review Request",
      "type": "n8n-nodes-base.slack",
      "position": [
        1824,
        -208
      ],
      "parameters": {
        "text": "=Invoice Review Required\n\n*Invoice:* {{ $json.invoiceNumber }}\n*Vendor:* {{ $json.vendorName }}\n*Total:* {{ $json.total }}\n*Issue:* {{ !$json.validation?.validationPassed ? \"Validation failed - amounts don't match\" : \"Low confidence extraction\" }}\n\n*Validation Details:*\n- Subtotal Match: {{ $json.validation?.subtotalMatch }}\n- Tax Match: {{ $json.validation?.taxMatch }}\n- Total Match: {{ $json.validation?.totalMatch }}\n\nPlease review and approve/reject.",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Workflow Configuration').first().json.slackChannel }}"
        },
        "otherOptions": {}
      },
      "typeVersion": 2.4
    },
    {
      "id": "703bbaa6-08bd-4aea-b088-a47621f95b16",
      "name": "Create QuickBooks Bill",
      "type": "n8n-nodes-base.quickbooks",
      "position": [
        2416,
        128
      ],
      "parameters": {
        "Line": [
          {
            "Amount": "={{ $json.lineItems[0].amount }}",
            "itemId": "={{ $json.lineItems[0].itemId }}",
            "LineNum": 1,
            "DetailType": "ItemBasedExpenseLineDetail",
            "Description": "={{ $json.lineItems[0].description }}"
          }
        ],
        "resource": "bill",
        "VendorRef": "={{ $json.vendorName }}",
        "operation": "create",
        "additionalFields": {
          "DueDate": "={{ $json.dueDate }}",
          "TxnDate": "={{ $json.invoiceDate }}",
          "TotalAmt": "={{ $json.totalAmount }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "af8ca67d-4b89-438c-911f-8d8fd872845a",
      "name": "Log to Audit Trail",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2864,
        128
      ],
      "parameters": {
        "columns": {
          "value": {
            "total": "={{ $json.total }}",
            "fileHash": "={{ $json.fileHash }}",
            "vendorName": "={{ $json.vendorName }}",
            "quickbooksId": "={{ $json.quickbooksId }}",
            "humanReviewed": "={{ $json.humanReviewed }}",
            "invoiceNumber": "={{ $json.invoiceNumber }}",
            "auditTimestamp": "={{ $json.auditTimestamp }}",
            "confidenceScores": "={{ $json.confidenceScores }}",
            "processingStatus": "={{ $json.processingStatus }}",
            "validationResults": "={{ $json.validationResults }}"
          },
          "schema": [
            {
              "id": "invoiceNumber",
              "required": false,
              "displayName": "invoiceNumber",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "vendorName",
              "required": false,
              "displayName": "vendorName",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "total",
              "required": false,
              "displayName": "total",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "auditTimestamp",
              "required": false,
              "displayName": "auditTimestamp",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "quickbooksId",
              "required": false,
              "displayName": "quickbooksId",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "processingStatus",
              "required": false,
              "displayName": "processingStatus",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "humanReviewed",
              "required": false,
              "displayName": "humanReviewed",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "validationResults",
              "required": false,
              "displayName": "validationResults",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "confidenceScores",
              "required": false,
              "displayName": "confidenceScores",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "fileHash",
              "required": false,
              "displayName": "fileHash",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "invoiceNumber"
          ]
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Audit Log"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Workflow Configuration').first().json.auditSheetId }}"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "532be0b0-4097-465a-87dc-6a7ce8700051",
      "name": "Send Success Notification",
      "type": "n8n-nodes-base.slack",
      "position": [
        3120,
        128
      ],
      "parameters": {
        "text": "=\u2705 Invoice Processed Successfully\n\n*Invoice:* {{ $json.invoiceNumber }}\n*Vendor:* {{ $json.vendorName }}\n*Total:* {{ $json.total }}\n*QuickBooks ID:* {{ $json.quickbooksId }}\n*Human Reviewed:* {{ $json.humanReviewed ? \"Yes\" : \"No\" }}\n\nAudit log updated.",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Workflow Configuration').first().json.slackChannel }}"
        },
        "otherOptions": {}
      },
      "typeVersion": 2.4
    },
    {
      "id": "2313ccc7-7d6a-4cf9-98e2-209b97a1373c",
      "name": "Prepare Audit Log Entry",
      "type": "n8n-nodes-base.set",
      "position": [
        2688,
        128
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "auditTimestamp",
              "type": "string",
              "value": "={{ $now.toISO() }}"
            },
            {
              "id": "id-2",
              "name": "quickbooksId",
              "type": "string",
              "value": "={{ $json.id }}"
            },
            {
              "id": "id-3",
              "name": "processingStatus",
              "type": "string",
              "value": "completed"
            },
            {
              "id": "id-4",
              "name": "humanReviewed",
              "type": "boolean",
              "value": "={{ $('Wait for Human Review').first() ? true : false }}"
            },
            {
              "id": "id-5",
              "name": "validationResults",
              "type": "string",
              "value": "={{ JSON.stringify($json.validation) }}"
            },
            {
              "id": "id-6",
              "name": "confidenceScores",
              "type": "string",
              "value": "={{ JSON.stringify($json.confidence) }}"
            },
            {
              "id": "id-7",
              "name": "maskedData",
              "type": "boolean",
              "value": true
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "5c5cb05c-fd9c-43b2-b52d-a72f615bd29f",
      "name": "OpenAI GPT-4 for Parser",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        656,
        528
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "gpt-4o"
        },
        "options": {},
        "builtInTools": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "7b0d715c-d7d6-480b-9cd5-6881ef73f397",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1296,
        -32
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 320,
        "content": "## Email Trigger\nWatches inbox and downloads invoice attachments automatically."
      },
      "typeVersion": 1
    },
    {
      "id": "2c11c5ff-21cd-4f6a-a529-e1c3375110e1",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -928,
        -32
      ],
      "parameters": {
        "color": 7,
        "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."
      },
      "typeVersion": 1
    },
    {
      "id": "33e0643c-a529-481e-ab04-f5c9bad57d76",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        -192
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 576,
        "content": "## File Processing\nRoutes PDF to extractor or images to OCR API for text extraction."
      },
      "typeVersion": 1
    },
    {
      "id": "0f6d8ca1-4844-4d92-b39d-59615b61337f",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        -64
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 320,
        "content": "## AI Extraction\nAI extracts structured invoice data with confidence scores."
      },
      "typeVersion": 1
    },
    {
      "id": "154488fb-3e0d-44fe-8ebe-130eb5455da0",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        816,
        -48
      ],
      "parameters": {
        "color": 7,
        "width": 464,
        "height": 320,
        "content": "## Validation and Masking\nRecalculates totals and checks for mismatches and Masks sensitive data like PAN, GST, and bank details."
      },
      "typeVersion": 1
    },
    {
      "id": "35f6626f-fc9f-4452-84a9-c62734144635",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1328,
        -48
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 320,
        "content": "## Review Check\nFlags invoices needing human review based on validation or confidence."
      },
      "typeVersion": 1
    },
    {
      "id": "4ad1c7d4-cf81-4e40-acc4-3dbd5092c09f",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1744,
        -368
      ],
      "parameters": {
        "color": 7,
        "width": 496,
        "height": 320,
        "content": "## Human Review\nSends Slack alert and waits for approval if issues are found."
      },
      "typeVersion": 1
    },
    {
      "id": "cdeed72c-3983-4827-9446-eddae4e1bfb0",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2384,
        -16
      ],
      "parameters": {
        "color": 7,
        "width": 224,
        "height": 320,
        "content": "## Accounting Sync\nCreates bill in QuickBooks for approved invoices."
      },
      "typeVersion": 1
    },
    {
      "id": "1e9d1916-ef4c-4e57-b12c-1dce1236c238",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2656,
        -16
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 320,
        "content": "## Audit Logging\nLogs processing details and results to Google Sheets."
      },
      "typeVersion": 1
    },
    {
      "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\nConnect Gmail, OpenAI, OCR API, Slack, QuickBooks, and Google Sheets. Configure thresholds, audit sheet, and test with sample invoices before enabling.."
      },
      "typeVersion": 1
    },
    {
      "id": "81d06077-6579-4d81-86a1-8d92c61f81ab",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3040,
        -16
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 320,
        "content": "## Notifications\nSends success message after invoice is processed."
      },
      "typeVersion": 1
    }
  ],
  "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
          }
        ]
      ]
    }
  }
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow automates invoice processing directly from your email inbox.

Source: https://n8n.io/workflows/14272/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

&gt; Note: This workflow uses sticky notes extensively to document each logical section of the automation. Sticky notes are mandatory and already included to explain OCR, AI parsing, folder logic, dup

QuickBooks, Google Sheets, Google Drive +5
AI & RAG

CV → Match → Screen → Decide, all automated

HTTP Request, Information Extractor, Google Sheets +7
AI & RAG

This workflow streamlines academic assessment through a multi-agent AI system that interprets rubrics, grades submissions, checks for plagiarism, performs quality moderation, generates feedback, and e

HTTP Request, Agent, OpenAI Chat +3
AI & RAG

Enterprise-grade resume screening automation built for production environments. This workflow combines intelligent AI analysis with comprehensive error handling to ensure reliable processing of candid

Gmail Trigger, Google Drive, HTTP Request +6
AI & RAG

*Tags: AI Agent, Supply Chain, Logistics, Circular Economy, Route Planning, Transportation, GPS API*

Gmail Trigger, Output Parser Structured, Agent +4