Deluge is the scripting language behind Zoho's custom functions, and its invokeurl task is how a function calls an outside API. That's all you need to send a text: build a JSON body, set a few headers, call the endpoint, read the response code. A workflow rule fires the function when a lead is created, a deal moves or a field changes.
We make Ready, so the example uses the Ready messaging API and only the request shape we document. If you want the no-code route, Zoho CRM is also one of the CRMs in Ready's App Library (an automation can start from, or write to, a Zoho CRM record). This post is for the case where you want a function you control.
What to set up first
- An API key, sent in an
X-API-Keyheader. - A card and a number on the Ready account. The number is $2 a month. A test key (Settings, Developers, Environment: Test) simulates every send with no card, number or charge, which is the right key while you're writing the function.
- Consent. Each request carries
consent_attested: true, your promise that the person agreed to texts. A lead who filled in a phone field hasn't necessarily agreed. Gate the function on a consent field you trust. - A registration plan. Until 10DLC registration is approved, an account can send up to 500 texts a calendar month, and most approvals take 2 to 7 days.
Where to keep the key
Don't paste it into the function body. Anyone who can open the function can read it, and it ends up in copies and exports. Zoho CRM has organization variables (under Setup, Developer Hub, Variables) that a function can read at run time, so the secret lives in one place and a rotation is one edit. The function below reads one called ready_api_key.
Check the variable's visibility settings and who in your org can edit it. If the key leaks, rotate it. Our key security and rotation post has the steps.
The custom function
Here's a function that takes a record ID, a phone number and a first name from a workflow rule. Adjust the argument names to match your module:
string sendReadyText(string recordId, string phone, string firstName)
{
// Keep digits and a leading plus only
cleaned = phone.replaceAll("[^0-9+]", "");
if(cleaned.length() < 10)
{
info "Skipped " + recordId + ": phone too short";
return "skipped";
}
apiKey = zoho.crm.getOrgVariable("ready_api_key");
payload = Map();
payload.put("to", cleaned);
payload.put("body", "Hi " + firstName + ", thanks for your enquiry. We'll call you shortly.");
payload.put("consent_attested", true);
hdrs = Map();
hdrs.put("X-API-Key", apiKey);
hdrs.put("Content-Type", "application/json");
hdrs.put("Idempotency-Key", "welcome-" + recordId);
resp = invokeurl
[
url :"https://api.tryready.com/v1/messages"
type :POST
parameters:payload.toString()
headers:hdrs
detailed:true
];
code = resp.get("responseCode");
info "Ready answered " + code + " for " + recordId;
return code.toString();
} Notes on what each part does:
- The cleanup line strips spaces, dashes and brackets.
tomust be E.164, like+12125550199, though a 10-digit US number is treated as +1. Our guide to E.164 formatting covers the odd cases. detailed:truemakesinvokeurlreturn the status code along with the body, so you can branch on it. Without it you only get the body.- The idempotency key is built from the record ID plus a label, so one lead gets one welcome text even if the workflow fires twice.
infowrites to the function's execution log, which is where you'll look first when a text doesn't arrive.
Test the function from the editor with a record you control and the test key before you attach it to a rule. Deluge details such as the exact replaceAll behavior and the variable function name can differ across Zoho editions, so confirm in the editor.
Handle failures without sleeping
Deluge custom functions have execution limits, and there's no good way to wait and retry inside one. So don't try. Make the function do one call, record the result, and let something else retry.
| Response | Meaning | What to do |
|---|---|---|
| 2xx | Accepted | Write the result to a field or a note |
| 429 or a timeout | Slow down or a blip | Leave the record flagged, retry from a scheduled function |
| 409 quiet-hours refusal | The recipient's local window is closed | Retry after the window opens, or see the quiet-hours guide |
| Other 4xx | The request or the recipient is wrong | Don't retry. Flag for a person |
A simple version of this: add a custom field called Welcome text status, set it to sent, retry or failed from the function, and run a scheduled function every 15 minutes that picks up the retry records. Because the key is stable per record, a retry can't text twice. The retries guide goes through which codes are safe to repeat.
If the function texts leads around the clock, read how to handle the quiet-hours 409: an API text is held only when the window opens soon, and otherwise it isn't sent.
Which texts belong in a function
Good fits: a welcome text when a lead is created, a note to the account owner when a big deal moves to a new stage, an appointment confirmation when a meeting record is created, a payment-failed notice to your own finance team. Poor fits: bulk sends. For lists, use the bulk endpoint from a script or a campaign tool, where you can batch up to 100 numbers per call, rather than looping a custom function across thousands of records.
Cold leads from a purchased list are a poor fit too. SMS goes to people who agreed or who've replied. Ready stores your attestation per API send but not a per-contact opt-in record, so keep the consent in the CRM record itself.
Also note that a text sent from a function doesn't appear in the contact's timeline unless you write it there. Ready doesn't log every text to the CRM on its own, so add a note from the function with the response code and time if the team needs the history. Our Zoho CRM integration guide compares the other ways to connect.
What it costs
Each segment on the Standard rate is $0.0075 plus a $0.0045 carrier fee. As an example, 400 new leads a month each getting a one-segment welcome text is 400 × ($0.0075 + $0.0045) = $4.80, plus the $2 monthly number. That all-in figure excludes screening, the optional Scrub lists and Number validation switches, off by default and $0.003 per segment each when on. Keep texts under 160 characters without an emoji and each is one segment. See pricing.
Ready's all-in prices per segment include the carrier fee but not screening: Scrub lists and Number validation, the two switches in Settings under Compliance, each add $0.003 per segment when switched on, shown as screening on your bill, and both are off by default. Unless you turn the opt-out footer off, the first text to each contact, and one again from time to time, also gets "Reply STOP to opt out" and your business name if the message does not already have them, so a text close to the segment limit can bill one more segment.
Accounts opened before November 12, 2026 keep their signup prices, shown under Billing.
The short version
One invokeurl call, a key held in an organization variable, a cleaned number, a per-record idempotency key and a status field instead of a retry loop. Start with a test key, then go live once the card, number and registration are in place. The API quickstart has the first-send steps, and you can start texting today when you're ready.