See llms.txt for all machine-readable content.

Back to Templates

Deduplicate inbound leads from a webhook with a data table

Created by

Created by: MORSOF || medac
MORSOF

Last update

Last update a day ago

Categories

Share


Quick overview

This workflow receives lead submissions via a webhook, validates and normalizes the data, and stores unique leads in an n8n Data Table using an idempotency key and payload hash to prevent duplicates and detect conflicting replays.

How it works

  1. Receives a POST webhook request containing lead details and an Idempotency-Key header.
  2. Validates required fields (including email format and idempotency key), normalizes the lead fields, and rejects invalid requests with a 400 response.
  3. Hashes the normalized lead payload to create a payload fingerprint for replay detection.
  4. Creates (or reuses) an n8n Data Table named lead_intake_template and looks up an existing row by the idempotency key.
  5. If the idempotency key exists with a different payload hash, returns a 409 conflict response to indicate the key was reused with different data.
  6. If the idempotency key already exists with the same payload hash, returns a 200 response identifying the submission as a duplicate and returns the existing lead ID.
  7. If no match exists, inserts a new lead row with status pending and returns a 202 response with the new lead ID.

Setup

  1. Copy the production webhook URL from the “Receive Lead” trigger and configure your lead source (form, site, or backend) to POST to it.
  2. Ensure the sender includes an Idempotency-Key (or X-Idempotency-Key) header on every submission and provides at least a valid email field in the JSON body.
  3. Update the webhook path (lead-intake-data-table) and Data Table name (lead_intake_template) if they need to match your environment or naming conventions.