Why we built this?
While working on a custom checkout flow, we ran into a key problem: some leads filled out forms but never submitted them completely. Yet, our automation was already triggering emails and WhatsApp reminders to help them complete their order. This created a gap—we had leads who were actively contacted, but not yet converted into Contacts and Deals, which disrupted reporting, tracking, and pipeline clarity.
We needed a way to auto-convert these leads from form interactions into proper CRM records — but only if:
Their email wasn't fake (e.g., test@test.com, abc@tempmail.com)
They didn't already exist in the Contacts module
So we built a GPT-powered Deluge function to handle it.
Solution Overview
Our function is built using:
Zoho CRM Deluge scripting
OpenAI GPT-4 API for smart email validation
Conditional logic to:
Flag fake/test/dummy emails
Check for duplicates
Convert valid leads into Contacts and Deals
How it works
Step 1: Validate Email Using GPT
We send the lead's email to OpenAI's GPT API with a strict prompt:
If the email contains
test,fake,dummy, or looks random (e.g., asdf123@gmail.com), GPT returnsYES.Otherwise, it returns
NO.
This lets us skip obviously fake/test data.
Step 2: Check for Duplicates
Using Zoho CRM's searchRecords, we look for existing Contacts with the same email or phone. If found, we skip the conversion.
Step 3: Auto-Convert
If the email passes and no duplicates are found:
The Lead is converted into a Contact
A new Deal is created in the correct pipeline and stage
Sample Code Snippet
string standalone.convert_lead(Int leadId,String email,String phone,String first_name,String last_name){response_message = "";// STEP 1: Check if Email is Fake/Dummy via GPTsystemPrompt = "You are a strict email validator.You must identify whether an email is likely fake, test, or dummy based on its structure or common patterns. If the email contains words like 'test', 'fake', 'dummy', random characters, or is from a suspicious or disposable domain, return YES. Examples of fake emails: test@example.com, fakeemail@gmail.com, dummy@tempmail.com, asdf1234@domain.com. If the email seems valid and real (e.g., john.doe@gmail.com), return NO. Always respond ONLY with YES or NO — no explanations.";userPrompt = "Check this email: '" + email + "'";dealName = first_name + " " + last_name;emailPrompt = "Is this email fake, test or dummy? '" + email + "'. Answer only YES or NO.";headersMap = Map();headersMap.put("Authorization","Bearer YOUR API KEY HERE");headersMap.put("Content-Type","application/json");messageList = List();messageList.add({"role":"system","content":systemPrompt});messageList.add({"role":"user","content":userPrompt});bodyMap = Map();bodyMap.put("model","gpt-4");bodyMap.put("messages",messageList);gptResponse = invokeurl[url :"https://api.openai.com/v1/chat/completions"type :POSTbody:bodyMap.toString()headers:headersMap];responseText = gptResponse.toMap().get("choices").get(0).get("message").get("content").toLowerCase();if(responseText == "no"){if(email != null && phone != null){contactSearch = "(Mobile:equals:" + phone + ") or (Email:equals:" + email + ")";contactSearchResults = zoho.crm.searchRecords("Contacts",contactSearch);info contactSearchResults;if(contactSearchResults.size() == 0){response_message = "Convert Lead";convertMap = Map();convertMap.put("overwrite",true);//convertMap.put("assign_to",ownerId);dealsMap = Map();dealsMap.put("Deal_Name","QuoteApp - " + dealName);dealsMap.put("Stage","xxx");dealsMap.put("Lead_Source","Form from Site");dealsMap.put("Pipeline","Pipeline xxx");// The Deals Map is simply added to the Convert Map.convertMap.put("Deals",dealsMap);// The Convert Map needs to be passed as a JSON string, which you'll see in the API call.dataParam = {"data":{convertMap}};// Nothing too crazy here, except for the required ".toString()" for the parameters. Again, the Conversion action requires a JSON string.convert = invokeurl[url :"https://www.zohoapis.com/crm/v7/Leads/" + leadId + "/actions/convert"type :POSTparameters:dataParam.toString()connection:"modulesall"];info convert;converted_contact_id = convert.get("data").get(0).get("details").get("Contacts").get("id");response_message = "Lead converted to Contact " + converted_contact_id;}else{response_message = "Contact already exist";}}else{response_message = "Email or Phone is null";}}else{response_message = "Fake, Test or Dummy lead. Do not Convert";}return response_message;}
🙌 Final Thoughts
This automation saved us hours of manual checks and helped align our contact flows with our real-time automations (email, WhatsApp). With GPT in the loop, we now trust the quality of converted contacts much more — no more test123@gmail.com clogging up our deal pipeline.
Feel free to adapt this solution to your own CRM setup — and let us know how it goes!

