Every office has the same chore: an email arrives with
scan0042.pdf, someone downloads it, renames it, and drags it into a project or customer folder - or forgets, and the file lives only in the mailbox. A small flow (Power Automate, n8n, Paperless-ngx) can do this on arrival: read the attachment, let a language model decide the document type, sender and reference, build a consistent file name, store the file in the right place and tag it. Unsure cases go to a review folder. This is deliberately small: days of work, no new platform, and a good first step for data preparation (PREP-009, PREP-010).
Problem & value
- Today: attachments are saved by hand or not at all; names are inconsistent and files sit in personal folders or the mailbox. When a colleague is absent, nobody finds the document.
- AI value: rules ("sender contains X") break on new senders and generic file names. A model reads the content and fills document type, reference, date and project, giving a searchable archive and a cleaner base for later AI search or a Copilot rollout.
- Boundary: this is filing, not accounting. Invoice extraction is DOC-001; central mailroom classification at scale is DOC-008.
- No reliable benefit figures exist for this niche; measure your own baseline.
Variants
- Shared mailbox (office@, orders@): best start. Personal mailbox: per-user flow with a category.
- Craft/construction: certificates, delivery notes, drawings per project number.
- Public sector: incoming mail into the e-file/DMS, with staff council involvement.
How it works
- new email (shared mailbox, trigger)
- skip noise (signature images, logos, tiny files, newsletters)
- read attachment (text layer, or OCR for scans)
- LLM: document type, sender/party, date, reference, project (JSON, fixed schema)
- lookup: map party/project against customer or project list
- build name YYYY-MM-DD_party_type_reference.pdf + target folder
- save to SharePoint / Nextcloud / file share, set tags
- low confidence or no match
- "to-check" folder + daily list for a human
- AI part: a small or mid-size model with a fixed JSON schema is enough. The prompt contains the allowed document types and your naming rules; the flow, not the model, builds the final name and path. Never let the model invent folder paths.
- Human in the loop: unsure or unmatched files are not guessed; they go to a review folder. The original mail stays in the mailbox, so nothing is lost if the flow errs.
Data preparation
Which data: a folder structure and naming convention, lists of customers, suppliers and projects, and 30-50 real example attachments with the correct target. Where it lives: shared mailboxes, SharePoint/Nextcloud/file shares, project numbers in Excel or the ERP.
Typical gaps: no agreed convention, private project lists, scans without text, folders with too wide access rights.
Preparation steps: 1. Agree 5-10 document types and one naming pattern (PREP-019). 2. Export customer, supplier and project lists to one clean table (PREP-005, PREP-011). 3. Tidy target structure and tags (PREP-009, PREP-010); check access rights (PREP-023). 4. Keep the example attachments as test set (PREP-018).
Tools: Excel/SharePoint lists, Power Automate or n8n, scanner with OCR.
Rough share of effort: about 50 percent - the rules and lookup lists take longer than the flow. See GUIDE-003.
Implementation paths
Which path for whom
- SMB - Path B: the flow must fit your own folders, project numbers and naming rules, so no product fits well; Power Automate (M365) or self-hosted n8n with an EU-region model is built in days. Path C where documents are sensitive.
- Enterprise - Path B: a flow platform usually exists (Power Automate, Logic Apps, n8n); one governed pattern is reused by many teams.
- Public - Path C: mail holds citizens' data; sovereignty rules favour self-hosted or German-cloud setups.
Path A - Buy (off-the-shelf)
Outlook rules plus Power Automate templates (no AI), or DMS products with mail intake: DocuWare, d.velop, ELO (German vendors). Choose A when senders and names are stable or a DMS already exists.
Path B - Build on cloud APIs
- Power Automate: trigger "When a new email arrives in a shared mailbox (V2)" (set Include Attachments to Yes; for personal mailboxes "When a new email arrives (V3)"), loop over attachments, AI Builder or a model API, SharePoint "Create file" [5]. New cloud flows stay in the EU Data Boundary for EU tenants, but Copilot inferencing can route outside it unless an admin switches this off, and some third-party models are excluded [3][4]. Verify the AI Builder location in your tenant.
- n8n (self-hosted in the EU or n8n Cloud EU): Email Trigger (IMAP) with attachment download, then an LLM node [1]. EU model options: Mistral, Azure OpenAI in an EU region, IONOS AI Model Hub, STACKIT.
- Google Workspace: Apps Script or Gmail filters plus Drive and the Gemini API.
- Leave posting of invoices to DOC-001.
Path C - Self-host (open source)
- Paperless-ngx: mail rules fetch IMAP mail, filter by sender or subject and assign tags, correspondent and document type [2]. GoBD process documentation is your task.
- n8n + Ollama: a small model (3-8B class) classifies and names; short text in, JSON out, so HW1 suffices.
- Nextcloud: Flow plus Assistant with a local model.
- Choose C for HR, health, legal or customer data, or when the same server serves AUTO-008, AUTO-012 and AUTO-016.
Path D - Custom training
Not needed; a schema plus 30-50 examples in the prompt is enough.
State of the art (2026)
- LLMs with structured output read most business PDFs reliably; weak points are poor scans, multi-document PDFs and unusual formats (CAD, ZIP). Unknown type goes to review.
- Models guess confidently: use a confidence field, a "none of the above" option and cross-check against lookup lists. Add a hash check against duplicates.
- Prompt injection: a hostile PDF can contain instructions. The model only fills a schema; the flow has no rights beyond "save file" (GUIDE-013).
Shared resources & combinations
- Same flow engine (workflow-automation + llm-small): AUTO-008, AUTO-012, AUTO-016.
- Escalation: invoices to DOC-001; high volume to DOC-008; parsing for AI search to DOC-014.
- Downstream: clean, tagged folders make AI search and Copilot safer (PREP-009, PREP-010, PREP-023).
Effort, cost & KPIs
- Path A: hours to a day. Path B: one to three days for a first mailbox incl. conventions and tests. Path C: two to five days incl. server setup.
- KPIs: share filed correctly untouched, share in review, minutes saved per week.
People & change
Involve early: department lead and end users decide folders and names; IT builds and secures the flow; data owners confirm lookup lists. The DPO checks personal data in attachments and the AVV (Art. 28 GDPR); a DPIA is normally not needed, but check if applicant or employee documents arrive (GUIDE-005, GUIDE-010).
Works council: depends. The flow logs senders and times; on a functional mailbox without individual evaluation risk is low, yet objective suitability for monitoring (§87(1) no. 6 BetrVG) and §90(1) no. 3 (timely information on AI-supported work) still apply. Personal mailboxes need more care; public bodies involve the Personalrat (GUIDE-004).
AI literacy: Art. 4 AI Act requires measures that support staff's AI literacy; a short briefing on misreads and the review folder is enough (GUIDE-006).
Pilot: one shared mailbox, one team, two to four weeks in parallel with manual filing, one champion; present it as relief from drag-and-drop (GUIDE-008, GUIDE-009).
Concerns: "my files vanish" (the original mail stays), "AI reads our mail" (one documented mailbox).
Risks, regulation & compliance
- EU AI Act: minimal risk, no Annex III use; Art. 4 literacy support applies (GUIDE-014).
- GDPR: attachments contain personal data; limit the flow to defined mailboxes, EU-hosted processing, AVV, deletion rules; health or HR documents argue for Path C.
- Records: accounting documents need tax-law retention (GoBD); a renamed copy must not replace the original.
- Security: least-privilege service account, malware scan before processing, action log (GUIDE-013).
- Mitigations: review folder, confidence threshold, monthly sample check (GUIDE-011).
Getting started
- Pick one shared mailbox; agree document types and one naming pattern.
- Collect 30-50 real attachments with the correct folder and name as test set.
- Build the flow in Power Automate or n8n with a review folder.
- Run it in parallel with manual filing for two weeks, then adjust.
- Clear data protection and works council points, then extend.
Sources
- n8n documentation - Email Trigger (IMAP) node - https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.emailimap
- Paperless-ngx documentation - Basic usage (mail accounts and rules) - https://docs.paperless-ngx.com/usage/
- Microsoft Learn - Data locations in Copilot Studio - https://learn.microsoft.com/en-us/microsoft-copilot-studio/data-location
- Microsoft Learn - Services that transfer data out of the EU Data Boundary on an ongoing basis - https://learn.microsoft.com/en-us/privacy/eudb/eu-data-boundary-ongoing-partial-transfers
- Microsoft Q&A - Rename and save PDF attachments from Outlook - https://learn.microsoft.com/en-us/answers/questions/5823916/rename-and-save-pdf-attachments-from-outlook
- Regulation (EU) 2024/1689 (AI Act) - https://eur-lex.europa.eu/eli/reg/2024/1689/oj