02IntegrationsType: Reference architecture
Every record accounted for: migrating into a live CRM with an AI agent under rules
A reference design for loading a live Zoho CRM with no sandbox: an AI agent does much of the hands-on work, and written rules limit what it touches.
Shows
- Applied AI
- Data Migration
- Business Automation
Where this comes from: Drawn from systems I've designed on Zoho. The business, names and data here are generalized. The patterns and failure modes come from real work, and the design includes what that work taught me.
On This Page
In 30 Seconds
A company moves customers, contacts and products from ERP exports into a live Zoho CRM with no sandbox. An AI agent (Claude Code) profiles the source, builds the files, checks them against the live configuration and reconciles the result. Written rules bound it: read-only by default, a backup before any write, a pilot before the full load, and a person for anything irreversible. Records land on the key the ERP sync will use, so the sync takes over without re-matching.
What It Guarantees
- Nothing is written before a backup exists.
- Every row is checked against the live CRM configuration, layouts included.
- Every record is reconciled by key: count, identity and values.
- The agent reads production freely and changes it only in approved steps.
- A repair changes only the wrong records, and proves it.
The Problem
A common setup: a company has run sales from spreadsheets and an ERP, and is moving to Zoho CRM. The CRM is already live, with users, test records, workflows and an assignment rule that emails each new owner. There is no sandbox, and the source holds more than twenty thousand records.
Both sides have traps. Different customers legitimately share an email or a mobile number. Some codes hide look-alike characters, and some numbers are stored as text. In the CRM, some picklist labels differ from the values they store. Some fields are required only on a layout. In my tests, some settings calls answered "success" and changed nothing. It may have changed since.
An ERP sync starts right after and must find every imported record. By hand, the work is slow and hard to repeat exactly. An agent with full access puts a live CRM at risk.
The Approach, in One Sentence
An AI agent works from a written runbook, and nothing reaches the live CRM until a backup, a live preflight and a pilot have passed, all keyed on the ids the sync will use.
Architecture
Connections in this diagram
- Profile the source → Map to live CRM
- Map to live CRM → Backup first
- Backup first → Fix config, preflight
- Fix config, preflight → Pilot batch (zero errors)
- Pilot batch → Pilot reads back right?
- Pilot reads back right? → Full load (yes)
- Full load → Reconcile by key
- Reconcile by key ↔ Targeted repair (mismatch)
- Reconcile by key → Sync takes over (all match)
Key Decisions
Key every record on the ERP's internal id, the one the sync upserts on
The alternatives were email or phone, a legacy code, or matching later. Customers legitimately share emails and mobiles. A legacy code works for the import but leaves the sync to re-match everything. With the ERP id in a unique CRM field, the sync finds each record on its first run, and a correction pass is an update, not a duplicate.
Validate against the live CRM, not the documentation
The alternatives were the import tool's own checks, or field definitions alone. A picklist label can differ from the value it stores, and writes, filters and automations all use the stored value. A field can be required on a layout while the fields API calls it optional. A first load once skipped rows for exactly this.
A pilot of hand-picked edge cases, never skipped
The alternatives were going straight to the full load, or a random sample. Static checks can't see what automations, derived fields and the importer actually do. The pilot is about twenty records, each picked for a reason: an existing record to update, a normalized code, the longest name, the highest price. When the input changes, the pilot runs again.
Read-only by default; anything irreversible goes to a person
The alternatives were full access for speed, or every step by hand. Without a sandbox, every write is a production write. The agent analyzes with a read-only credential and writes only in steps I've approved, each after a backup.
When Things Go Wrong
A picklist label doesn't match its stored value
The preflight compares every value with the stored values. I fix mismatches while the modules are nearly empty and the fix is small.
A value disappears in transformation
A price with a thousands separator can become a blank without an error. The parser fails loudly, and reconciliation compares values, not only keys. A key-only check once passed with prices missing.
An automation fires during the load
Workflows and assignment rules are off, and owners are set explicitly, so no rule emails a new owner per record.
A repair is needed
A snapshot comes first. Only the wrong records change, by id, with values taken again from the source and automations off. A full re-fetch proves nothing else changed. Unexplained differences wait for a person.
The agent reads the wrong org
An AI tool's connector or a saved login can quietly point at a demo org. Every analysis names the org it read, and the read-only client refuses any other.
What the Business Gets
- Clean picklists and fields from the first record, so reports and assignment work on day one.
- The ERP sync starts without a matching project.
- Later corrections are routine keyed updates, never a delete-and-reload.
- Every data decision, rejection and repair has a written reason.
For Engineers
Runbook. Backup (metadata, picklists, automation rules, translations, records) → configuration fixes → files rebuilt by script → preflight → pilot → load in dependency order (products, then accounts, then contacts) → reconcile → repair. Each step writes a report that the next one reads.
Preflight. Encoding and line endings. A unique, non-empty key. System-required and layout-required fields. Picklist values against the stored values in use. Types. Lengths. Stray whitespace, control characters and look-alike characters. Any error stops the run.
Keys, routing, status. The ERP id sits in a unique field that every upsert names as its match field. Otherwise, Zoho's documentation says, its upsert checks system duplicate-check fields, such as an account's name, first. The migration and the sync share the routing rule (a source customer with a tax id becomes an account; one without becomes a contact) and the sync-status values.
Read-only client. GET requests and COQL SELECT queries only, to the API base only. COQL goes out as a POST, so the guard checks the query, not just the method. It refuses another org's token, never prints tokens, and stops rather than fall back to a write-capable one.
reconcile(module, source, fields):
src = index(source, by=key)
crm = index(fetch_all(module, fields + [key]), by=key)
missing = src.keys - crm.keys
extra = crm.keys - src.keys - known_existing
dupes = keys seen more than once in crm
drift = {k in both where any(norm(src[k][f]) != norm(crm[k][f]) for f in fields)}
pass only if all four are empty
How I Build Systems Like This
I write the runbook and the rules before the agent starts: the order of steps, what it may read and write, and what needs me. The agent (Claude Code) does the profiling, scripts, checks and reports. I make the scope and data decisions, each written down with its reason. The method comes from a migration of more than twenty thousand records into a live Zoho CRM.