Introduction
A distributor's accounts payable team receives around 600 supplier invoices a month. Some come to a shared mailbox, some are forwarded by buyers, and some arrive as photos in a WhatsApp group with the warehouse. An intern downloads and types them into the accounting system. Every quarter, a supplier calls about an unpaid invoice that nobody remembers seeing.
When teams automate this, they usually focus on extraction: getting an LLM or OCR service to read invoice numbers and totals. Extraction matters, but a pipeline that extracts well and loses one file in fifty is worse than the manual process, because nobody is looking anymore.
In this article you will learn how to capture documents from email and WhatsApp reliably, track every file through a state machine, extract and validate data, route uncertain cases to people, and prove that nothing was dropped.
Capture: Every File Gets a Record First
The first rule is that a document exists in your system before anything tries to understand it. When an email or message arrives, store the original file in object storage, compute a content hash, and create a document record. Only then start processing.
CREATE TABLE documents (
id uuid PRIMARY KEY,
tenant_id bigint NOT NULL,
source text NOT NULL, -- 'email', 'whatsapp', 'upload'
source_ref text NOT NULL, -- message ID + attachment index
sender text,
sha256 text NOT NULL,
storage_key text NOT NULL,
doc_type text, -- invoice, purchase_order, delivery_note
status text NOT NULL DEFAULT 'received',
received_at timestamptz NOT NULL DEFAULT now(),
UNIQUE (tenant_id, source, source_ref)
);
For email, use your provider's API or an inbound-parse webhook rather than polling a mailbox with fragile rules. For WhatsApp, the WhatsApp Business Platform sends a webhook with a media ID; download the file promptly, because media URLs are temporary. The unique constraint on source and source reference makes reprocessing a message safe, and the content hash flags the same invoice sent twice through different channels.
Track Every Document Through States
Give documents explicit states: received, classified, extracted, validated, needs_review, posted, rejected. Every transition is recorded with a timestamp and actor, whether a worker or a person. A dashboard showing counts by state and the age of the oldest document in each is how you prove nothing is stuck.
Any document that stays in an intermediate state longer than expected raises an alert. This is the mechanism that replaces the intern's memory.
Extract With Structure, Then Validate
Classify the document type first, then extract fields with a schema specific to that type. Modern LLMs can return structured JSON for invoices and purchase orders with high accuracy, especially when combined with OCR for scanned files. Ask for exactly the fields you need: supplier name and tax ID, invoice number and date, PO reference, line items, tax amounts, and total.
Then validate against your own data, because a well-formed answer is not a correct one. Does the supplier exist? Does the PO reference match an open PO for that supplier? Do line totals add up to the invoice total? Is the tax calculation consistent? Has this invoice number already been recorded for this supplier? Documents that pass every check move forward automatically; anything else goes to review with the failed checks listed.
Human Review That Feels Fast
The review screen should show the original document beside the extracted fields, highlight the fields that failed validation, and let the reviewer correct values and approve in one place. Record corrections, because they are the best data for improving prompts and rules.
Acknowledge receipt to the sender where it helps. A supplier who gets an automatic "Invoice INV-2219 received, reference D-48812" reply stops calling to check.
Practical Examples: Real-World Use Cases
The distributor in the introduction moved its invoice intake to a dedicated email address and a WhatsApp Business number. Within two months, about 70 percent of invoices were posted without manual typing, the rest went through a review screen, and the monthly reconciliation of received versus posted documents showed zero unexplained gaps.
An industrial supplier extracts customer purchase orders from PDFs and creates draft sales orders. Validation checks part numbers against the catalog and flags price differences above a threshold for the sales team.
A logistics company collects signed delivery notes as WhatsApp photos from drivers. Each photo is matched to a shipment by its reference number and stored against the delivery record, which made proof-of-delivery disputes far quicker to resolve.
Common Mistakes to Avoid
Processing attachments before storing them. A crash mid-processing loses the file.
Trusting extracted data without validating it against master data.
Relying on mailbox rules and manual forwarding as the intake mechanism.
Not deduplicating documents that arrive through more than one channel.
Hiding the review queue so items wait for days without anyone noticing.
Best Practices: Actionable Tips
Give suppliers and drivers one dedicated address or number per document type.
Keep originals immutable and link every extracted record back to its source file.
Measure the straight-through rate, review time, and oldest document age weekly.
Build a test set of difficult real documents and run it before changing extraction prompts.
Reconcile documents received against documents posted at least monthly.
Conclusion
A document intake pipeline succeeds when every file is accounted for, not only when extraction is accurate. Store originals and create a record before processing, track each document through explicit states, extract with type-specific schemas, validate against your own data, and make human review fast. The takeaway: build the tracking first and the extraction second, because a lost invoice costs more than a slow one.
Automate Document Intake With Parallaxis
Parallaxis builds document automation for B2B teams, capturing invoices, POs, and delivery proofs from email and WhatsApp, extracting data with AI, and validating it against ERP records. If documents still enter your business by hand, visit parallaxis.in to explore our automation services or discuss your intake process with us.

