DEV Community

Cover image for Extracting Invoices From WhatsApp Photos With AI Vision (Apps Script + Google Sheets)
Hayrullah Kar
Hayrullah Kar

Posted on • Originally published at magesheet.com

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. 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
Enter fullscreen mode Exit fullscreen mode

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.

Top comments (0)