One hundred and six. Three digits, no country code, no international form, and no single owner. It might be the hardest number in Israel to dial.
It's also the number that decides whether Daniel's dialler is a toy or a real system.
Right. So Daniel's prompt, for those just joining us. He has outbound TwiML on his own Twilio and SIP setup, and he's already solved the basic case — a number typed the way a person would type it, Israeli local format starting 02, gets translated to E.164 before Twilio dials. What he wants now is the actual build, written out. How dial-out recognition works for wherever you are in the world, which local shorthands people will expect to keep working, the pitfalls, and then the hard edge of it all: the special numbers. Israel's three-digit service lines, the municipal moked, emergency numbers with their restrictions, and in the US, toll-free 1-800 numbers dialled from an ordinary Twilio number.
The whole problem is one sentence long, honestly. Twilio wants E.164 and humans don't dial it.
And that sentence is the entire job.
The noun inside wants a plus, a country code, the subscriber number, fifteen digits maximum. The only leniency Twilio documents is for unformatted US numbers — you can hand it 415-555-1212, with the parentheses and dashes and all, and it'll cope. That leniency is the trap. It works for a San Francisco number, so you assume the API is friendly, and then an Israeli 02 number walks in the door.
It's friendly to exactly one country.
Which is a strange kind of friendly. And there's a reason for it, which is that Twilio was born inside the North American Numbering Plan. The US and Canada share one numbering scheme, so a number that's unformatted but unambiguous in San Francisco is also unambiguous in Toronto. Most of the world doesn't have that luxury — Israel's plan can't be disambiguated without knowing you're in Israel. The leniency isn't generosity, it's geography.
So the American developer never learns the rule, and the Israeli developer learns it on day one.
Usually via an error message, which is a terrible teacher. The failure comes in two flavours, and Daniel should know both by heart. Error 13223 is "Dial: Invalid phone number format" — the number isn't E.164, or the noun is missing, or you're dialing something that isn't a phone number at all. That last clause matters more than it looks, and we'll come back to it. Error 13226 is "Dial: Invalid country code", and that's the one a leading zero triggers — zero is not a valid first digit for an E.164 country code, so an 02 number sent raw falls over right there.
So the shape of the episode is: the translation layer is easy to write and hard to write correctly.
Yes. The regex is a weekend. The policy is a career. Every rule you add to the translator is a bet about what the human meant, and some of those bets are cheap and some are very expensive.
Start with the ordinary case, then. The one Daniel already fixed — an Israeli landline typed the way an Israeli would type it.
Israel's country code is 972, and the dial plan is closed, which means you always dial the trunk prefix domestically. Zero, then the area or network code, then the subscriber number. From outside, you drop the zero and prepend plus 972. So 02-531-4600, which is a Jerusalem landline, becomes plus nine seven two, two, five three one four six zero zero.
And just to be clear about what closed means, because I got this wrong for years — closed isn't about the number of digits.
No, it's about whether you can omit anything. A closed plan says: the national number is always dialled in full, trunk prefix included, no matter where in the country you're calling from. An open plan, like the old UK one, lets you dial just the local subscriber number when you're calling within your own area. Israel closed things up years ago precisely to avoid the ambiguity we're about to spend half this episode on. Which tells you something: a whole national regulator looked at local shorthands and decided they cost more than they were worth.
And Daniel's users will want them anyway.
Humans always want the shortcut the regulator took away. But that's ahead of us. The zero is dropped. Not doubled, not carried, just gone.
Gone.
The five geographic area codes are 02 for Jerusalem, 03 for Tel Aviv and the centre, 04 for Haifa and the north, 08 for the south and lowlands, 09 for the Sharon. Mobile numbers start 05, VoIP numbers start 07. Landline subscriber numbers run eight or nine digits, mobile is ten. Strip the trunk prefix, prepend plus 972, keep the total under fifteen digits — you're done for maybe ninety percent of what anyone will ever type.
Ninety percent is a lot. It's the other ten I want to talk about, but first — the digit-length thing. Eight or nine digit landlines. Does that matter to the translator?
It matters for validation, not translation. If someone in area 03 types a number that resolves to eleven subscriber digits, no rule you have will make that a phone number. Length checking is your cheapest sanity gate — it catches fat-fingered extra digits before they ever reach Lookup. But you have to encode the lengths per country, per number type, and they drift over time as regulators allocate new ranges. Israel added the 07 range in stages; the lengths in that range alone aren't uniform. So even the sanity gate is a maintenance commitment.
Then the fun starts. Because Twilio's own error page for 13226 prescribes exactly this fix, doesn't it.
Almost word for word. Remove any national trunk prefix such as a leading zero before adding the country code, and validate and normalise with Twilio Lookup before you place the call. So Daniel built what the doctor ordered. The question is what the doctor didn't order.
Lookup.
Lookup. The Basic Lookup in Lookup v2 is the sanctioned normaliser — it's free, it returns the number in both E.164 and national format, and it validates. But here's the footgun, and it's a beautiful one. If you send Lookup a number in national format and don't pass the CountryCode parameter, CountryCode defaults to the US.
An Israeli number validated as American.
Validated as American. And it gets worse, because Twilio admits there's an ambiguity in their own behaviour — non-US numbers in national format, with no plus sign and no CountryCode, are sometimes processed as valid. They call it unintended behaviour that could lead to ambiguous validation responses. Unintended is their word.
"Sometimes processed as valid." That's the kind of bug that gets a pass mark.
It's the worst kind, because it doesn't fail loudly. Your validation step says yes, your TwiML goes out, and the call dies at dial time with 13223. So the rule for Daniel's build is simple: never call Lookup without CountryCode. It's one parameter. Leave it out and the whole safety net is checking the wrong country.
What I like about that is where the failure lands. The number is fine, the format is fine, the code is fine — the assumption is wrong, and nothing in the pipeline tells you.
Nothing. And the debugging pattern is insidious, because the developer tests with a US number first, usually. It validates, it dials, everything's green. Then they test the Israeli number, it validates — because of the ambiguity — and dies at dial. So the validation step looks guilty by association, and they spend a day rewriting the one part that was working. The bug was never in the translator. It was in the default.
Okay, now the shorthands, because this is where Daniel's users will fight him. Within a geographic area code, Israel lets you drop the prefix entirely. Instead of dialing the full 0-area-subscriber number, you can dial just the seven or eight subscriber digits if you're inside that area.
Wait — hold on. You just told me the plan is closed.
I did, and this is the wrinkle. The plan is closed at the national level, but the local subscriber shorthand survives in practice for calls within a geographic area. Regulators can close a plan on paper faster than a population closes it in muscle memory. So a bare seven-digit string walks into the dialler.
And the dialler has to guess. Is that a local subscriber number in the caller's own area code, or is it a typo, or is it garbage? There's no answer in the numbering plan. The plan doesn't know where the caller is. You either assume a default area code — and then you have to decide whose, the Twilio number's area code, the caller's actual location, something the user set in a profile — or you reject it and make them type the whole thing.
Which would you build?
I'd assume, honestly, but I'd do it loudly. If someone dials seven digits, translate it against the area code of the Twilio number doing the dialling, and show them what you dialled before the call connects. A half-second confirmation. Because the silent guess is the thing that wakes you up at two in the morning — you called the wrong plumber in the wrong city and it connected anyway.
Give me the two-in-the-morning version. Make it concrete.
Fine. Your Twilio number is a Jerusalem 02 number. Your user is visiting Haifa, and their regular plumber — whose number they know by heart as seven digits — is a Jerusalem plumber. But they've just had a burst pipe in Haifa, and they dial the seven digits of the Haifa plumber their neighbour gave them. The dialler sees seven digits, prepends 02, and calls a Jerusalem number that happens to share those seven digits. It rings. Somebody answers. The call connects, minutes tick, and nobody involved — not the caller, not the callee, not your logs — shows anything wrong. The number was valid. The city was wrong. That's the whole nightmare in one sentence.
I'd reject.
You would.
A sloth has never once regretted asking for the full number.
Fair. And for a household dialler like Daniel's, one user, known area — the assumption is nearly free. It's when the dialler serves people you don't know that the guess gets expensive. Then there's the other shorthand, and this one must not be mistaken for a national number: international access prefixes. From Israel, you reach abroad with 00, or with one of the 01x operator codes — 012, 013, 014, all the way up to 019, one per carrier.
So somebody types 00-1-415-555-1212.
And if your translator naively prepends 972, you've just invented a number that doesn't exist — plus nine seven two, zero zero, one, four one five... That's not a phone number, that's a confession. The rule is: strip the 00, or the 01x, strip and reflag as international, prepend a plus, and treat the rest as the international number. 00-1-415-555-1212 becomes plus one, four one five, five five five, one two one two.
And the 01x codes — do those change the destination, or just the route?
Historically, the carrier. You dial 013 to send the call via that carrier's international arm. The destination number after the prefix is the same. So for translation purposes, 012-1-415... and 00-1-415... should resolve to the identical E.164. The carrier choice is a routing preference, and a Twilio dialler doesn't honour it anyway — Twilio routes via its own carriers. Which means the honest thing is to strip it and, if you're feeling thorough, note that the user's carrier preference was discarded. Most users dialling 01x today are doing it out of habit from a decade when it mattered.
The prefix is a human's way of saying "abroad." The translator's job is to hear it.
That's the part I find elegant about the whole problem, actually. Every one of these rules is linguistics wearing a number's clothes. The trunk zero is a word that means "stay in the country." The 00 is a word that means "leave the country." The seven-digit bare string means "nearby." You're not formatting digits, you're parsing intent.
And the mistakes are translation mistakes, not arithmetic ones.
Which is why I'd build it as a small state machine with a country-specific rule set, not one heroic regular expression. Rule order matters too — you check the 00 prefix before anything national, because once you've decided it's an international number, everything downstream changes. You check the short codes before the short strings get mistaken for subscriber numbers.
You've got an order in your head already.
Plus-signed input passes straight through, strip formatting. Then 00 or 01x, strip and reflag as international. Then country-specific national format, which for Israel means leading zero plus known area code. Then the bare short string, which is your local-assumption rule. Then everything else, which gets validated and bounced back to the human. Five gates, in that order.
And gate five is a person, which is the correct gate to end on.
It's the only gate that can read minds, so yes. I will say, we did an episode on Twilio number normalization a while back — the carriers' translation layer, trunk prefixes generally — and one thing we said then that holds up: Twilio doesn't understand service codes at all. That was the gap. Today is the build on top of that gap.
The ordinary numbers, then. The ones that are numbers. Now the cases where the right answer is to refuse.
And I want to start with 106, because it's the most interesting design decision in this whole build. 106 is the municipal call centre — the moked. Resident inquiries, hazards, referrals to emergency services if it's not quite an emergency. Many local authorities use it. It is a three-digit short code, and it has no international equivalent. There is no plus 972-106. It doesn't exist.
Error 13223 again — dialing something that isn't a phone number.
That's the clause I flagged earlier. The 106 case is literally in the error definition. But here's the twist that makes it a design decision and not just a blocked row: 106 isn't even a national constant. Some municipalities use 107. Some use 108. Some use 109. Ramat Gan is 109. Bat Yam is 107. So when your user types 106, the question isn't "what is 106 in E.164" — the question is "which municipality does this caller mean."
The number means nothing without a postcode.
Without at least a city. Now — where does the dialler get the caller's city? Two honest sources. One, the Twilio number doing the dialling has its own area code, so a 02 number suggests Jerusalem. But that's the number's location, not the person's.
And the gap between those two things — how big is it really, in practice?
Bigger every year, honestly. Number portability means people keep mobile numbers when they move across the country, and a household landline-style Twilio number stays wherever it was bought. The number is a photograph of where the account was opened, and the person is wherever they are. For a one-user household system the gap is probably zero. Every user you add multiplies the chance the photograph is stale.
Or two, you ask. Which is slower but correct, and for a household system it's a one-time setting.
And once you know the city?
Then you can do the thing that actually works, which is the published geographic fallback. Every municipality that runs a moked also publishes an ordinary geographic number that reaches the same desk from mobiles and from outside the city. Jerusalem's moked is 106 from a phone in Jerusalem, and 02-531-4600 from a mobile or anywhere else. Tel Aviv is 106, or star-9106 from a mobile, or 03-523-8888. Ariel publishes 106 or 03-906-1666. Beit Shemesh does 106 plus a cellular speed dial, 10622.
So the translator doesn't translate 106. It swaps it.
It swaps it, through a short-code table keyed by municipality. 106 for a Jerusalem caller becomes plus 972-2-531-4600. The same three keystrokes for a Tel Aviv caller becomes plus 972-3-523-8888. That's a real strategy — it's arguably the only strategy, because there's no E.164 route to a short code and Twilio documents no mapping whatsoever.
Nobody's built this table.
Nobody's built it. The municipal directories exist — the hotlines are all published, city by city — but as far as I can tell nobody has assembled them into a short-code translation layer for a dialler. Daniel would be assembling it by hand, municipality by municipality.
Which is the kind of thing Daniel does for fun, and we get the episode out of it.
We absolutely do. One more trap in that Tel Aviv row: star-9106. That's a star code, and it is not dialable as a PSTN number at all. If a user types it, the translator has to recognise the shape and refuse — or better, resolve it through the same table to the geographic number — but it must never be mangled into something that looks dialable.
Don't turn a star code into a wrong number.
A mangled star code doesn't fail. It rings something. That's the nightmare row in any translation table. And notice it's the same shape as the seven-digit plumber problem — a valid-looking output from an unparseable input. The rule for both is identical: when you can't be sure what the human meant, don't guess silently.
Now the emergency numbers. Where the correct behaviour, I'd think, is the same shape as the star code — refuse — but for completely different reasons.
For regulatory reasons, and this is the part I want to be unambiguous about, because it's the one place in this build where getting it wrong is serious. Twilio's Israel voice guidelines state it flat: calls to emergency services numbers in Israel are not allowed over Twilio. Not unsupported — not allowed. Israel's emergency short codes sit in the 10, 11 and 12 ranges: police is 100, Magen David Adom is 101, fire is 102. All of them marked not available from abroad. There's no E.164 form, and even if you invented one, the policy is no.
So the TwiML refuses to dial them. Says so out loud, ideally.
It should say so out loud and early. If someone dials 100 through your dialler, the correct behaviour is not a busy tone and not a silent failure — it's "emergency numbers can't be dialled through this system, call 100 directly from your phone." Because the person dialling 100 is not in a state to debug your translation layer.
The failure mode there has a cost measured in minutes.
Minutes you don't have. And I want to underline the wording of the refusal, because it matters. You don't say "invalid number." The number is valid — it's just not dialable through you. If the message says invalid, the caller's next thought is "I typed it wrong," and they type it again. Every second of that retry loop is on the dialler's design. The message has to redirect to the phone in their hand, immediately, in plain language.
Here's the asymmetry that makes it a design problem rather than a rule, though. Twilio's US voice guidelines say the opposite: emergency calls in the US are allowed over Twilio. Same code path, opposite policy. So a dialler with one hard-coded emergency rule is wrong in one direction or the other — block 911 and you've broken a legal US call; allow 100 and you've broken an Israeli regulation. The emergency check has to be per-country policy, and Israel's is a hard no.
Same function, two countries, two answers.
And here's the part I'd love to test and can't from this desk: Twilio doesn't document what actually happens if you try anyway. An error code, a silent drop, a carrier rejection — nobody's published it. I don't know, and I'd want to find out the responsible way, with a test call to a non-emergency number in the same range, watching which error comes back.
You want to probe the fence without touching it.
I want to know where the fence is. There's a difference.
Something tells me you've already thought about which number to test with.
There's a difference between thinking about it and doing it, Corn, and I'd like the record to reflect that I'm still on the thinking side of that line.
So, US toll-free, which is Daniel's other case. And this one inverts the usual direction of the pitfall. If you're dialling plus 1-800-something from an ordinary Twilio US number — a local number, a mobile — that's supported. The toll-free prefixes in the North American plan are 800, 833, 844, 855, 866, 877 and 888. Outbound to toll-free is reachable. The restriction is on the other end of the call: a Twilio toll-free number is a bad originator.
The From, not the To.
The From. Twilio's own help material says toll-free numbers are designed for domestic inbound voice, and outbound calling is not supported. So if Daniel's dialler happens to run on a toll-free Twilio number — someone bought the 1-800 because it looks official — outbound calls will misbehave. The fix is simply to use a local number as the caller ID. Ordinary number in, toll-free out: fine. Toll-free in, anything out: broken.
A number built to receive calls, used to make them.
It's the phone equivalent of a postbox trying to drive. The other toll-free trap is geographic, and it's the one that'll bite an Israeli build. Dialling a US toll-free number from outside the US mostly just fails. People who've tried it from Asia report 1-800 and 1-888 calls not connecting at all — the number, quote, doesn't exist in that country. Which is true in a literal sense: those numbers only have meaning on the North American network.
So an Israeli user hears about a nice 1-800-FLOWERS line, dials it, and the translator does its job perfectly.
Perfectly. Plus one, eight hundred, the letters converted to digits, textbook E.164, validated, clean — and then the call dies at the carrier, not at Twilio. Your logs will show a correctly formatted number that simply doesn't complete. That's the case where I'd have the dialler recognise the toll-free prefix and warn: this number may not be reachable from Israel.
Translate it correctly and then tell them it probably won't work. That's an honest machine.
It's the difference between a formatter and a dialler. A formatter's job ends at the plus sign.
Hello dear, it's your mother, with Dororthy's History of Toast.
Sliced bread was first sold in July nineteen twenty eight, in Chillicothe, Missouri, on a machine built by Otto Rohwedder.
Though his first prototype and his plans had burned in a factory fire in nineteen seventeen, so you see, it does make you wonder.
Anyway, sweetheart, I'll let you get on. Have you had your lunch?
We've had lunch, Mum.
Toast counts, I assume?
It counted at the fire, it counts now.
The last layer, then, because it's the one that catches even people who build all of this correctly. There are gates that sit outside the translator entirely, and they'll still break the call. Voice Geo Permissions — Twilio restricts outbound calling to certain countries and number types by default, to protect the account from fraud. So a perfectly formed plus 972 number can still fail if the destination country isn't enabled on the account. Daniel's already calling Israel so presumably it is, but it's the first thing to check when a correct number doesn't connect.
The number was right and the permission said no.
Then caller ID, which is where I'd start any debugging in Israel. Israeli domestic outbound caller ID is listed as local, non-guaranteed. Whatever clean E.164 you send, the callee may see a local-format number or something else entirely. So if you ever wonder why your Twilio call shows up looking strange on an Israeli phone — start there, not at your TwiML.
People will spend a weekend in the translation layer over that.
A weekend, a rewrite, and a support ticket, and the answer was a row in a guidelines table marked non-guaranteed. There's one more tool worth naming for the toll-free question specifically — Lookup has a Line Type Intelligence add-on that tells you what the destination number is. Mobile, landline, fixed VoIP, non-fixed VoIP, toll-free. Worldwide coverage. That's the clean way for the dialler to detect it's about to call a toll-free destination and branch its behaviour — warn, block, whatever the policy says — rather than hard-coding prefix rules and hoping they stay current.
Ask the network what the number is, instead of guessing from its costume.
It's the same principle as the whole build, really. Every hard-coded guess has a shelf life; every question you can ask at runtime doesn't.
Fallback's the wrong word for it.
You've both been saying geographic fallback number. It's not a fallback. The 02 number is the moked. The 106 is the shortcut. Jerusalem's card says 02-531-4600, Tel Aviv's says 03-523-8888, and that's the desk, same people, same queue. Fallback sounds like it rings somewhere else.
You have cards.
Index cards. I keep them because I don't trust 106 to reach the right desk, and I don't trust a council website to still say the same thing next month. Herman, you said nobody's assembled the table. Somebody has. It's in a shoebox. Beit Shemesh has a card with 10622 on it, which is a speed dial for mobiles, and I wrote that on the card myself so I wouldn't argue with it later.
What order are they in?
By the colour of the municipality's logo. Jerusalem's cream and blue sits with the blues. Anyone can find their city faster that way than with your alphabet. I never dialled any of them through Twilio. I don't hold with the dispute being settled by a machine. The council here maintains that 106 is not an emergency line, and I maintain it is, and I'm not filing anything until the record's straight. I used to keep card indexes for a living, mind, so the system has some rigour behind it.
The record.
The shoebox. It's chronological by acquisition.
He knows which municipalities use 107 without looking, Corn.
That's the part I'd actually take from him, honestly — the area-code guess. A 02 Twilio number tells you where the number is, not where the person is. If the dialler asks the caller which city, it's one question once, and the short-code table gets the right row every time. Guess from the number and you'll be right until the one caller who's moved.
Or the one caller who borrowed the line.
And then the moked goes to the wrong city, and the wrong city's operator very politely transfers you, and you never learn anything. The cost of asking is one second per user, forever. The cost of guessing is a wrong call at the worst moment.
If you take one thing from this episode, take this: the translation layer is a policy engine wearing a regex's clothing. The regex is the weekend. The decisions — whose area code, which municipality, which country's emergency rules — are the actual product.
And the special numbers are where the bets get expensive. A wrong translation of an ordinary number fails loudly. A wrong decision about 106 or 100 fails politely, and nobody notices until it matters.
The open question I'd leave with Daniel is that undocumented one — what actually happens if you dial an Israeli emergency number through Twilio anyway. Error code, silent drop, carrier rejection. Twilio says no, and then says nothing about enforcement.
That's a test, not a guess. And it's the last cell in the table nobody's built.
I suspect Daniel builds it this week and we hear about it by Friday.
His dialler, the moked directory, and a Saturday afternoon — I'd put money on it.
Producer credit where it's due: Hilbert Flumingtop, at the desk, keeping the show on the air and the shoebox indexed.
And with that, If you enjoyed this one, try episode eighteen sixty-one, Emergency Prep You Can Sing To; episode forty-five sixty-nine, Dialing Without a Switchboard; and episode eight, Building Your Own Whisper. this has been My Weird Prompts. No question too obscure, no rabbit hole too deep.
If today went down well, the review button is right there wherever you listen, and it costs less than an index card.
We'll be back soon. See you then.