If your onboarding flow involves someone reading a scanned ID and retyping the name, ID number, and address into a CRM, you have a data-entry bottleneck disguised as a compliance step. It's slow, it's error-prone on long numeric fields, and it doesn't scale past a handful of documents a day.
This is the architecture we use to replace that with an automated pipeline: upload a scan, get structured, validated fields back in under 30 seconds.
The pipeline
Four stages, each doing one job well:
- Ingest — a watched folder or upload endpoint receives the scanned PDF/image.
- OCR — the raw image is sent to an OCR service (we use Parsio) that returns plain text plus rough field positions.
- Extraction — the raw OCR text is messy: inconsistent spacing, line breaks in the wrong place, occasional character misreads. A combination of regex patterns and an AI extraction pass turns that mess into named fields (name, ID number, date of birth, expiry date).
- Validation & write — numeric ID fields get checksum-validated where the country's ID format supports it, dates are normalized, and the clean record is pushed into the CRM via API.
Why regex alone isn't enough
OCR output is not clean text. A national ID number might come back with a stray space in the middle, or a similar-looking character substituted (0/O, 1/I). Regex is good at finding the general shape of a field — the ID line usually still has a consistent length and character class — but you need a validation step behind it, not just a match.
For fields with a checksum digit (many national ID formats have one), always validate the checksum before accepting the extraction. It catches the OCR misreads that regex alone would silently accept.
What this actually saves
The honest way to size this: measure your current per-document manual entry time (ours was 3-5 minutes per document, mostly on the numeric fields), multiply by monthly volume, and compare to OCR service cost. For most B2B onboarding flows processing 50+ documents a month, the pipeline pays for itself inside the first month — the win compounds every month after that.