Docs/Integrations/n8n/Templates/Archive E-Invoices from Email

Archive E-Invoices from Email

Automatically receive, parse, and archive incoming e-invoices to Google Drive. Files are renamed with invoice number, date, and supplier name.

GmailInvoice-api.xhubGoogle DriveGoogle Sheets5 min setup

How This Workflow Works

Archive E-Invoices from Email — Workflow Diagram
  1. 1

    Watches Gmail for new emails with PDF or XML attachments

  2. 2

    Extracts attachments and filters for invoice files

  3. 3

    Auto-detects the e-invoice format (XRechnung, ZUGFeRD, Factur-X, etc.)

  4. 4

    Parses the invoice to extract metadata (invoice number, date, seller)

  5. 5

    Renames the file: 2025-01-15_SupplierName_INV-001.xml

  6. 6

    Uploads to Google Drive, organized by month

Why This Matters

Manual invoice filing is error-prone and time-consuming. Files arrive as attachment.pdf or rechnung_2025.xml — with no consistent naming. This workflow automatically creates a clean, searchable archive.

Google Sheets Structure

ColumnTypeExampleDescription
newFilenameText2025-01-15_Telekom_RE-2025-001.xmlRenamed filename as uploaded to Drive
monthFolderText2025-01Year-month for folder organization
invoiceNumberTextRE-2025-001Extracted invoice number
invoiceDateDate2025-01-15Invoice issue date
sellerNameTextDeutsche Telekom AGSeller/supplier company name
buyerNameTextMeine Firma GmbHBuyer/customer company name
totalNumber1785.00Invoice total amount
currencyTextEURCurrency code
formatTextxrechnungDetected e-invoice format

Setup Steps

  1. 1

    Install the n8n-nodes-invoice-api-xhub community node

  2. 2

    Create an API key at invoice-api.xhub.io

  3. 3

    Configure credentials: invoice-api.xhub, Gmail (OAuth2), Google Drive (OAuth2), Google Sheets (OAuth2)

  4. 4

    Set your Google Drive folder ID in the 'Google Drive: Upload' node

  5. 5

    Set your Google Sheets spreadsheet ID in the 'Google Sheets: Log Invoice' node

  6. 6

    Activate the workflow — it runs automatically on new emails

Preview (truncated)

json
1{
2 "name": "Archive E-Invoices from Email to Google Drive",
3 "nodes": [
4 {
5 "id": "trigger-email-archive",
6 "name": "Gmail Trigger",
7 "type": "n8n-nodes-base.gmailTrigger",
8 "typeVersion": 1.3,
9 "position": [400, 600],
10 "parameters": {
11 "simple": false,
12 "pollTimes": {
13 "item": [{ "mode": "everyMinute" }]
14 },
15 "filters": {
16 "q": "has:attachment filename:pdf OR filename:xml"
17 },
18 "options": {
19 "dataPropertyAttachmentsPrefixName": "attachment_",
20 "downloadAttachments": true
21 }
22 },
23 "credentials": {
24 "gmailOAuth2": {
25 "id": "",
26 "name": "Gmail account"
27 }
28 }
29 },
30 {
31 // ... (truncated)

Use Cases

E-Invoice Mandate 2025

Archive incoming e-invoices as required by the German B2B mandate

Accounts Payable

Organize supplier invoices automatically

Tax Preparation

Monthly folders make year-end accounting easy

Audit Compliance

Searchable archive with consistent naming

Get Started Now

Import the workflow into your n8n instance and get started in minutes.