<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aleksei Mikhailov</title>
    <description>The latest articles on DEV Community by Aleksei Mikhailov (@aleks_ota).</description>
    <link>https://dev.to/aleks_ota</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4264108%2Fcf868d8e-5dd3-4353-941c-cbc8b1facecc.jpg</url>
      <title>DEV Community: Aleksei Mikhailov</title>
      <link>https://dev.to/aleks_ota</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aleks_ota"/>
    <language>en</language>
    <item>
      <title>Duplicate Leads in CRM: Build a Safer n8n Deduplication Workflow</title>
      <dc:creator>Aleksei Mikhailov</dc:creator>
      <pubDate>Thu, 26 Nov 2026 16:58:24 +0000</pubDate>
      <link>https://dev.to/aleks_ota/duplicate-leads-in-crm-build-a-safer-n8n-deduplication-workflow-270p</link>
      <guid>https://dev.to/aleks_ota/duplicate-leads-in-crm-build-a-safer-n8n-deduplication-workflow-270p</guid>
      <description>&lt;h1&gt;
  
  
  Don't let duplicate webhook events become duplicate customers
&lt;/h1&gt;

&lt;p&gt;A buyer submits a form twice. A webhook is delivered again after a timeout. Then the same person emails your team.&lt;/p&gt;

&lt;p&gt;A CRM can end up with three contacts and three separate conversations. But &lt;strong&gt;deleting anything that looks similar is not a solution&lt;/strong&gt;. The same buyer might have a genuinely new opportunity, and two different people can share a name.&lt;/p&gt;

&lt;p&gt;The more reliable approach is to separate three ideas:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;An event&lt;/strong&gt; is an incoming form submission, webhook delivery, or email. Its external ID helps detect replays.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A contact&lt;/strong&gt; is a person or organization, identified by approved, reliable fields.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A deal&lt;/strong&gt; is a commercial opportunity. One contact can have several distinct deals.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You don't want all three concepts collapsed into one deduplication rule.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Make the incoming event idempotent
&lt;/h2&gt;

&lt;p&gt;In an n8n workflow, the first step after receiving a webhook should be to preserve a stable event identifier and source.&lt;/p&gt;

&lt;p&gt;For example, a database with a unique constraint can enforce:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;inbound_events&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;source&lt;/span&gt; &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;external_id&lt;/span&gt; &lt;span class="kt"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;received_at&lt;/span&gt; &lt;span class="kt"&gt;TIMESTAMPTZ&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt; &lt;span class="k"&gt;DEFAULT&lt;/span&gt; &lt;span class="nb"&gt;NOW&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;external_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then an insert can safely distinguish the first delivery from a retry:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;inbound_events&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;external_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="k"&gt;CONFLICT&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;external_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;DO&lt;/span&gt; &lt;span class="k"&gt;NOTHING&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is only the event-level idempotency gate. It does &lt;strong&gt;not&lt;/strong&gt; tell you whether two inquiries belong to the same person.&lt;/p&gt;

&lt;p&gt;Also, a find-before-create check on its own isn't race-safe: two webhooks arriving simultaneously might both see no contact and create one. Use constraints, transactions or controlled locking where your stack requires them.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Match contacts, not just strings
&lt;/h2&gt;

&lt;p&gt;Email and phone can be useful, but matching rules need context:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Normalize phone numbers with country codes.&lt;/li&gt;
&lt;li&gt;Be cautious with shared business inboxes.&lt;/li&gt;
&lt;li&gt;Don't merge contacts based only on names.&lt;/li&gt;
&lt;li&gt;Treat incomplete and conflicting matches as review candidates.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An LLM may help explain why records look related. It should not silently merge customer histories or remove data.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Keep a human review path
&lt;/h2&gt;

&lt;p&gt;A practical n8n flow can look like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Receive the event and persist its external key.&lt;/li&gt;
&lt;li&gt;Ignore or acknowledge previously processed technical retries.&lt;/li&gt;
&lt;li&gt;Search the CRM using approved contact identifiers.&lt;/li&gt;
&lt;li&gt;Link a confident match or create a new contact.&lt;/li&gt;
&lt;li&gt;Route ambiguous matches to a human.&lt;/li&gt;
&lt;li&gt;Create or update the deal using separate business rules.&lt;/li&gt;
&lt;li&gt;Log who made the decision and how errors are recovered.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The key is knowing which steps are deterministic and which steps actually need judgment.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Measure the pilot, not the demo
&lt;/h2&gt;

&lt;p&gt;Use authorized test data and compare against a labeled sample. Track false merges, leads lost, duplicate contacts, manual reviews and processing latency.&lt;/p&gt;

&lt;p&gt;A fast automation that loses inquiries is worse than a slightly slower one with a review step.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Full original guide:&lt;/strong&gt; &lt;a href="https://aib2b.blog/en/blog/crm-duplicate-leads/" rel="noopener noreferrer"&gt;Duplicate Leads in CRM: Prevent Repeats Without Losing Inquiries&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Published originally on AI B2B Blog. This DEV Community version is a technical adaptation; the canonical URL points to the original.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>automation</category>
      <category>n8n</category>
      <category>crm</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
