Case study
AI agents & CRM systems architecture

Bringing intelligence to a live CRM, with people in control.

An AI data agent that audits a live CRM, finds what's broken, and queues every fix for a person to approve, edit or deny.
CRM Agent hero screen
The CRM Agent keeps a building-services company's sales data clean. It reads the whole CRM, finds duplicates and broken records, and proposes each fix. Nothing changes until a person approves it, and every approved change can be undone.
0
writes
Made on its own.
Writes the agent can make to the CRM without a person.
4
kinds
Kinds of write.
So new checks need no new code.
388
contacts
Candidate duplicates.
Found in the first backlog.
86
operations
Run on the live CRM.
All approved, none failed.

How we built it.

Four pieces that let the agent audit a live CRM while people stay in charge of every change.

It reads everything.And writes nothing.

The agent has read-only access to the CRM. It audits contacts, buildings, deals and quotes for duplicates, missing fields and broken relationships, and backs every finding with record IDs and evidence.
✓ Facts, inferences and unknowns kept apart
✓ Every finding carries a confidence level
✓ The same finding never queues twice
CRM Agent audit screen
CRM Agent proposal screen

Every finding arrives.As a proposal.

A recommendation pairs the reason and its evidence with an ordered list of steps. The reviewer sees exactly what would change, adjusts any proposed value, then approves, denies or cancels it.
✓ Four steps: update, create, merge, delete
✓ Reviewers edit the values, never the plan
✓ Merges and deletes must be typed to confirm

A new check starts.As a sentence.

Business rules live with the agent, not in the app. Teach it a rule or correct a mistake in plain language and it updates its own skill. If the fix fits the four existing steps, nobody touches the code.
✓ Corrections stick between runs
✓ No business rules hard-coded in the app
✓ New checks ship without a release
CRM Agent rules screen
CRM Agent history screen

Every change.Leaves a trail.

Each step's result is saved as it runs, along with a snapshot of what it replaced. The history shows what was proposed, what the reviewer changed, what ran, and what the record held before.
✓ Progress saved after every CRM write
✓ Merges verified against the CRM afterwards
✓ Undo runs last step first

How it works.

The architecture and safeguards that keep every write checked, reversible and on the record.

The agent decides what.
The app decides how it runs safely.

The agent runs on its own server and can only submit recommendations. The dashboard only reads rows and passes on the reviewer's decision. One Edge Function holds the path to the CRM, and it re-checks every rule the dashboard shows, so no client can skip them.
Agent · own serverSupabaseBrowserCRMread-only accessproposesstatus · snapshotsreads rowsapprove · undoevery writeData agentfinds issues, sends fixesIntake functionvalidates shape, de-duplicatesPostgresrecommendations, historyEdge Functionrules, run, verify, undoReview dashboardthe human in the loopCustom CRMthe live recordsComposio proxyauthenticated API callsChanges data or passes a decisionRead only
Safeguards

Six checks.
Before the first write.

Approve is a request, not a write. If any check fails, the CRM stays untouched and the reason appears on the recommendation.
01
Reviewer
Must be on the approved reviewer list
02
Edits
Only values may change, never steps or records
03
Merge choices
Owner picked and any data loss accepted
04
Freshness
Every record re-read; changed values stop the run
05
Writable fields
Fields the CRM won't accept are caught up front
06
Single run
A guarded status change lets only one request run it

A merge can't lose data.
Not quietly.

One person can hold several buildings, roles, notes and deals across duplicate records. Before a merge, the system lists every distinct value nothing else would keep. Approval is blocked until the reviewer accepts that loss, and the acceptance is stored with the run.
Marcus Bell
3 records · linked to 12 King St W and 40 Bay St
Field
Record 1
Record 2
Record 3
Email
marcus@ledgerline.io
mbell@ledgerline.io
—
Title
Head of Finance Ops
Finance Manager
Head of Finance Ops
Owner
Reuben K.
Jordan K.
Reuben K.
Not kept anywhere: Finance Manager, mbell@ledgerline.io
Accept this loss to approve.
Approve
26
records
Duplicates removed.
From the live CRM so far.
7
approvals
Losses signed off.
Where a reviewer accepted a listed loss.
2
roles
Building roles re-pointed.
Primary and billing contact, verified after each merge.

Runs that outlast.
The request that started them.

A large merge can take longer than one server request allows. So each call starts new steps only in its first minute, saves its place and returns. The dashboard calls again until the row finishes, and a Continue button picks the run back up if the tab was closed.
150s
limit
Per server request.
The hard limit on a single call.
60s
window
To start new steps.
After that, a call saves its place and returns.
7 min
idle
Marks a run stopped.
When nothing has been saved in that time.
0
retries
Of an uncertain step.
Nothing reruns automatically if its result is unclear.
Undo

A new write.
Not a rewind.

Each step is reversed from its saved snapshot, last step first. If someone has changed a record since, undo leaves their work alone.
Update
Old value restored if the field is unchanged since
Create
New record deleted if nobody has edited it
Merge
Records recreated and building links pointed back
Delete
Record recreated from its snapshot
The limit
Notes and deals stay where a merge put them, and the reviewer is told before confirming
Principles

Four decisions that hold it together.

01
The agent never gets write access
A bad inference costs one denied recommendation, not a damaged record.
02
Four writes, any number of checks
New checks need no code. Only a new kind of CRM write does.
03
Every rule is enforced on the server
The dashboard and the Edge Function share one module, so a rule can't drift.
04
The original proposal is never edited
A reviewer's version is saved beside it, so both stay on record.

Let's find your
next win.

In one call, we'll map where AI fits in your work, what it would take to build and what it's worth to your team.