{"product_id":"n8n-workflow-classify-file-inbound-docs-with-openai-gmail","title":"n8n Workflow: Classify \u0026 File Inbound Docs with OpenAI + Gmail","description":"\u003ch3\u003eAutomatically classify and file inbound documents with OpenAI + Gmail—only when you need a human.\u003c\/h3\u003e\n\u003cp\u003eThis n8n workflow receives documents via a token-protected webhook, checks OCR and file metadata quality, then uses OpenAI to classify and extract key fields. Every outcome is stored in an n8n Data Table, high-confidence results are filed logically, and Gmail alerts are sent when OCR or AI results require human review.\u003c\/p\u003e\n\n\u003ch3\u003eWhat this workflow does\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eSecure intake:\u003c\/strong\u003e Accepts a POST request to an n8n \u003cem\u003ewebhook\u003c\/em\u003e and verifies it using a shared intake token.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eNormalize + key documents:\u003c\/strong\u003e Standardizes the payload (filename, MIME type, IDs, OCR text), generates a deterministic document key, redacts PII for the model, and uses a temporary in-memory claim to reduce concurrent reprocessing.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eDuplicate protection:\u003c\/strong\u003e Checks the \u003cstrong\u003en8n Data Table\u003c\/strong\u003e for an existing row with the same document key scope and immediately returns a “duplicate” response when already processed.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eDead-letter invalid inputs:\u003c\/strong\u003e If the item is permanently invalid (e.g., unsupported MIME type or malformed identifiers), it records a dead letter in the Data Table and responds with the dead-letter reason.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eOpenAI extraction + validation:\u003c\/strong\u003e For acceptable OCR quality, sends a bounded, redacted excerpt to \u003cstrong\u003eOpenAI\u003c\/strong\u003e to extract metadata (type, party, date, amount, currency). The workflow validates returned JSON against strict rules and confidence thresholds.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eFile vs. review:\u003c\/strong\u003e Fully validated, high-confidence results are recorded as \u003cstrong\u003eFiled\u003c\/strong\u003e with a logical archive path; other cases become \u003cstrong\u003eNeeds Review\u003c\/strong\u003e and trigger the appropriate \u003cstrong\u003eGmail\u003c\/strong\u003e alert before the workflow responds.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eScheduled review processing:\u003c\/strong\u003e Runs hourly to find “Needs Review” rows where no alerts have been sent (per the workflow logic).\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eUse cases\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eInbox-to-archive automation for customer documents (forms, statements, other inbound files) using OCR + AI classification.\u003c\/li\u003e\n  \u003cli\u003eInvoice- or record-like processing where only confident extracts are filed automatically.\u003c\/li\u003e\n  \u003cli\u003eOperational support queues: notify staff via Gmail when OCR quality or AI confidence is insufficient.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eTechnical details\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eNodes\/stack:\u003c\/strong\u003e webhook, if, code, data table, gmail, sticky note.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eCore mechanisms:\u003c\/strong\u003e deterministic document keys, PII redaction for OpenAI, strict JSON validation, confidence thresholds, duplicate\/dead-letter handling, and Gmail alerts for “Needs Review”.\u003c\/li\u003e\n\u003c\/ul\u003e","brand":"N8N Commerce","offers":[{"title":"Default Title","offer_id":45865766912179,"sku":"N8N-18351","price":74.99,"currency_code":"GBP","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0749\/6279\/6723\/files\/rJSPuLlDx3XJrXwkYrdYc_USjgM2d2.png?v=1787044797","url":"https:\/\/buyflowscripts.com\/products\/n8n-workflow-classify-file-inbound-docs-with-openai-gmail","provider":"N8N Commerce","version":"1.0","type":"link"}