# Validate incoming XRechnung invoices from IMAP and archive them: n8n workflow

> Started by an arriving email, and works across Email and n8n data table. 20 steps, 3 branches: a working afternoon to understand properly.

Source: https://millionrounds.com/workflow/validate-incoming-xrechnung-invoices-from-imap-and-archive-t (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [Money admin](https://millionrounds.com/workflows?category=Money+admin#library)

# Validate incoming XRechnung invoices from IMAP and archive them

Started by an arriving email, and works across Email and n8n data table. 20 steps, 3 branches: a working afternoon to understand properly.

Medium

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fvalidate-incoming-xrechnung-invoices-from-imap-and-archive-t)

**20 steps** Medium: a working afternoon

**3** Branches: places the flow splits

**0** Loops or waits

**2** Services it connects to

## The flow

Logic 12 Service 8

The steps in the order they run, from what starts it.

- 1 **Fetch Emails (IMAP)** Email Read Imap *Service*
- 2 **Set Configuration** Set *Logic*
- 3 **Find XML Attachment** Code *Logic*
- 4 **Has XML Attachment?** If *Logic*
- 5 **Extract XML Text** Extract From File *Service*
- 6 **No Invoice - Ignore** No Op *Logic*
- 7 **Convert XML to JSON** Xml *Logic*
- 8 **Parse XRechnung Fields** Code *Logic*
- 9 **Capture Processing Error** Code *Logic*
- 10 **Validate Invoice (EN 16931)** Code *Logic*
- 11 **Notify Unreadable File** Email Send *Service*
- 12 **Validation Passed?** If *Logic*
- 13 **Attach File (Valid)** Code *Logic*
- 14 **Attach File (Invalid)** Code *Logic*
- 15 **Save Valid Invoice** Read Write File *Service*
- 16 **Save Invalid Invoice** Read Write File *Service*
- 17 **Log To Data Table** Data Table *Service*
- 18 **Notify Accounting** Email Send *Service*
- 19 **Auto-Reply Enabled?** If *Logic*
- 20 **Email Sender For Correction** Email Send *Service*

## How it's built

- **Starts on:** An arriving email
- **Steps:** 20, with 3 branches
- **Size:** Medium: a working afternoon
- **Connects to:** Email, n8n data table
- **Model:** None. This is plumbing, not judgement

## Questions

What does it need to run?

An n8n account, plus your own Email account. You connect your own accounts after importing it; none are included.

What starts it?

It starts on an arriving email.

Does it use AI?

No. Every step is fixed logic or a call to a service, so it does the same thing every time.

How long does it take to set up?

Plan an afternoon. 20 steps is enough that you should read each one before running it.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

**Before you run it**

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 20 steps before you point it at anything that matters.

## Run it in n8n

- **Create your n8n account** Free to start. n8n is where the workflow runs. [Create an n8n account ↗](https://millionrounds.com/n8n)
- **Download the workflow** Free with a Millionrounds account. [Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fvalidate-incoming-xrechnung-invoices-from-imap-and-archive-t)
- **Paste it into n8n** Open a new workflow in n8n and paste. Then connect your own accounts.

Stored with the author's traces removed: canvas notes, instance identifiers, saved credential names and any live document they had left behind.

## Connects to

Each opens the other workflows that use it.

[Email](https://millionrounds.com/workflows?service=Email#library)[n8n data table](https://millionrounds.com/workflows?service=n8n+data+table#library)

## Workflows like it

Also money admin, with the same services where possible, closest in size first.

- [**Vet supplier payments with Bright Data and OpenAI** 20 steps · calls a model · Slack, n8n data table](https://millionrounds.com/workflow/vet-supplier-payments-with-bright-data-and-openai)
- [**Automate payment gateway & database transaction reconciliation** 19 steps · Email, Google Sheets](https://millionrounds.com/workflow/automate-payment-gateway-and-database-transaction-reconcilia)
- [**Invoice overdue reminder system - delivered with Airtable** 21 steps · Airtable, Email](https://millionrounds.com/workflow/invoice-overdue-reminder-system-delivered-with-airtable)
- [**Monitor bank transactions with Google Sheets and Slack** 19 steps · Email, Google Sheets](https://millionrounds.com/workflow/monitor-bank-transactions-with-google-sheets-and-slack)
- [**Generate research proposals with OpenAI** 21 steps · calls a model · n8n data table](https://millionrounds.com/workflow/generate-research-proposals-with-openai)
- [**Match supplier invoices to purchase orders with Gmail** 19 steps · calls a model · Gmail, n8n data table](https://millionrounds.com/workflow/match-supplier-invoices-to-purchase-orders-with-gmail)
