Extracting Invoices From WhatsApp Photos With AI Vision (Apps Script + Google Sheets)
Every logistics and field-sales team runs the same expensive process: a driver photographs a receipt into a WhatsApp group, and a back-office clerk manually types the invoice number, total, and date into a spreadsheet. H
Every logistics and field-sales team runs the same expensive process: a driver photographs a receipt into a WhatsApp group, and a back-office clerk manually types the invoice number, total, and date into a spreadsheet. Hundreds of receipts a week = transcription errors and thousands of wasted hours.
AI vision models kill that bottleneck. Here's the pipeline that turns a blurry field photo into clean structured data in seconds.
Why vision models beat traditional OCR
OCR reads characters. Modern vision models (Claude Vision, Gemini Vision, GPT-4 Vision) read structure โ they distinguish a tax ID from a total, and a date from an amount, even on crumpled, angled, or poorly lit receipts. No brittle per-vendor parsers.
The pipeline (3โ8 seconds end to end)
WhatsApp image โ Apps Script doPost โ forward to vision model
โ model returns JSON { InvoiceNumber, TotalAmount, VendorName,
Date, Category, confidence_score }
โ confidence routing:
> 90 โ auto-append to ledger
70โ90 โ flag for human review
< 70 โ ask driver to re-photo
โ write row to Google Sheet (+ link to original image)
โ auto WhatsApp confirmation to driver
The confidence_score is the whole trick โ it's what stops bad extractions from silently polluting your ledger.
Model selection (this drives your bill)
- Gemini Vision โ cost-efficient default, strong multilingual OCR, great on clean receipts.
- Claude Vision โ highest accuracy on degraded receipts; use for high-stakes flows.
- GPT-4o Vision โ competitive, strong structured extraction.
Pattern: Gemini for the first pass, escalate only low-confidence cases to Claude / GPT-4o.
The economics
~500 receipts/week: vision API $10โ40 + WhatsApp API $30โ60 + Apps Script free = ~$40โ100/month. Versus a clerk at ~25 hrs/week = $2,000โ4,000/month in loaded labor. Per-receipt cost: $0.005โ0.02.
Accuracy: 92โ97% on legible receipts, 75โ85% on handwritten/damaged โ hence the confidence routing.
The complete pipeline, categorization, and privacy controls are in the full guide on the MageSheet blog.
Built by the MageSheet team.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes โ full credit and traffic to the original publisher.