I built this workflow to prevent duplicate lead submissions before they reach a CRM.
It receives lead data through a webhook, validates and normalizes the fields, then uses an idempotency key and payload hash to decide whether the submission is new, an exact duplicate, or a conflicting
replay.
The workflow handles four outcomes:
A valid new lead is stored in an n8n Data Table.
An exact duplicate returns the existing lead ID without creating another row.
The same idempotency key with different data is rejected as a conflict.
Missing or invalid information is rejected before storage.
I tested all four paths successfully. The template uses only built-in n8n nodes and does not require external credentials.
Official n8n template:
Source and documentation:
The Data Table version is intended for demonstrations, prototypes, and low-concurrency intake. For production systems that require atomic uniqueness under high concurrency, I would use PostgreSQL or
another database with a unique constraint on the idempotency key.
@Medac Actually clean work just you need to considered one thing about the idempotency key, it dedupe requests not people for example if the same lead submitting twice from different sessions generates two different keys that means there’s two rows, no conflict raised. That’s why is better to add a second softer check like normalized email lookup so that returns the existing lead or flags for review instead of silently creating a near duplicate
And two small notes (or maybe a tricks). Hash only stable business field after normalization a timestamp or user agent anywhere in the payload breaks exact duplicate detection forever. And give keys a TTL (Stripe uses 24h) so table doesn’t grow unbounded (Legitimate retries almost never arrive after that window)
Thanks Walid, good catch This version handles request-level idempotency, not full lead dedup. So if the same lead is submitted with a different idempotency key, it can still create a new row.
For the next version, I ll add a second layer of duplicate detection using normalized email and phone when available, with name and company as additional signals. Since this still can’t guarantee that two submissions are the same person, uncertain matches will be flagged for review instead of merged automatically.
The payload hash already uses only normalized business fields: name, email, company, message, and source. Timestamps, user agents, and other request metadata are excluded.
I also agree on expiring idempotency keys. I’ll keep their retention separate from the lead records, so old retry keys can be cleaned up without affecting the leads.
Thanks for the detailed feedback, definitely useful for the next iteration
This is a really solid approach, especially separating validation from deduplication. Using both an idempotency key and payload hash makes the conflict case much easier to handle than simply checking whether an email already exists.
I also like that you’re returning the existing lead ID for exact duplicates instead of silently creating another record. That makes the workflow much safer for webhook retries and repeated submissions.
The Data Table approach seems practical for prototypes and lower-volume workflows, while moving the uniqueness check to a database with proper constraints would make sense as concurrency increases. Overall, a clean and useful pattern for lead intake automation.