If you send WhatsApp messages from n8n to Indian customers, the first thing that breaks is not the API. It is the phone number.

People type their number every possible way into a form, an IndiaMART enquiry or a Google Sheet:

  • 9810012345
  • 98100 12345
  • 098100-12345
  • +91 98100 12345
  • 0091 98100 12345
  • 91 98100 12345

The WhatsApp Cloud API wants one thing: country code plus number, digits only, like 919810012345. Send anything else and the message fails, or worse, goes to the wrong number.

I hit this while adapting one of my published n8n workflows (instant WhatsApp reply + enquiry log) for Indian businesses. The original was written for UK numbers, where "starts with 0, so swap the 0 for the country code" works. In India it doesn't, because most people never type the leading 0 at all. They type 10 digits.

The rules that actually matter for India

  1. Indian mobile numbers are 10 digits and start with 6, 7, 8 or 9.
  2. People may add a leading 0, +91, 0091, 091 or 91, with any spaces, dashes or brackets.
  3. Landlines (like 0120 4xxxxxx in Noida) look similar but are not mobiles. Flag them instead of sending.
  4. If someone types + or 00 first, trust them: it is an international number, so leave the country code alone.

The function

// Turns whatever an Indian customer typed into the number format the // WhatsApp Cloud API expects: country code + number, digits only (no +). function toWhatsAppNumberIN(entered) { let s = String(entered ?? '').trim(); let international = false; s = s.replace(/[^\d+]/g, ''); // keep digits and a leading + if (s.startsWith('+')) { s = s.slice(1); international = true; } else if (s.startsWith('00')) { s = s.slice(2); international = true; } s = s.replace(/\D/g, ''); if (!international) { if (/^0?[6-9]\d{9}$/.test(s)) s = '91' + s.slice(-10); // 98100 12345, 098100 12345 else if (/^091[6-9]\d{9}$/.test(s)) s = s.slice(1); // 091 98100 12345 } if (s.startsWith('91')) { // Indian mobiles are 10 digits starting 6-9. Anything else (a landline, // a short number) can't reliably receive WhatsApp from you. return /^91[6-9]\d{9}$/.test(s) ? { ok: true, number: s } : { ok: false, number: s, reason: 'not an Indian mobile number' }; } // Other countries: accept a plausible international number (E.164 is max 15 digits). return international && s.length >= 8 && s.length <= 15 ? { ok: true, number: s } : { ok: false, number: s, reason: international ? 'number too short or too long' : 'not a mobile number we recognise' }; } 

Note the order of the checks. A 10-digit mobile can itself start with 91 (for example 9112345678), so the "10 digits starting 6-9" rule runs before the "already has a country code" rule. Get that order wrong and you send to the wrong person.

The test cases

I ran it against the inputs I actually see in Indian enquiry forms:

Typed by the customer Result
9810012345 919810012345 ✅
98100 12345 919810012345 ✅
098100-12345 919810012345 ✅
+91 98100 12345 919810012345 ✅
+91-98100-12345 919810012345 ✅
0091 98100 12345 919810012345 ✅
919810012345 919810012345 ✅
091 98100 12345 919810012345 ✅
(+91) 7011 223344 917011223344 ✅
+44 7700 900123 447700900123 ✅ (international left alone)
0120 4567890 ❌ not a mobile number
5810012345 ❌ not a mobile number
+91 98100 1234 ❌ not an Indian mobile number (one digit short)
12345 ❌ too short
empty ❌

15 out of 15 pass.

Using it in an n8n Code node

Put this in a Code node (Run once for all items) right after your trigger. It keeps the original number for your records and adds the cleaned one plus a flag you can route on with an If node.

// paste toWhatsAppNumberIN() from above here, then: return $input.all().map((item, index) => { const typed = item.json['Mobile number'] ?? item.json.mobile ?? ''; const phone = toWhatsAppNumberIN(typed); return { json: { ...item.json, phone_entered: String(typed), phone_whatsapp: phone.number, phone_ok: phone.ok, phone_problem: phone.ok ? '' : phone.reason, }, pairedItem: { item: index }, }; }); 

Then:

  • If phone_ok is true and the person agreed to WhatsApp → WhatsApp node → Send Template, with phone_whatsapp as the recipient.
  • Otherwise → log it as Call only in your sheet or CRM, so a person phones them instead.

That second branch matters. A silent failure is how leads disappear: the workflow "ran", nobody got a message, and nobody knows.

Two things the code can't fix

  • Consent. Business-initiated WhatsApp messages need the person's opt-in and an approved template. Ask "Can we reply on WhatsApp?" on the form and store the answer.
  • The 24-hour window. Free-form replies only work within 24 hours of the customer's last message. Outside it, you need a template.

Where this fits

This is the first step in every WhatsApp workflow I build for Indian businesses, before the instant reply, the follow-ups or the CRM update. If you want to see it in context, there's a 2-minute walkthrough of the full workflow on the WhatsApp follow-up automation page, and the template itself is free on n8n.io.

If you find an input format that breaks it, drop it in the comments and I'll add a case.

Chandan Kumar builds CRM, WhatsApp API and n8n automations for Indian businesses at Workflow Decoded.