Quick overview
Watches Gmail for receipt and invoice emails, uploads PDF/JPG/PNG attachments to Lexware Office as vouchers, labels successful emails, and logs every file — with a named error branch and readable reasons for failed uploads.
How it works
- Runs every 5 minutes and searches Gmail for emails with attachments that do not have the
lexware-uploaded label.
- Splits each email into individual attachment items and keeps only PDF/JPG/PNG files that match receipt/invoice keywords (optional), are under 5 MB, and are not tiny images likely to be email-signature logos.
- Uploads each qualifying attachment to Lexware Office using the Public API endpoint
POST /v1/files with type=voucher, pacing requests and retrying transient failures.
- If the upload succeeds, deduplicates by email and adds a “processed” Gmail label so the same message is not picked up again.
- If the upload fails, maps the HTTP error to a readable reason, leaves the email unlabeled so it can retry on the next poll, and writes a per-file log line with the result.
Setup
- Create a Lexware Office XL Public API key and add it to an n8n HTTP Header Auth credential as
Authorization: Bearer <your_api_key>.
- Connect your Gmail account in n8n (Gmail OAuth2) for both reading messages and applying labels.
- Create a Gmail label (for example
lexware-uploaded), copy its label ID, and replace PROCESSED_LABEL_ID in the workflow configuration.
- Review and adjust the receipt keyword list,
REQUIRE_KEYWORD, and MIN_IMAGE_KB settings to match what you consider a receipt/invoice and which images to ignore.
Requirements
- An n8n instance (tested on self-hosted n8n 2.44.7; only built-in nodes, n8n Cloud not tested)
- Lexware Office XL (Public API is XL-only) and an API key
- New email with attachment: Gmail OAuth2
- Upload to Lexware Office: Header Auth (Authorization = Bearer + API key)
- Label email as processed: Gmail OAuth2