Skip to main content
Time to complete: 45 minutesDifficulty: IntermediatePrerequisites: Access to your document source, access to your target system and master dataYou’ll build: An agent that extracts fields from invoices, receipts, or IDs, validates them against your data, and routes low-confidence or anomalous records for human review

Why Automate This?

The Problem: Documents arrive in bulk — scanned invoices from vendors, receipts submitted by employees, ID copies from customers. Someone has to open each file, read the fields, and key them into a system. They cross-check every entry against vendor lists or PO registers and flag anything that looks wrong. At any volume, this is slow, error-prone, and expensive. A misread invoice number, a vendor not in the system, or a VAT rate that does not match all create downstream problems in finance, compliance, or operations. The Solution: A Duvo agent that reads every document using the Intelligent Document Reader, extracts the fields you need, validates each field against your master data, and routes anything below your confidence threshold or outside your rules to a human reviewer. Clean documents go straight to your system of record. Borderline ones get a human decision before anything is written. Expected Results:
  • Eliminate manual data entry for clean, well-formatted documents
  • Catch extraction errors and validation failures before they reach your system
  • Create a full audit trail: what was extracted, what was changed by a reviewer, and why
  • Scale document processing without adding headcount

What You’ll Build

By the end of this playbook, you’ll have an agent that:
  1. Reads incoming documents (PDFs, scanned images, or Word files) from a folder, email, or upload
  2. Extracts structured fields: vendor, invoice number, line items, amounts, dates, tax, and any custom fields you need
  3. Checks field-level confidence scores and flags anything the extraction was uncertain about
  4. Cross-validates extracted values against your master data: vendor list, PO register, employee directory, or product catalog
  5. Handles tax, currency, and formatting edge cases (VAT rates, multi-currency, multi-page documents)
  6. Routes low-confidence or anomalous documents to a human reviewer with full extraction context
  7. Writes validated records to your system of record: ERP, spreadsheet, finance system, or database
  8. Maintains a complete audit trail of every extraction, review decision, and write action
Connections used:
  • Intelligent Document Reader — extract text and structured fields from PDFs, Word files, scanned images, and photos
  • Email Attachments Reader (if documents arrive by email) — pull attachments from incoming messages
  • Your source system — Google Drive, SharePoint, email inbox, or a file upload trigger
  • Your target system — NetSuite, SAP, Google Sheets, Salesforce, Dynamics 365, or your ERP
  • Human-in-the-Loop — pause for review on low-confidence extractions and validation failures

Before You Start

Make sure you have these ready:
Sample documents — Prepare a test set of 8-12 documents covering:
  • Clean digital PDF invoice
  • Scanned image invoice (JPG or PNG)
  • Multi-page PDF
  • Document with multiple tax rates
  • Zero-tax or tax-exempt document
  • At least one intentionally imperfect scan (low resolution, skewed, or photographed)
Anonymize each file before use: redact or replace vendor names, amounts, and personal data with fictional values. Upload the set to Files so the whole team can run tests with consistent inputs. Reuse this canonical test suite whenever you change the AOP.
Master data access — Your vendor list, PO register, employee directory, or product catalog. Either accessible via API in your target system, or exportable as a CSV you can upload to Files.
Target system login — A login with read and write access to the system where validated records will land. Store logins securely.
Field list — Know exactly which fields you need to extract. For invoices: vendor name, vendor ID, invoice number, invoice date, due date, line items (description, quantity, unit price, total), subtotal, tax amount, tax rate, and total amount payable. Adjust for your document type.
Validation rules — Document your rules: which vendors are in your system, what PO number formats look valid, what quantity or amount ranges are normal.

Create Your Agent

  1. Click ”+ Create Agent” from your dashboard.
  2. Select “Use Agent Builder”.

Describe Your Workflow

Paste this prompt into the Agent Builder and replace the bracketed placeholders with your specifics:
Click “Generate” to create the agent AOP.

Review Generated AOP

Duvo will generate a structured AOP from your description. Before continuing, confirm:
  • The document type (invoice, receipt, ID) is correctly named throughout.
  • The field list matches what your target system actually requires.
  • The validation rules reflect your real business rules — not overly strict (causing too many flags) or too loose (letting bad data through).
  • The anomaly routing describes what your reviewers will see and what actions they can take.
Edit the AOP directly to adjust anything that does not match.

Configure Connections

Click “Connections” and add:
  1. Intelligent Document Reader — Already available by default; no additional setup required.
  2. Email Attachments Reader — Already available by default; needed if documents arrive as email attachments.
  3. Source connection — Gmail or Outlook (if triggered by email), Google Drive or SharePoint (if polling a folder), or leave unset if using manual file upload.
  4. Target system — The ERP, spreadsheet, or database where validated records land. See My Logins to store your login.
  5. Human-in-the-Loop — Already available by default.

Set Confidence Thresholds

The Intelligent Document Reader returns an extraction for each field. Add explicit confidence handling to your AOP:
Adjust thresholds based on what your team finds in testing (Step 9). Tighter thresholds mean more human reviews; looser thresholds mean more automated processing with some risk of errors slipping through.

Cross-Validate Against Master Data

Add validation against your reference data to catch mismatches before they reach your system:Vendor validation
PO/reference number validation
Amount cross-checks

Handle Tax, Currency, and Multi-Page Edge Cases

Real-world documents have edge cases that cause silent errors if not handled explicitly.Tax and VAT edge cases
Multi-page documents
Duplicate detection

Configure HITL Review Requests

When the agent routes a document for human review, give reviewers everything they need to decide quickly. Update your AOP with this format:
See Human-in-the-Loop and Designing Human-in-the-Loop Workflows for guidance on structuring effective review requests.

Test with Sample Documents

Before processing real documents, run tests that cover the range of scenarios your agent will encounter:
  1. Click “Start Work” to run the agent manually with a test document.
  2. Cover these test cases:
Review the session log after each test. Check that the extraction pulled the correct values and that validation fired on the right cases. Adjust confidence thresholds and validation rules in your AOP based on what you observe.

Write to Your Target System

The method the agent uses to create records depends on your system:API-connected systems (NetSuite, Salesforce, Dynamics 365, Supabase) The agent calls the system’s API directly. Confirm write permissions are granted to the login you added in Step 4.Spreadsheet-based systems (Google Sheets, Excel) The agent appends a row per document. Upload your column headers as a Files file so the agent knows the schema. See Google Sheets or Microsoft Excel.Web-only systems (browser-based ERPs) The agent navigates the system using Computer Use — it opens the browser, logs in, fills in the record form, and submits. Add to your AOP:
Desktop client systems (SAP GUI, legacy ERPs) Connect via Windows Remote Desktop to a machine running the client.

Expected Results

When your agent is running successfully: In your target system:
  • A new record for each validated document, with all extracted fields populated and source document reference included.
  • No partial or incorrect records — anomalous documents are held for human review before anything is written.
In your Requests:
  • Pending review requests for each flagged document, with extracted fields, confidence scores, and specific failure reasons clearly described.
In your audit log (spreadsheet, ERP, or Files):
  • For each document processed: document number, vendor, date, extracted fields, validation outcome (auto-validated or reviewed), reviewer name and corrections (if any), and timestamp.
In Duvo:
  • A complete session log for each run showing each extraction step, validation check, and write action.

Troubleshooting

  • Scanned quality: Low-resolution scans (below 150 DPI) reduce extraction accuracy. Where possible, request native digital PDFs from vendors rather than scans.
  • Complex layouts: Documents with heavy formatting, watermarks, or multi-column tables can confuse extraction. Test your most complex document types and add explicit AOP instructions: "The vendor name appears in the top-left corner of the first page." — spatial hints improve accuracy.
  • Non-standard field labels: Some vendors use non-standard labels (“Bill-to Party” instead of “Vendor Name”). Update your AOP to list the alternative labels your documents use.
  • Multi-page line items: If line items spanning multiple pages are only partially extracted, add: "Read all pages before extracting line items. Line items continue until the subtotal row."
  • Confidence threshold too high: Lower your threshold and re-run your test set to see the effect. A threshold of 85% is a reasonable starting point for most typed PDFs; scanned documents may need 75%.
  • Validation rules too strict: Check which rule is generating the most flags. Common culprits: vendor name matching (names differ slightly between document and master data), date format expectations, or amount ranges set too narrow for the actual data.
  • Vendor name normalization: Add a normalization step to your AOP: "Trim whitespace, remove punctuation, and convert to title case before looking up the vendor name." This handles “ACME CORP.”, “Acme Corp”, and “Acme Corp.” as the same vendor.
  • Review: confidence threshold too low: If low-confidence fields are passing through undetected, increase your threshold and/or raise the lower bound below which fields are treated as missing.
  • Math check not firing: Confirm your AOP explicitly instructs the agent to verify totals. Add a separate validation step: "After extracting all amounts, verify: total = subtotal + tax. If not, flag the specific discrepancy."
  • Blanket/standing invoices: Some vendors send monthly invoices with the same base reference number. Add an exception: "Treat document numbers ending in -YYYY-MM as recurring monthly invoices; do not flag these as duplicates."
  • Reused document numbers across vendors: Narrow the duplicate check to same vendor + same document number rather than document number alone.
  • Session log: Open the run in Duvo and check the session log for timeout or connection errors. The log shows exactly which step the agent stopped at.
  • Source permissions: Verify the source folder or inbox is still accessible and that the connected login has not expired. Re-authorize the connection if needed.
  • Requests: Check Requests for any pending Human-in-the-Loop requests that may be holding up the run.
  • Write permissions: Confirm the login used for the target system has create/write access, not just read.
  • API rate limits: If processing a large backlog, your target system may be throttling writes. Add a pause between writes in your AOP: "Wait 2 seconds between each record creation."
  • Schema mismatch: Your target system may reject records missing required fields. Identify which fields are mandatory and add them to the extraction and validation steps so documents are flagged before a write is attempted.

Take It Further

Once your agent is processing documents reliably, consider these enhancements: Route to BI reporting
Close-the-loop notifications
Batch processing from a shared folder
Escalate aging review requests
Connect to spend analytics See the ROI and business-impact reporting guide once available for how to surface document processing metrics — volume processed, auto-validated rate, review rate, and error rate — to your finance team.

Intelligent Document Reader

Extracts text, tables, and fields from PDFs, Word files, scanned images, and photos

Human-in-the-Loop

How to pause for human review and resume after a decision

Designing Human-in-the-Loop Workflows

Patterns for effective review requests and approval gates

Email Attachments Reader

Extracts content from email attachments, including PDFs and spreadsheets

Files

Upload master data (vendor lists, PO registers) for the agent to validate against

Computer Use

For writing to UI-only systems: browser automation for web ERPs, remote desktop for SAP GUI

My Logins

Store target system logins securely

Email Order Intake

Related playbook for processing orders arriving by email