Validate incoming XRechnung invoices from IMAP and archive them with Data Tables
Quick overview This workflow reads incoming invoice emails via IMAP, detects and parses XRechnung (UBL) XML attachments, validates required fields and totals, archives the XML to disk, logs key values to an n8n Data Table, and sends email notifications to accounting or the sender when processing fails.
How it works Reads new emails from an IMAP mailbox and downloads attachments. Searches each email’s attachments for an .xml file and ignores messages without an XML attachment. Extracts the XML text, converts it to JSON, and parses UBL Invoice fields into a normalized invoice object (and reports non-UBL/invalid XML as a processing error). Validates the invoice for required EN 16931 fields and recalculates totals and tax breakdowns to detect inconsistencies. If the invoice is valid, saves the XML file to a “gueltig” folder and inserts invoice metadata and amounts into an n8n Data Table. If the invoice is invalid, saves the XML file to a “fehlerhaft” folder and emails accounting with the error list. If enabled and the sender address is not a no-reply address, sends a follow-up email to the original sender requesting correction.
Setup Configure IMAP credentials for the mailbox that receives invoices and ensure attachments are downloaded. Configure SMTP credentials for sending emails, and set the notification and sender addresses in the workflow settings values. Create or select an n8n Data Table named “Rechnungseingang” and map its columns to the fields used for logging. Ensure the file system path used for archiving exists and is writable (for self-hosting, mount a host folder to /data/rechnungen and allow file access to that path). Optionally enable automatic replies to suppliers by setting the auto-reply flag once you are confident the validation rules fit your process.
Requirements IMAP mailbox for incoming invoices · SMTP access for notifications · UBL format only — CII/ZUGFeRD is detected and reported, but not parsed · Self-hosted: file access to the archive folder
Customization Replace the Data Table with Google Sheets, Airtable or a database · Disable file archiving if not needed · Adjust the accepted tax rates (currently 0/7/19 %) · Enable or disable automatic supplier replies
Additional info Tested against the official KoSIT reference invoices, including construction final invoices with retention amounts and prepayments. German setup guide included. Built by Blackforest Systems.
Related Templates
AI Email Classifier & Auto-Delete for Gmail (SPAM/OFFER Cleaner)
This workflow is designed for freelancers, solopreneurs, and business owners who receive a high volume of irrelevant mes...
Generate Product Ad Copy & CTAs with GPT-4 for Slack and Airtable
⚡ AI Copywriter Pro: Instant Ad Copy & CTA Generator Transform product details into compelling marketing copy in second...
Auto-classify Gmail emails with AI and apply labels for inbox organization
Who is this for? Professionals and individuals who receive high volumes of emails, those who want to automatically organ...
🔒 Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments