Contact Deduplication
Pull contacts from the CRM (customer relationship management system), detect likely duplicate records, and compile a merge/change list to a file for a human to review and approve.
When to use
- A CRM data-quality sweep is requested or scheduled.
- Import or sync jobs are suspected of creating duplicate contact records.
- Before a bulk email or outreach campaign, to avoid contacting the same person twice.
- A human asks for a duplicate report or cleanup pass on the contacts database.
Tools
http-get: reads contact records from the CRM's REST API.shell-execute: runs a small script to normalize fields and detect duplicate/near-duplicate contacts.write-file: writes the merge/change list artifact for human review.send-message: notifies a human when the report is ready, when an Integration is missing, or when authorization fails.
Playbook
- Confirm scope with the human or task brief: which CRM object (contacts), which fields matter for matching (email, phone, name, company), and any date range or list filter.
- Call the CRM REST API with
http-get(e.g. GET https://api.hubapi.com/crm/v3/objects/contacts) to pull the contact list. Authentication is injected by the org's Integration row for this host — never ask for, echo, or hardcode credentials. If the call returns 401/403 or no Integration row exists, stop and message a human viasend-messageasking them to create the Integration, naming the service and required scopes. - Paginate through all results with repeated
http-getcalls until the full contact set is retrieved. - Use
write-fileto save the raw pulled contact data to a working file (e.g. JSON or CSV) so downstream processing has a stable input. - Use
shell-executeto run a small script that normalizes fields (lowercase emails, strip phone formatting, trim whitespace) and flags likely duplicates by exact email match, exact phone match, or close name+company similarity. - Read the script output and group flagged records into duplicate clusters, deciding a suggested "primary" record per cluster based on completeness or recency.
- Compile the findings into a clear merge/change list: for each cluster, list the record IDs involved, the suggested primary, and the fields that would be merged or overwritten. This system cannot update or delete CRM records directly (no PATCH/PUT/DELETE tool exists) — every change must be routed to a human for manual execution or approval.
- Use
write-fileto save the merge/change list as the final artifact, including a summary count of duplicates found and records affected. - Use
send-messageto notify the requesting human that the deduplication report is ready, where the file is, and that no records were altered — approval and merging is a manual next step.
Failure modes
- 401/403 on the CRM API -> no Integration configured for that host; stop and escalate via
send-messagenaming the service and scopes needed. - Empty result set from the pull -> verify the endpoint, object type, and filter parameters before assuming there are no contacts.
- Rate limit (429) from the CRM -> back off and retry with delay; note the rate limit behavior via
update-memoryif it recurs. - CRM page or API schema has changed and fields are missing/renamed -> fall back to browser-search to confirm current API documentation before retrying.
Done when
- A merge/change list file exists (via
write-file) enumerating every duplicate cluster, the suggested primary record, and the fields to merge. - No CRM records were modified — all proposed changes are queued for human approval.
- The requesting human has been notified via
send-messagethat the report is ready and where to find it.