AI CRM Data Normalization with Pydantic Schema Validation at Ingestion

Garbage in, garbage in your CRM forever. Normalize on the way in and stamp audit metadata so downstream systems can trust the record.

November 26, 2026

Related templates: Data Enrichment

Every CRM rots the same way. Free-text imports, chat transcripts, and web forms dump "USA," "U.S.A.," "United States," and "us" into country fields. Six months later, marketing runs a regional campaign, excludes half the Americas, and nobody can explain why.

Cleanup projects lose to the next quarter. Normalization at write-time is the most durable fix, and AI parsers without validators just speed up writing garbage into Salesforce.

This article covers ingestion pipelines that parse messy input, normalize CRM fields, and validate before saving. It maps to the Data Enrichment playbook. For meeting notes that need review, see meeting notes that actually pass review. For outbound that depends on clean firmographics, see SDR outbound without invented pricing.


Ingestion Chaos in the Wild

Consider a Series B fintech that pastes LinkedIn exports into HubSpot. Titles vary, "VP Eng," "Vice President Engineering," "vp engineering." Phone numbers mix E.164, local formats, and junk strings. Enrichment vendors disagree on company size bands.

Downstream effects compound:

  • SDR sequences misfired on title filters.
  • Dialers skipped valid numbers stored in non-dialable shapes.
  • Attribution reports split one account into three company name variants.

Quarterly scrubs fixed last month's mess while this week's web form recreated it. RevOps heroics do not scale. The write path needs a gate.


Why Enrichment-Only Is Not Enough

Many teams bolt on an enrichment vendor and assume clean data arrives. Vendors infer. They conflict. They stale-date. They return confidence scores marketing never sees.

AI extraction makes the problem faster, not smaller. A model can turn a messy chat log into structured fields in seconds. It can also map "Head of Biz Ops" to an enum that does not exist in your picklist. A loose import script may silently coerce that value.

Validation belongs between parse and persist. Design your write path so only output that passed validation reaches the CRM. The playbook returns validated JSON; your application performs the save.

The same contract discipline applies to API integrations, see legacy APIs were not built for chat for outbound JSON. CRM ingest is inbound untrusted data with the same mindset.


Write-Time Pipeline: Parse, Normalize, Validate

The Data Enrichment playbook runs three agents in sequence: extraction, CRM normalization, and audit wrapping. It does not include an enrichment-vendor lookup, a duplicate-merge step, or a stewardship queue.

Step one, parse raw input. Extract field candidates from messy text, forms, chat logs, or call transcripts into structured JSON. The data_extraction_strict template blocks output that is not valid JSON. It requires non-empty top-level id and name strings, checks that id is UUID-shaped, and blocks the literal words unknown and TBD and the text N/A.

Step two, normalize contact fields. The crm_field_normalization_agent template requires non-empty email, phone, postal_code, and country strings. It also blocks duplicate JSON keys, a Markdown-fenced wrapper, and the placeholders TBD, N/A, unknown, null, and TODO. Three format rules follow:

  • Email must match a simple name@host.tld shape. This is not a deliverability or full RFC 5322 check, and a failure blocks.
  • Country must be a two-letter code from a built-in list of 18 countries (US, GB, DE, FR, PL, CH, AT, BE, NL, ES, IT, CA, AU, JP, CN, IN, BR, MX), compared case-insensitively. A valid code outside that list, such as IE or SE, fails and blocks.
  • Phone and postal code are warnings. Phone must look like E.164 (a plus sign, then 7 to 15 digits). Postal code is checked against the US pattern, so international postal codes produce a warning.

A warning is recorded but does not stop the run. Add your own title enums and international postal-code rules where needed.

Step three, add audit metadata. The audit_trail_fields_agent template requires model_id, rules_version, timestamp, and payload, with payload as an object. It checks that rules_version is a semantic version and that the timestamp value starts with a YYYY-MM-DDT date-time prefix. It also enforces a 60-character minimum on the whole output and blocks TBD and unknown model. The step wraps the payload; it does not decide what is correct inside it.

All three steps route forward with an unconditional edge, and there is no reject branch. A failing rule with on_fail: block ends the run with a blocked status. The "Enriched output" terminal is reached only when no step blocks. Route blocked or incomplete results to stewardship in your application rather than assuming the graph creates that queue.

CRM data enrichment flow: extract contact fields, validate configured formats, and add audit metadata before application-side CRM handling
.

The validate LLM output tutorial walks through wiring enum_validator and required_fields on an extraction agent. The reask loops tutorial covers bounded retries when a configured validation failure is safe to repair.


What the Playbook Rejects, and What You Add

The shipped templates reject output that fails the configured rules above. They do not know your ICP, title picklist, or segment rules. These are checks you add as custom rules or in application code:

  • Records missing required fields for your ICP, such as no company domain on enterprise segment leads.
  • Enum values outside allowed sets, with no silent "closest match" unless policy documents fuzzy mapping with audit.
  • Mutually inconsistent data, such as a personal email on a record tagged enterprise, or country US with a mismatched phone country code.
  • Injection attempts in chat ingest, where instructions embedded in web form fields try to override parser behavior. Treat untrusted text as prompt injection surface area.

Failed rows should go to a stewardship queue with the partial parse attached. Fix upstream causes such as form labels, import scripts, and parser version, not quarterly scrubs.


Canonical Field Design

Normalization only works if canonicals are documented and small:

  • Country → ISO 3166-1 alpha-2. The shipped country rule accepts only its 18-country built-in list, so extend it if you sell beyond that set.
  • Title → internal enum (IC, Manager, Director, VP, C-level) with an explicit fallback such as other. Avoid the literal unknown, which the shipped templates block.
  • Phone → E.164. The shipped template requires a non-empty phone, so a contact with no phone is blocked. Keep raw junk in provenance, not in the canonical column.
  • Company size → fixed bands aligned to MAP and CRM picklists.

Publish the enum list to sales and marketing. Mystery values return to the reject queue, not silent coercion.

When LinkedIn says "Head of Product" and the form says "PM," store both values in provenance-linked fields. Choose the canonical value by documented precedence. For example, the form may win for title while enrichment wins for company size. Record which source won in your own audit fields.


Audit Metadata Downstream Systems Expect

The shipped audit wrapper requires model_id, rules_version, timestamp, and payload. The first three describe the run. The fourth carries the normalized record. Fields such as these are not in the template, so add them inside payload or your own schema if you want them:

  • source_system, such as web form, chat, or import batch ID.
  • confidence, model or vendor score where available.
  • validation_result, pass or rule-level failures on reject.

The required rules_version tells you which rule set ran. That helps RevOps filter low-confidence leads before SDR assignment, and it lets re-normalization jobs find records processed under legacy rules. Compliance can also use these fields to answer "who changed this phone number?", though ValGuard does not replace your own change log.

Marketing automation handoff: normalized country and title enums must match your MAP picklists exactly. Misaligned enums cause silent segment drops. Export canonical values to marketing ops when taxonomy changes.


Handling Conflicting Sources

Conflicts are normal. Policy beats hope.

Document precedence tables:

FieldPrimary sourceFallback
TitleWeb formLinkedIn export
Company sizeEnrichment vendorForm self-report
PhoneClick-to-call verifiedForm entry

When sources disagree beyond tolerance, reject to stewardship rather than pick randomly. Random resolution destroys forecast trust.

For strict JSON repair before enum checks on noisy extracts, when JSON must be exact details parse-then-validate patterns that prevent silent field drop.


Re-Normalization When Taxonomy Changes

When title taxonomy adds a "Principal" bucket split from "Director," batch re-run normalization on records tagged with an old rules_version. Do not one-off SQL update titles without provenance, you will break attribution forensics and compliance audits.

Re-normalization jobs should:

  • Read raw provenance fields where stored.
  • Write the new canonical value with an updated rules_version.
  • Log diff summaries for RevOps review before MAP sync.

Stewardship, Not Heroics

Assign owners to the reject queue weekly. Track reject rate by source. A spike in web form junk usually means marketing changed a field label, not that AI broke.

Stewardship KPIs:

  • Reject rate by source system.
  • Mean time to clear rejects.
  • Duplicate rate post-normalization.
  • SDR bounce rate on normalized phone fields.

A rising reject queue from one landing page is a form design ticket, not a model tuning session.


Integration Points

These integration points live in your application, not in the playbook graph.

Ingest triggers: form submit, chat end, call transcript webhook, scheduled import batches.

CRM write API: upsert only on validation pass; never merge partial objects.

Enrichment vendor: the playbook has no vendor step. If you add one, call it after parse and before final validation, merge with precedence, and reject if the vendor conflicts with hard rules.

MAP sync: export canonical enums on taxonomy change; block sync job if drift detected between CRM and MAP picklists.

Pair operational metrics with validator false-positive monitoring when tightening enum rules, stewardship queues should not drown in good leads.


Common Mistakes

MistakeSymptomFix
Save raw model JSON to CRMPicklist corruptionValidate before upsert
Silent closest enum matchMystery segmentsReject or flag explicit fuzzy map
No rules_version trackingCannot re-normalize safelyStore the audit wrapper's rules_version with each record
Quarterly scrub onlyRot returns next weekWrite-time gate
Enrichment as sole sourceStale firmographics in outboundPrecedence + freshness rules

Testing the Ingest Gate

  • Fixture imports: messy CSV rows; assert canonical output or a named rule failure.
  • Cross-field chaos: enterprise tag plus gmail.com; assert reject. This needs a custom rule you add.
  • Enum boundary: titles one token off the allowed set; assert the stewardship route in your application.
  • Vendor conflict: enrichment disagrees with form; assert precedence or reject per policy.

Run gates in CI on parser prompt or schema changes with the test policy before production tutorial. Save live vendor calls for weekly smoke tests.

Start new enum rules in shadow mode if tightening an existing taxonomy. Log what would have rejected on last month's imports before cutting ingest paths that production dashboards depend on. See shadow mode rollout.


Latency and Throughput

The template benchmark snapshot reports validator-pack time only. At p50, data_extraction_strict (5 rules) takes 1.463 µs, crm_field_normalization_agent (10 rules) takes 2.375 µs, and audit_trail_fields_agent (9 rules) takes 3.624 µs. These exclude network calls and model inference.

The proxy request p50 is a separate end-to-end measurement of 0.57 ms with a zero-latency mocked upstream. It does not include CRM normalization, enrichment APIs, or model inference. See the latency methodology.

Batch imports can parallelize validation; real-time forms should fail closed to a "we'll confirm your details" path rather than save garbage under load.


Summary

Clean CRM data is a write-time discipline, not a quarterly project. Parse messy input into structured candidates. Normalize to documented canonicals. Validate before save. Route rejects to stewardship with provenance intact.

Deploy the Data Enrichment playbook from playbook templates or fork from the marketplace. Spend RevOps time on taxonomy and precedence rules, not on explaining why "United States" and "US" still do not segment the same campaign.

Book a technical walkthrough with our team → Start free in shadow mode →

Related articles