CRM
Validate phone numbers and emails in Zoho CRM
Check the email and phone of each new Zoho CRM lead or contact with a workflow rule and a Deluge function that calls the API and updates the record.
Updated 2026-11-26
This recipe checks the email and phone number of each new lead in Zoho CRM and writes the answer back to the lead, so bad addresses never reach a campaign and reps call numbers in a format their dialer understands. There is no native Qelka extension for Zoho CRM: a workflow rule runs a Deluge function, the function calls the API with invokeurl and updates the record with zoho.crm.updateRecord. The same function works for contacts with one word changed.
What you need
- A Zoho CRM organization with workflow rules and custom functions, and a user with the Manage Automation and Manage Extensibility permissions. Zoho's own function recipes list Enterprise edition and above, as far as we know: check yours, and try it in a sandbox first if you have one.
- A Qelka API key. Because it sits in a Zoho connection, use a restricted key limited to
emailandphone. Ask_test_key returns simulated results and never spends credits: see Test mode. - Three custom fields on Leads, all single line:
Email Status,Email SuggestionandPhone E164. Their API names, shown in the module's field settings, should beEmail_Status,Email_SuggestionandPhone_E164; if Zoho gave them other names, use those in the code.
Steps
1. Store the key in a connection
In Setup, open Connections (under Developer Hub, or Developer Space in newer menus) and create a connection to a custom service:
- Authentication type: API Key.
- Param type: Header. Parameter name:
Authorization. - Connection name:
validation_api.
When you connect, enter Bearer followed by your key as the value of the Authorization parameter. Zoho stores it and adds the header to every invokeurl call that names the connection. Zoho's connection screens change between versions, so follow its current Connections documentation if a label differs; the goal is that the key lives in the connection and never in the function.
2. Create the workflow rule
Go to Setup, Workflow Rules, and create a rule on the Leads module:
- Execute the rule on a record action: Create.
- Condition: Email is not empty, or Phone is not empty.
- Under Instant Actions, choose Function, then write your own.
- In the Deluge editor, click Edit Arguments, add an argument named
leadIdand map it to Leads, Lead Id.
3. The function
Paste this body into the editor:
defaultCountry = "US";
leadRecord = zoho.crm.getRecordById("Leads", leadId.toLong());
email = ifnull(leadRecord.get("Email"), "");
phone = ifnull(leadRecord.get("Phone"), "");
alreadyChecked = ifnull(leadRecord.get("Email_Status"), "") != "";
updates = Map();
if (!alreadyChecked && email != "")
{
emailStatus = "unchecked";
requestBody = Map();
requestBody.put("email", email);
requestBody.put("mode", "fast");
try
{
response = invokeurl
[
url: "https://api.qelka.com/v1/email"
type: POST
body: requestBody.toString()
headers: {"Content-Type": "application/json"}
connection: "validation_api"
detailed: true
];
if (response.get("responseCode") == 200)
{
result = response.get("responseText").toString().toMap();
emailStatus = result.get("status");
updates.put("Email_Suggestion", ifnull(result.get("did_you_mean"), ""));
}
else
{
info "email check skipped: HTTP " + response.get("responseCode") + " " + response.get("responseText") + " request " + response.get("responseHeader").get("x-request-id");
}
}
catch (error)
{
info "email check skipped: " + error;
}
updates.put("Email_Status", emailStatus);
}
if (!alreadyChecked && phone != "")
{
phoneValue = "unchecked";
requestBody = Map();
requestBody.put("phone", phone);
if (defaultCountry != "")
{
requestBody.put("country", defaultCountry);
}
try
{
response = invokeurl
[
url: "https://api.qelka.com/v1/phone"
type: POST
body: requestBody.toString()
headers: {"Content-Type": "application/json"}
connection: "validation_api"
detailed: true
];
if (response.get("responseCode") == 200)
{
result = response.get("responseText").toString().toMap();
if (result.get("status") == "valid")
{
phoneValue = result.get("e164");
}
else
{
phoneValue = result.get("status");
}
}
else
{
info "phone check skipped: HTTP " + response.get("responseCode") + " " + response.get("responseText") + " request " + response.get("responseHeader").get("x-request-id");
}
}
catch (error)
{
info "phone check skipped: " + error;
}
updates.put("Phone_E164", phoneValue);
}
if (updates.size() > 0)
{
saved = zoho.crm.updateRecord("Leads", leadId.toLong(), updates);
info saved;
}
Older editors expose arguments as input.leadId: if yours does, use that name. Set defaultCountry to the two-letter code of most of your leads, so a number typed without + can be read, or to "" to send numbers as they are. A number without + and without a country comes back unknown. See the phone reference.
mode: "fast" runs the syntax, DNS, disposable and role checks and skips the mailbox check. invokeurl has no timeout setting of its own and waits up to 40 seconds before Zoho throws a socket timeout, according to Zoho's documentation, so a fast check keeps the function short and predictable. It never returns deliverable: when everything else passes, the answer is unknown with the reason smtp_not_checked. See the email reference.
Click Save and Execute Script, then save the rule.
4. Do the same for contacts
Copy the rule to the Contacts module. In the function, replace "Leads" with "Contacts" in both calls, name the argument contactId mapped to Contacts, Contact Id, and create the same three fields on Contacts.
5. Test it
With a sk_test_ key in the connection, create a lead with the email disposable@example.com. Email Status reads risky. With a test key, the part before the @ picks the answer, and in fast mode only the outcomes decided before the mailbox check apply: nomx@example.com gives undeliverable, and any other well-formed address gives unknown. The function's log, in the workflow's execution history, shows the info lines. Then reconnect with a live key.
6. Use the result
Build views, filters or a second workflow rule on Email_Status:
| Value | Meaning | Suggested action |
|---|---|---|
undeliverable |
Bad syntax, no domain or no mail server | Mark the lead as bad email, notify the owner with Email_Suggestion when it is not empty |
risky |
Disposable inbox or catch-all domain | Review before adding to a campaign |
unknown |
Fast mode passed the checks, or no conclusion | Keep the lead |
unchecked |
The API call failed | Keep the lead, check again later |
An unknown email is not a bad email, so never delete a lead on it. Phone_E164 holds the number in E.164 when it is valid, or invalid, unknown or unchecked. Format phone numbers in E.164 explains why E.164 is the format to keep.
Handle errors and rate limits
Every failure ends as unchecked and the lead is saved as usual: the function never throws past its try blocks, and its log keeps the HTTP status, the error envelope with its type and the request id. No error is billed. 401 and 403 mean a wrong or restricted key, 402 an empty balance: filter leads on unchecked regularly so you notice. The function does not retry a 429, because a Deluge function cannot wait long; the lead stays unchecked and a later run can check it again. A key allows 200 requests per 10 seconds, and Zoho has limits of its own on function executions, so do not run the rule on a mass import: check imported files with a bulk file check instead. Each email check costs 1 credit and each basic phone check 1. See Errors and Rate limits.
Related
Frequently asked questions
Where should the API key go in Zoho CRM?
Will updating the lead run the workflow rule again?
Which Zoho CRM edition do I need?
More in CRM
All integrationsPut this check in your product
Get an API key in under a minute. 100 free credits every month, no card required.
- 100 free credits a month
- No card
- Test keys spend nothing
- Cancel any time