The challenge
A company running its customer contacts in Zoho Desk had a database of approximately 14,306 contact records that was full of duplicate and incorrect entries, along with fake or incomplete ones. The duplicates had built up over time from three sources.
- Different customers sharing the same phone number
- Different customers with the same name
- Contacts created automatically by the client’s Zoho Voice integration, which places calls and gathers information
The Zoho Voice records caused a specific mess. During that automation the phone number was sometimes saved in the Last Name field instead of the phone field. Desk ended up with contacts whose surname was a phone number, sitting next to the real contact for the same person.
Any fix had to be careful. Two different customers can share a name or a phone number, so matching on one field and merging would create new errors. The automation needed to merge true duplicates and leave everyone else alone.
The size of the backlog was a separate problem. The Zoho Desk API could not retrieve and process the full database directly. Search filters were limited, response sizes were restricted, and output was capped at around 50,000 characters.
What we built
Amatec built a daily deduplication automation for Zoho Desk using Deluge scripts and the Zoho Desk API, with every merge and skip logged to Zoho Sheet and analysed in Zoho Analytics. Before it could run, we cleared the existing backlog in a one-off pass.
The daily run uses two separate scripts, each working on contacts created the previous day:
- Name check. For each new contact, the script finds existing contacts with the same name and compares email, phone, mobile, first name and last name. If every relevant field matches, the records merge. If any key field differs, for example same name but different email, the pair is skipped.
- Phone check. The script finds contacts with the same phone number and compares full name, email and mobile. Matching records merge. Conflicts, such as same phone but different mobile, are skipped.
The Zoho Voice problem got its own rule. When a phone number appears in the Last Name field, the script recognises it and merges that record into the real contact, logging the reason as phone number as a name.
Merges go through the Zoho Desk merge API. The script picks a master contact, merges the duplicate into it, and copies across anything the master is missing: email, mobile, phone, secondary email, work phone and address fields.
Every action is written to Zoho Sheet with the date, first and last name, master contact ID, child contact ID, merged or skipped, and the reason. Each run removes repeated log lines and keeps a row counter in a second sheet, so new entries land below the previous day’s. The log then feeds Zoho Analytics.
The one-off backlog clean worked around the API limits:
- All contacts were exported from Zoho Desk to an Excel file.
- Zoho Sheet identified the duplicates, which were isolated across two sheets without deleting anything.
- ChatGPT generated an array of duplicate contact IDs and handled approximately 60% of the duplicate data.
- The remaining 40% was processed manually, checking each potential duplicate in Zoho Desk by name, phone number and email.
- The verified array was handed to the merge script.
The most stubborn bug was a small one. The Zoho Desk API returns many empty fields as null, but inside Deluge they arrive as an empty string. Logic that checked for null made the merge fail, and tracking that down took significant debugging. The scripts now treat every missing field as an empty string.
The results
The client’s Zoho Desk contact database of approximately 14,306 records was cleaned, and a daily automation now detects and resolves new duplicate contacts.
- Approximately 14,306 contact records cleaned in the initial pass
- ChatGPT processed approximately 60% of the duplicate data, with the remaining 40% verified and processed manually
- Duplicate detection by name and by phone runs every day
- Every merge and skip logged in Zoho Sheet with its reason
The skip rules matter as much as the merges. Because a merge only happens when the key fields agree, the automation prevents incorrect merges, and two customers who happen to share a name or a number stay separate.
The log gives the client transparency. Anyone can open the sheet and see why a contact was merged or left alone, and the same data sits in Zoho Analytics for review. That record is what keeps the database clean over the long term, instead of a one-time tidy that drifts back.