Catch duplicate leads and missing fields with an n8n Salesforce agent
This agent checks new and changed leads for duplicates, including the same company spelled differently, and cleans them up with narrow, careful steps. The CRM stays tidy without someone hunting duplicates by hand.
Paste this into ChatGPT, Claude or your agent tool. See the prompt
- Pipeline Hygiene / CRM
- intermediate
- RevOps
- Category
- Pipeline Hygiene / CRM
- Difficulty
- Intermediate
- Est. cost
- Not stated by source
Works with
Problem
Flow rules cannot read free text or spot that two leads are the same company spelled differently. Someone has to notice and fix those records by hand.
Setup
A Salesforce Trigger node in n8n polls for new or changed leads and hands each to an AI Agent node. The agent has one narrow Salesforce tool per action (search, get, update) and searches by company domain before creating anything. Every create or update passes through a Slack approval step; searches run without approval.
Prompt
Starter prompt by The GTM Agent Weekly, written from the setup described on this page. It is not the source's own prompt; see the source link below for their write-up.
# ROLE
You check each new or changed lead for duplicates and missing fields before anything new is
created in the CRM. Any change you want to make needs human approval.
# TOOLS
- search(query): find leads, contacts and accounts. Runs without approval.
- get(id): read a record. Runs without approval.
- update(id, fields): change a record. Needs approval.
# INPUTS
- {{LEAD}}: the new or changed lead. {{REQUIRED_FIELDS}}: fields every lead must have.
# TASK
1. Search by company email domain first, then by exact email, then by company name.
2. If a likely duplicate exists, propose a merge or link, showing both records side by side
and the fields that match.
3. If required fields are missing, propose values only where another record or the lead's
own data supports them; otherwise list them as "needs rep input".
4. Send every proposed change to {{APPROVAL_CHANNEL}} with approve and reject.
# OUTPUT
"Duplicate: yes or no", matching records with links, proposed changes, missing fields.
# GUARDRAILS
- Never create or update without approval. Never delete.
- Never treat a personal email domain (gmail and similar) as a company match.
- One narrow action per tool call; log every proposal and decision. Replace every {{PLACEHOLDER}} before running. Works with any capable LLM and runner.
Tools
Steps
- Start in a sandbox or on one object no other team depends on.
- Add Salesforce nodes as separate tools for search, get and update instead of one broad tool.
- Have the agent search leads and contacts by domain before creating or updating anything.
- Leave fields blank when the source text does not support a value.
- Gate writes behind Slack approval and loosen only the lowest-risk writes after weeks of correct results.
Results
Tutorial with no outcome data.
What goes wrong
Gotchas
- Every call counts against the org's daily API limit; search, get and update per record can triple usage.
- An agent that invents a plausible value is worse than one that leaves the field blank.
- Salesforce feeds reporting and compensation, so unreviewed writes can break other teams' numbers.
Get 5 like this every week, free.
Real agent setups with sources and failure modes, in one short weekly email.
Free. One email a week. Unsubscribe anytime.
Source and credit
Muhammad Qasim Hammad, The Agent Ecosystem · newsletter
Source dated 2026-08-06 · last reviewed 2026-10-11. Summarized in our own words; see the source for details.