r/AI_Agents • • 3d ago

Tutorial Image document processing automation

I’m looking to automate a document-processing workflow and would appreciate advice on the best way to build it with minimal costs.

What I need:

  1. Send photos (JPG/PNG) via WhatsApp.
  2. Automatically extract text using OCR.
  3. Convert the extracted information into a predefined, consistent text template, following strict formatting rules.
  4. Send the final text by email (Gmail, in an existing email thread) and return the same text via WhatsApp.

Things to take info account:
- No PDF files or attachments — text only.
- I have a private Windows 11 laptop running 24/7 at home (Intel Core i5 (8th generation), 8 GB RAM, SSD, integrated graphics) which might not be powerful enough to handle the automation locally but it can be mentioned.
- Around 20–50 documents processed per day.

My priorities are:

  1. Ideally zero ongoing costs, or at least very low costs.
  2. Keep OCR and text processing local whenever possible.
  3. Avoid unnecessary cloud services and subscriptions.
  4. Make the workflow reliable, secure, and easy to maintain.

Has anyone built something similar? Any practical advice would be greatly appreciated!

12 Upvotes

27 comments sorted by

1

u/whiteafrikkanoloco 2d ago

I've built a similar tool, before anyone can give you a solution. I do have questions: 1/ What exactly are the documents? I am specifically wondering about the quality and the standardization. 2/ Are these documents confidential? Is strict privacy truly required? 3/ What is the error tolerance? Will you be OK with a process that includes human-in-the-loop?

1

u/Vader20FF 1d ago
  1. Can’t tell you exactly but these are documents which share similar schema and data (including words and numbers).
  2. Strict privacy is not required however local execution would be prefered.
  3. Very very small
  4. I would rather have the whole process automated without any human interference

1

u/AutoModerator 3d ago

Thank you for your submission, for any questions regarding AI, please check out our wiki at https://www.reddit.com/r/ai_agents/wiki (this is currently in test and we are actively adding to the wiki)

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/AgentSearchEngine 3d ago

that laptop is fine for the ocr part, 50 docs a day is nothing. the whatsapp end is the annoying bit, and id keep the template strict and rule based, only let a model touch the messy ones that fail the format check

1

u/InterviewOld5242 3d ago

whatsapp webhooks are a pain, try using n8n with the WhatsApp API. I set up a flow that grabs images, runs ocr via tesseract, then formats the output. took a weekend, but now it's hands-off.

1

u/LGAD_ai 2d ago

The part I would plan for early is photo quality, since phone pictures sent through WhatsApp are often tilted, dark or compressed, and that is where most OCR errors come from. Collect twenty or thirty real examples first and run them through your OCR before you build the rest, so you know how much cleanup it needs. I would also store each message ID and skip any you have already handled, so a retry never sends the same email twice. If a document fails the format check, send yourself a short note instead of sending a half-right result to the thread.

1

u/CosackBenjamen 2d ago

at 50 docs a day id rather just have the failed ones bounce back to WhatsApp right away so whoever took the blurry photo can retake it while theyre still holding the paper.

1

u/Substantial_Zone_289 2d ago

that laptop is actually plenty for 20 to 50 images a day yu don't need a heavy local vision model for this. a simple local python script using lightweight open-source ocr and basic text parsing to fill your template will run in seconds on 8gb ram for free. just be careful with the whatsapp step since unofficial web-automation scripts can get your number flagged, and for gmail make sure your script grabs the original message id header so it replies inside the existing thred instead of starting a new one

1

u/Massive-Second-3912 2d ago

before wiring everything together id make a small test set from real docs and check each field against the expected output. track which fields OCR gets wrong and send only those cases for review instead of trusting the whole document. that should show pretty quickly whether local OCR is accurate enough for your docs

1

u/macromind 2d ago

For minimal maintenance, split this into deterministic stages instead of asking one agent to handle everything. Use image cleanup and OCR first, classify the document second, extract into a strict schema third, then validate required fields and confidence thresholds before writing anywhere. Route low-confidence pages to a review queue rather than retrying endlessly. Keep the original image, extracted JSON, model version, and validation errors together for auditing. A small labeled test set covering rotated scans, handwriting, tables, and duplicate pages will reveal more than a broad demo.

1

u/chrysisnetworks 2d ago

At 20 to 50 photos a day, the one I'd worry about is the Gmail reply that went through right before WhatsApp failed. Restart the whole job and now someone has two emails to sort out.

Save the approved text once under the incoming WhatsApp message ID. Give Gmail and WhatsApp their own send status. When only WhatsApp fails, pick up just that leg. And when a send times out and you can't tell whether it went through, check for a receipt before retrying. No receipt and no way to check? Put it in a review queue instead of guessing.

I'd give bad scans the same queue. A template can look perfect with the wrong total in it. Let someone see the original photo next to the extracted fields, fix what's wrong, and approve the text once for both destinations.

We build document handoffs like this at Chrysis Networks. A good first test on that laptop: stop the job after Gmail succeeds and see whether it can finish without creating a second email.

See how we help companies!

1

u/deinerotthaarige 2d ago

make dev might be able to handle the whatsapp to email and back part of this pretty easily

1

u/EggplantStrong1697 1d ago

at 20-50 docs a day id skip running the ocr model on that laptop, 8gb is gonna be painful with anything decent and it'll choke while youre using it. the cheap route that still works: whatsapp cloud api to receive the photos (replies inside the 24 hour window after they message you are free or close to it, check current pricing), n8n self hosted on the laptop for the flow, and for the reading part send the image to a vision model like gemini flash with your template in the prompt and ask for json back. at your volume thats pennies a month and way less pain than tesseract plus a pile of cleanup rules.

then n8n fills the template, replies in the existing gmail thread using the thread id, and sends the result back on whatsapp. the strict template part is usually where it breaks, so check the json fields are all there before it emails and kick anything missing back to a person.

if it really has to be fully local, paddleocr does better than tesseract on phone photos but youll still need something to map the text into your fields

0

u/romit5587 3d ago

20–50 a day is very doable on that laptop. How I'd split it:

  • OCR: Tesseract or PaddleOCR locally. Both run fine on an 8th-gen i5 at that volume. Clean up the image first (grayscale, deskew, contrast) and accuracy goes up a lot.
  • Template: fill it with plain rules (regex or field matching), then validate the result against your format. Only send documents that fail validation to a small local model through Ollama, and if that fails too, put them in a manual review folder. Don't let a model write the final text unchecked if the format is strict.
  • WhatsApp: use the official WhatsApp Business Cloud API with a webhook. Unofficial WhatsApp Web automation is free but fragile, and numbers can get banned.
  • Gmail: the Gmail API can reply inside an existing thread if you set the threadId and the In-Reply-To/References headers.

Run it all as one small Python service with a log line per document. Then when one goes wrong, you can see which step failed.

0

u/KyrelleBuckley 3d ago

The split above is the right one. These are the parts that usually break a setup like this a few weeks in.

The Cloud API needs a public HTTPS webhook. You can get one on a home laptop without opening router ports: ngrok's free plan gives you one fixed domain, or use a Cloudflare Tunnel on a domain you own. Skip the random quick-tunnel URLs, because they change on every restart and Meta keeps posting to the old one.

Answer the webhook with a 200 straight away and do the OCR after. If you're slow, Meta retries the delivery, so save every message ID you've handled and skip repeats. Otherwise one photo can turn into two emails.

Download the image as soon as the webhook lands. The media URL Meta hands you only works for a few minutes, and the download needs your access token. On cost, free-form replies inside the 24 hours after their message are free, and yours always will be, since the bot answers right after the photo comes in.

On Gmail, the Subject has to match the original too, or you get a new thread even with threadId set. And if your Google Cloud OAuth app is still in Testing, the refresh token expires after 7 days and everything quietly stops. Switch it to In production. For your own account you can click past the unverified-app warning.

On Windows, run the script as a service (NSSM is the easy way) or as a Task Scheduler job that starts at boot. Turn off sleep and set active hours so an update restart doesn't land mid-batch. It'll still restart now and then, so have the script look for unfinished jobs when it starts.

0

u/[deleted] 2d ago

[removed] — view removed comment

1

u/Vader20FF 1d ago

Yes, they basically are and they are very similar