Workflows· Data, Analytics & Finance

    The Invoice Pipeline

    A workflow that reads incoming PDF invoices, matches them against purchase orders in the ERP, and books matches automatically while routing discrepancies to the finance team for manual review.

    automatingreviewingdata-driven

    Description

    Steps

    Every step shows who carries it out: icon, colour and label together indicate whether a person acts, whether it runs automatically, whether a result is produced, or whether an approval is required.

    01Person

    The process starts as soon as a new email with a PDF invoice arrives in the invoice inbox.

    02Automated

    03Automated

    04Automated

    05Result

    06Person

    07Result

    Key
    PersonAutomatedResultApproval

    Requirements and operations

    Requirements

    • Invoice inbox A dedicated address for incoming PDFs, for example [email protected].
    • ERP or purchase order system SAP, Dynamics, or Odoo supplies the purchase order data and goods receipts.
    • Accounting system DATEV, Lexoffice, or a comparable system books the approved invoices.
    • LLM access and team chat Access to OpenAI, Claude, or Gemini for extraction and matching, plus Slack or Teams for escalations.

    Testing

    • Test invoices Test a real invoice with a matching purchase order and a second one with a deviating amount.
    • Extraction Check whether invoice number, supplier, amounts, IBAN, and purchase order number are correct in the JSON.
    • Matching and booking Check whether the tolerance applies correctly and the right invoice actually gets booked.
    • Edge cases Test poor scans, missing purchase order numbers, foreign currency, and duplicate submissions.

    Go-live

    • Approval Activate the workflow only once extraction, matching, and booking are reliably correct.
    • Pilot Start with a single top supplier and roll out step by step from there.
    • Mapping and tolerance Fine tune the account or cost center mapping and the tolerance value iteratively.
    • Expand Add duplicate detection, a tiered approval workflow above a threshold, and reporting as a next step.

    Common issues

    • Poor OCR quality Use a stronger model or enforce a higher minimum scan resolution.
    • Tolerance value too narrow or too wide Calibrate the value against real invoices from the past.
    • Missing purchase order number Use fallback matching by supplier, amount, and date.
    • Duplicate booking Check invoice number and supplier together as a unique key.

    Builder Prompt

    GOAL
    Build a workflow that automatically extracts invoice data from incoming PDF invoices, matches it against purchase order data and goods receipt in the ERP, and triggers the booking in the accounting system on a match. On discrepancies, the workflow notifies the finance team with full details and flags the case for manual review instead of booking it through automatically.
    
    Adapt the structure to the concepts of your automation tool (for example nodes, steps, zaps, or agent actions). While doing so, preserve the trigger logic, the sequence, the branching, and the data flow.
    
    TRIGGER
    Type: new email with a PDF attachment in the dedicated invoice inbox, for example [email protected].
    Filter: only attachments of type PDF, other emails are ignored.
    
    STEPS
    1. Read the PDF: obtain the text via OCR or extraction from the attachment.
    2. AI step: data extraction. Use exactly the Invoice Data Extraction working prompt (see the Working Prompts section). Output: JSON with all invoice fields.
    3. Duplicate check: check invoice number and supplier together as a unique key against already processed invoices. On a duplicate, jump directly to step 7 and flag the case as a duplicate.
    4. Load purchase order data: load the purchase order data via the purchase order number from the ERP (SAP, Dynamics, or Odoo). If the purchase order number is missing, use matching by supplier, amount, and date as a fallback.
    5. AI step: matching. Use exactly the Discrepancy Analysis working prompt (see the Working Prompts section) with the invoice JSON and the purchase order JSON as input. Output: JSON with a recommendation.
    6. Branch: if the recommendation is book_automatically, trigger the booking in the accounting system (DATEV, Lexoffice, or comparable) with cost center and account mapping.
    7. Otherwise, or on a duplicate or a missing purchase order: escalate to the finance team via ticket or a message in Slack or Teams, with invoice data, purchase order data, and all discrepancy details. Flag the case for manual review.
    8. Both branches: log the incoming email, the extracted JSON, the match result, and the final status in the audit log.
    
    PROMPTS
    Take over both working prompts from the section of the same name unchanged and in full. Do not alter the placeholders they contain, and map them as described in the data flow.
    
    DATA FLOW
    Step 1 to step 2: extracted invoice text.
    Step 2 to steps 3, 4, and 5: invoice JSON.
    Step 4 to step 5: purchase order data as purchase order JSON.
    Step 5 to steps 6 and 7: the recommendation, discrepancies found, details, and rationale fields from the match result.
    
    ERROR HANDLING
    Incomplete extraction, for example a missing invoice number or gross amount: do not book, escalate instead, and state the cause in the review note.
    No purchase order found, even with fallback matching: do not book, escalate instead.
    Duplicate detected: do not book, escalate as a duplicate instead.
    Foreign currency or an unusual format: escalate for manual review.
    Principle: when in doubt, never book automatically, escalate instead.
    
    PLACEHOLDER CONVENTION
    All placeholders in square brackets inside the two working prompts are mapped dynamically, as described in the data flow. The tolerance percentage in the matching prompt is not dynamic: you set it yourself before activation, calibrated against real invoices from the past. List all placeholders that require manual configuration separately at the end.
    
    SELF CHECK BEFORE COMPLETION
    Check, before you report the workflow as finished:
    1. Are all steps connected correctly, in particular the branch between booking and escalation and the audit log in both branches?
    2. Are both working prompts inserted in full and unchanged, and is the tolerance percentage mapped?
    3. Do the duplicate check and the fallback matching work as described?
    4. Are all points listed that require manual configuration: invoice inbox, ERP and accounting system access, cost center and account mapping, tolerance percentage, and escalation channel?

    Working prompts

    Invoice Data Extraction

    Reads the incoming invoice and returns all relevant fields as structured JSON.

    You are an expert in invoice analysis. Analyze the following invoice and extract all relevant data into a structured JSON format. If a detail is not unambiguously stated in the invoice text, mark it as an assumption rather than presenting it as certain.
    
    INVOICE:
    [INVOICE_TEXT]
    
    Extract the following information:
    - Invoice number
    - Supplier/issuer (name and address)
    - Invoice date
    - Due date
    - Net amount
    - VAT rate and amount
    - Gross amount (total)
    - Description of goods or services/line items
    - Purchase order number (if available)
    - IBAN/bank details
    
    OUTPUT FORMAT (JSON):
    {
      "invoice_number": "...",
      "supplier": {"name": "...", "address": "..."},
      "invoice_date": "YYYY-MM-DD",
      "due_date": "YYYY-MM-DD",
      "net_amount": 0.00,
      "vat_rate": 0.00,
      "vat_amount": 0.00,
      "gross_amount": 0.00,
      "line_items": ["Item 1", "Item 2"],
      "purchase_order_number": "...",
      "iban": "..."
    }
    
    If information is not available, set the value to null. Use correct number formats with a period as the decimal separator.

    Discrepancy Analysis

    Compares the extracted invoice data with the purchase order data and returns a structured recommendation.

    You are an expert in invoice auditing. Compare the extracted invoice data with the purchase order data and identify discrepancies. Explicitly mark any assessment for which relevant information is missing as an assumption.
    
    INVOICE DATA:
    [INVOICE_DATA_JSON]
    
    PURCHASE ORDER DATA:
    [PURCHASE_ORDER_DATA_JSON]
    
    CHECK CRITERIA:
    - Supplier matches
    - Amount deviates by no more than [TOLERANCE_PERCENT]%
    - Description of goods or services matches the purchase order
    - Purchase order number is correct (if available)
    
    OUTPUT:
    Create a structured analysis in the following JSON format:
    {
      "discrepancies_found": true/false,
      "details": [
        {"category": "Amount/Supplier/Service", "description": "...", "severity": "critical/medium/low"}
      ],
      "recommendation": "book_automatically" or "manual_review_required",
      "rationale": "..."
    }
    
    Be precise and state concrete figures for discrepancies. Amounts with a deviation below [TOLERANCE_PERCENT]% are considered correct.

    JSON export

    Setup

    Two routes lead to the same result. Pick the one that fits your setup.

    Suitable when you want to build the workflow in your own automation tool.

    1. Open your workflow tool, for example n8n, Make, Zapier or Langdock.
    2. Create a new workflow and give it a name.
    3. Choose the AI-assisted build option if your tool offers one.
    4. Paste the builder prompt from above in full.
    5. Check the result against the step sequence in this document, then add your access credentials and channels.

    Suitable when you want to take the workflow over unchanged.

    1. Download the JSON file from the JSON export section.
    2. Open the workflow area of your tool and create a new workflow.
    3. Give it a name and confirm.
    4. Open the menu on the workflow name and choose to import a JSON file.
    5. Upload the file, then add your own access credentials.
    6. Run a test before you activate the workflow.

    Last reviewed:

    In the workshop this becomes your method.

    A single prompt becomes a repeatable method. We show that in the workshop From Prompt to Method.

    View workshops

    Related resources

    Browse all resources

    Conversation, not pitch

    Understand first, then decide. We take time for an initial conversation, without sales pressure, without obligation.

    Schedule a call