How to handle telephone numbers starting with zeros, like 00483

Hi, I have scenario where I get telephone number information from the voiceflow chatbot to webhook, then it is sent to Google Sheets Add a Row module and then to Text Parser to convert it to text, then it goes to Set Variable module where I want to edit this number into format accepted by Twilio (+421908123456).


The customers might leave the telephone number in different formats (00421 0908 123 456, 0908 123 456, 908 123 456 etc), so I first created regex [\s-()] in Text parser to remove spaces etc, and then I set the function in the Set Variable module to create the format accepted by Twilio:
{{if(contains(toString(4.text); β€œβ€β€œ+421"β€β€œ) & length(toString(4.text)) = 13; toString(4.text); if(contains(toString(1.phone); β€œβ€˜00421’”) & length(toString(1.phone)) = 14; β€œβ€β€+421"" & " + slice(toString(1.phone); 5); if(contains(toString(1.phone); β€œβ€˜0’”) & length(toString(1.phone)) = 10; β€œβ€β€œ+421"” & " + slice(toString(1.phone); 1); if(length(toString(4.text)) = 9; β€œβ€β€œ+421"” & " + toString(4.text); β€œβ€β€œNo matching patternβ€β€œβ€))))}}

However, it does not work. It works only if I get the number from the Text parser in the format 908123456, but all the other variants are not matched by the condition in the function and β€œNo matching pattern” is placed into the variable instead of the formated number +421908123456. It seems that the zeros at the beginning of the number cause the problem, and even though the number is converted into text in the Text parser, and even though it is mapped via toString in Set Variable module, it still does not help. Can you help me set this right and explain what is wrong here?

Hey Michal,

try with the Parse a Phone Number module. It will check if a number is valid and return the number in several different standardized formats.

Hello Stoyan,
Thank you for the solution - yes, it works perfectly. I did not know such a module exists. Still, out of curiosity, I would be interested to know if there is a way to write a conditional function to adjust numbers which start with zeros to the desired format.

Welcome to the Make community!

You can do this using the built-in function replace.

For more information, do view these similar questions previously asked by other community members, which may answer your question:

Next time, please try to search this forum first for existing answers. This may help you get to the solution faster, and also help keep the forum organised. Thanks for your cooperation!

Hope this helps! Let me know if there are any further questions or issues.

β€” @samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

1 Like