AWS Builder Center
How to Prevent Duplicate CRM Contacts with DynamoDB and AWS Lambda

How to Prevent Duplicate CRM Contacts with DynamoDB and AWS Lambda

Prevent duplicate CRM contacts with AWS Lambda and DynamoDB while keeping repeat enquiries, campaign attribution, and contact preferences intact.

Series: CRM (9 articles)

  1. …
  2. 4
    How to Prevent Duplicate CRM Contacts with DynamoDB and AWS Lambda This article
Love to Learn Tech especially AI things.
To prevent duplicate CRM contacts, give each form submission a stable ID, match people using an identifier your business has verified, and reserve that identifier when creating a contact. AWS Lambda can apply the matching policy, and a DynamoDB transaction can create the identity mapping, contact, and enquiry together.
The distinction matters when a prospect comes back. If a website retries the same request after a timeout, the CRM should show one enquiry. If the same prospect submits a new project request three months later, the CRM should show two enquiries under one contact.

Which contact matches should be automatic?

Evidence
Action in this example
Same submission ID and same normalized payload
Return the existing enquiry
Same verified individual email in the same CRM workspace
Link the new enquiry to the existing contact
Same shared inbox, such as  sales@ 
Keep company-level context or send the match for review
Same name and company, with different emails
Suggest a possible match for staff review
Two trusted identifiers point to different contacts
Hold the proposed match for review
An email typed into a public form is a self-reported address. Use a trusted verification or enrollment process before treating it as an automatic identity match. Normalize addresses consistently, such as trimming spaces and normalizing the domain. Handle plus aliases and dots only where you have a defined policy for the relevant provider.

1. Reserve the identity during the first write

Imagine that two distinct enquiries from the same verified address reach Lambda at the same time. Both workers search for the contact and find no match. If they then create contacts independently, each can create a new CRM record.
Create a lookup item keyed by the workspace and approved contact identifier. Then use a DynamoDB transaction for the first write:
Create the identity lookup only if its key is unused
Create the contact with its new contact ID
Create the enquiry only if its submission ID is unused
If another worker has already reserved that identity, read the current mapping and attach the distinct enquiry to the existing contact. If staff can merge or move identity mappings, check that the mapping still points to the same contact when saving the enquiry. If the submission ID already exists, compare the saved inputs before returning the original result.

2. Preserve the information sales needs

Keep the enquiry’s project description, campaign attribution, date, and owner on the enquiry record. Contact-level fields, such as the current verified email and marketing preferences, should follow their own update policy.
A new quote request can be linked to a contact who previously opted out of promotional emails. Their latest enquiry should remain visible to sales while the marketing preference stays in force.
When staff confirm an existing duplicate, keep a record of the merge decision:
  • Which contact survived and which record was merged.
  • Which enquiries, tasks, and opportunities moved.
  • Which contact fields were retained and why.
  • Who reviewed the match and when.
  • Whether the CRM confirmed the merge or still needs reconciliation.

3. Measure whether the rules are working

Start with three counts: duplicate submission retries, distinct enquiries linked to existing contacts, and potential matches sent to review. If retries rise, inspect the form and network handling. If the review queue grows, check whether the team sees repeated shared inboxes, conflicting records from imports, or a missing verified identifier.
Test a timeout retry, simultaneous first-time enquiries, a shared mailbox, and conflicting identifiers. In the final CRM record, sales should be able to open one contact and see each legitimate enquiry with its own campaign and project history.

Series: CRM (9 articles)

  1. …
  2. 4
    How to Prevent Duplicate CRM Contacts with DynamoDB and AWS Lambda This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article