Zoho Creator and Razorpay Integration: Build a Custom Payment Collection Portal for Indian Businesses
Build a custom payment collection portal using Zoho Creator and Razorpay. Step-by-step setup with Deluge…
Sales teams lose deals when follow-ups are slow. A lead fills out a form, and hours pass before anyone reaches out. By connecting Zoho CRM and Twilio, you can trigger an SMS within seconds of a lead status change, log every inbound and outbound call directly to the contact timeline, and run multi-step SMS drip sequences without leaving your CRM. This guide walks through the complete Zoho CRM Twilio integration using Deluge custom functions and Twilio’s REST API, covering triggered SMS campaigns, call logging, drip sequences, opt-out compliance, and error handling for production use.

Zoho CRM handles contact management, deal tracking, and workflow automation. Twilio provides programmable SMS, voice, and WhatsApp APIs used by over 300,000 businesses. Connecting the two gives your sales team three capabilities that native Zoho telephony providers do not offer out of the box.
First, event-triggered SMS. When a lead moves to “Contacted” or a deal reaches “Negotiation,” a Deluge custom function fires and sends a personalised SMS through Twilio within seconds. No manual intervention, no third-party automation tool.
Second, bi-directional call logging. Every outbound call made through Twilio and every inbound call received gets logged as a note or activity on the matching CRM contact record. Your team sees the full communication history in one place.
Third, SMS drip sequences. You can schedule a series of messages, for example a welcome SMS on day 0, a product overview on day 2, and a meeting request on day 5, all triggered from a single workflow rule with scheduled custom functions.
The result is faster response times, complete audit trails, and higher conversion rates. Research consistently shows that SMS open rates exceed 90%, and responding to a lead within five minutes increases qualification odds by a factor of eight.
Before writing any code, you need a working Twilio account and the correct Zoho CRM edition.
The core of the Zoho CRM Twilio integration is a Deluge custom function that fires when a workflow rule detects a field update. Here is the step-by-step implementation.
Go to Setup > Automation > Actions > Custom Functions. Click “Configure Custom Function” and select the Leads module. Refer to the Zoho Deluge Twilio documentation for syntax details. Name the function sendTwilioSMS and map the argument leadId as a string.
// sendTwilioSMS - triggers on lead status change
leadDetails = zoho.crm.getRecordById("Leads", leadId.toLong());
phone = leadDetails.get("Mobile");
firstName = leadDetails.get("First_Name");
optOut = leadDetails.get("SMS_Opt_Out");
// Respect opt-out
if(optOut == true)
{
info "SMS blocked - lead opted out: " + leadId;
return;
}
if(phone == null || phone == "")
{
info "No mobile number for lead: " + leadId;
return;
}
// Twilio credentials
accountSid = "YOUR_ACCOUNT_SID";
authToken = "YOUR_AUTH_TOKEN";
fromNumber = "+1XXXXXXXXXX";
// Compose message
message = "Hi " + firstName + ", thanks for your interest. Reply STOP to opt out.";
// Build Twilio API request
twilioUrl = "https://api.twilio.com/2010-04-01/Accounts/" + accountSid + "/Messages.json";
params = Map();
params.put("To", phone);
params.put("From", fromNumber);
params.put("Body", message);
// Send via invokeurl
response = invokeurl
[
url: twilioUrl
type: POST
parameters: params
connection: "twilio_connection"
];
// Log the Message SID back to the lead record
if(response.containKey("sid"))
{
msgSid = response.get("sid");
updateMap = Map();
updateMap.put("Twilio_Message_SID", msgSid);
zoho.crm.updateRecord("Leads", leadId.toLong(), updateMap);
info "SMS sent - SID: " + msgSid;
}
else
{
info "Twilio error: " + response.toString();
}
Navigate to Setup > Automation > Workflow Rules. Create a new rule for the Leads module with these settings:
sendTwilioSMS custom function, passing the Lead IDYou can duplicate this rule for other status transitions. Our Zoho CRM automation guide covers workflow rules and blueprint configuration in detail. For example, trigger a different message when Lead Status changes to “Qualified” or when a Deal Stage moves to “Proposal Sent.”
In Zoho CRM, go to Setup > Developer Space > Connections. Create a new connection with these parameters:
twilio_connectionhttps://api.twilio.com
SMS is only half the picture. If your team makes calls through Twilio, those interactions should appear on the Zoho CRM contact record alongside emails, meetings, and notes.
When an agent initiates a call through Twilio (using a Twilio-powered softphone or click-to-call widget), Twilio generates call events with metadata including duration, status, and recording URL. You can capture this data using a Twilio StatusCallback webhook that posts to a Zoho CRM custom function exposed via an API endpoint. If you are new to webhooks in Zoho, our CRM API and webhooks guide covers the setup process.
Create a standalone Deluge function exposed as a REST API:
// logTwilioCall - webhook endpoint for Twilio call events
callSid = input.get("CallSid");
callerNumber = input.get("From");
dialedNumber = input.get("To");
callStatus = input.get("CallStatus");
duration = input.get("CallDuration");
recordingUrl = input.get("RecordingUrl");
// Find the contact by phone number
searchResult = zoho.crm.searchRecords("Contacts", "(Mobile:equals:" + dialedNumber + ")");
if(searchResult.size() > 0)
{
contactId = searchResult.get(0).get("id");
// Create a note on the contact
noteData = Map();
noteData.put("Note_Title", "Twilio Call - " + callStatus);
noteData.put("Note_Content", "Duration: " + duration + "s | SID: " + callSid);
noteData.put("Parent_Id", contactId);
noteData.put("se_module", "Contacts");
zoho.crm.createRecord("Notes", noteData);
info "Call logged for contact: " + contactId;
}
else
{
info "No matching contact for number: " + dialedNumber;
}
For inbound calls, configure your Twilio phone number’s webhook to point to the same Zoho function endpoint. Twilio sends the caller’s number in the From parameter, which you use to search Contacts and Leads. If a match is found, log the call. If no match exists, create a new Lead record automatically with the phone number, ensuring no inbound call goes untracked.
A single welcome SMS is useful, but a timed sequence of messages converts better. Zoho CRM’s scheduled custom functions let you build drip campaigns without external tools.
The approach uses a custom module called “SMS_Sequences” with these fields:
| Field | Type | Purpose |
|---|---|---|
| Sequence_Name | Single Line | Campaign identifier (e.g., “New Lead Welcome”) |
| Lead_ID | Lookup (Leads) | Linked lead record |
| Step_Number | Number | Current step (1, 2, 3…) |
| Next_Send_Date | Date/Time | When to send the next message |
| Status | Picklist | Active, Completed, Cancelled |
Create a scheduled function that runs every hour. It queries all SMS_Sequences records where Next_Send_Date is in the past and Status is “Active,” then sends the appropriate message for the current Step_Number.
// scheduledDripSender - runs hourly via scheduled function
now = zoho.currenttime;
pendingSequences = zoho.crm.searchRecords("SMS_Sequences",
"(Status:equals:Active) and (Next_Send_Date:before:" + now + ")");
for each seq in pendingSequences
{
leadId = seq.get("Lead_ID").get("id");
step = seq.get("Step_Number").toNumber();
// Define messages per step
messages = List();
messages.add("Hi {{First_Name}}, welcome aboard. We help teams close deals faster with Zoho CRM.");
messages.add("Quick question, {{First_Name}}: what is your biggest sales tracking challenge right now?");
messages.add("{{First_Name}}, would a 15-minute call this week help? Book here: {{meeting_link}}");
if(step <= messages.size())
{
// Fetch lead details for personalization
lead = zoho.crm.getRecordById("Leads", leadId.toLong());
msg = messages.get(step - 1);
msg = msg.replaceAll("{{First_Name}}", lead.get("First_Name"), true);
msg = msg + " Reply STOP to opt out.";
// Send via Twilio (reuse sendTwilioSMS logic)
sendSMSviaTwilio(lead.get("Mobile"), msg);
// Advance the sequence
nextStep = step + 1;
updateMap = Map();
if(nextStep > messages.size())
{
updateMap.put("Status", "Completed");
}
else
{
updateMap.put("Step_Number", nextStep);
updateMap.put("Next_Send_Date", now.addDay(2));
}
zoho.crm.updateRecord("SMS_Sequences", seq.get("id").toLong(), updateMap);
}
}
This pattern scales to any number of sequences. For a related use case, see how Zoho Creator handles Twilio appointment reminders using a similar scheduled approach. You define the message content per step, control timing through the Next_Send_Date field, and the scheduled function handles execution automatically.
Production SMS integrations fail silently if you do not build in error handling. Twilio returns specific error codes that your Deluge functions should catch and act on.
| Error Code | Meaning | Action |
|---|---|---|
| 21211 | Invalid phone number | Flag the lead record, skip future sends |
| 21614 | Number not SMS-capable | Remove from SMS sequences |
| 21610 | Recipient opted out via STOP | Set SMS_Opt_Out = true on the CRM record |
| 30003 | Unreachable destination | Retry once after 1 hour, then flag |
| 30007 | Message filtered (carrier block) | Check A2P registration status |
Wrap every Twilio API call in a try-catch block and log failures to a custom “SMS_Errors” module for visibility:
try
{
response = invokeurl
[
url: twilioUrl
type: POST
parameters: params
connection: "twilio_connection"
];
if(response.containKey("error_code") && response.get("error_code") != null)
{
errorCode = response.get("error_code");
errorMsg = response.get("error_message");
// Log to SMS_Errors module
errorRecord = Map();
errorRecord.put("Error_Code", errorCode.toString());
errorRecord.put("Error_Message", errorMsg);
errorRecord.put("Lead_ID", leadId);
errorRecord.put("Phone_Number", phone);
zoho.crm.createRecord("SMS_Errors", errorRecord);
// Handle opt-out automatically
if(errorCode == 21610)
{
optOutMap = Map();
optOutMap.put("SMS_Opt_Out", true);
zoho.crm.updateRecord("Leads", leadId.toLong(), optOutMap);
}
}
}
catch(e)
{
info "Exception sending SMS: " + e.toString();
}
When sending an SMS, include a StatusCallback parameter in your Twilio API request. Twilio will POST delivery updates (queued, sent, delivered, failed, undelivered) to your callback URL. Use these updates to populate a “Delivery_Status” field on your SMS log records, giving your team real-time visibility into message outcomes.

SMS compliance is not optional. Violations of TCPA (US), GDPR (EU), or TRAI DND (India) regulations carry significant fines. Build compliance into the integration from day one.
Twilio enforces sending limits based on your number type. A standard US local number supports 1 SMS per second. Toll-free numbers support 3 per second. Short codes support 100 per second. If your drip sequences process hundreds of leads hourly, add a wait(1000) call between sends in your Deluge loop, or use a Twilio Messaging Service with number pooling for higher throughput.
Before going live, validate every component of the integration in a controlled environment.
Set up a Zoho CRM analytics dashboard that tracks SMS sent per day, delivery rates, opt-out rates, and error counts. Create a workflow alert that notifies the admin when the SMS_Errors module receives more than five records in a 24-hour period. This early warning system catches API credential expiry, number deactivation, or carrier filtering issues before they affect your campaigns.
For a full overview of all available options, explore our complete guide to Zoho integrations.
What Zoho CRM edition do I need for Twilio integration?
You need Zoho CRM Professional edition or higher. Custom functions, which are required to call the Twilio API via Deluge scripts, are not available on the Free or Standard plans. The Professional plan starts at $23 per user per month (billed annually). If you only need basic SMS without custom logic, the Twilio Marketplace extension works on Enterprise edition and above.
How much does Twilio SMS cost per message?
Twilio charges $0.0079 per outbound SMS segment in the US and $0.0079 per inbound SMS. International rates vary, for example India is approximately $0.04 per outbound SMS. Each SMS segment supports 160 characters (GSM encoding) or 70 characters (Unicode). Messages exceeding these limits are split into multiple segments and billed accordingly. Phone number rental adds $1.15 per month for a US local number.
Can I send bulk SMS from Zoho CRM through Twilio?
Yes, but with rate limits. A standard Twilio local number supports 1 SMS per second. For bulk sends exceeding 100 messages, use a Twilio Messaging Service with a number pool or a short code. In Zoho CRM, trigger bulk sends through a scheduled function that processes a batch of records with a delay between each send to stay within Twilio’s throughput limits. Always check the SMS_Opt_Out field before sending.
How do I handle SMS opt-outs automatically in Zoho CRM?
Twilio’s Advanced Opt-Out feature processes STOP replies automatically and returns error code 21610 when you attempt to message an opted-out number. In your Deluge custom function, catch this error code and set the SMS_Opt_Out checkbox to true on the Lead or Contact record. Add a condition at the start of every SMS function that checks this field and exits immediately if the lead has opted out.
What is the difference between using Zoho Flow and custom functions for Twilio?
Zoho Flow is a no-code automation tool that connects Zoho apps with third-party services including Twilio. It works well for simple triggers like sending a single SMS when a new lead is created. Custom Deluge functions offer full control over message content, error handling, delivery tracking, retry logic, and multi-step drip sequences. For production SMS campaigns with compliance requirements, custom functions are the recommended approach because they support conditional logic and CRM record updates within the same execution.
Aaxonix builds custom Zoho CRM integrations with Twilio, including triggered SMS workflows, call logging, drip sequences, and compliance automation. Book a free consultation to get a no-obligation review of your current CRM communication setup and a scoped implementation plan.
Book a free consultationConnecting Zoho CRM with Twilio gives your sales team instant SMS reach and complete call visibility, all driven by Deluge custom functions and Twilio’s REST API. Start with a single triggered SMS on lead status change, validate the end-to-end flow, then expand to drip sequences and call logging. The technical foundation covered here scales from a five-person sales team to an enterprise operation with thousands of daily interactions.
Our team builds systems that actually work. No fluff, just honest architecture and clean implementation.