• Instructions to Ask a Question

    Click on the "Ask a Question" button and select the application for which you would like to ask questions.

    We have 5 different products namely - Pabbly Connect, Pabbly Subscription Billing, Pabbly Email Marketing, Pabbly Form Builder, Pabbly Email Verification.

    The turnaround time is 24 hrs (Business Hours - 10.00 AM to 6.00 PM IST, Except Saturday and Sunday). So your kind patience will be highly appreciated!

    🚀🚀Exclusive Discount Offer

    Just in case you're looking for any ongoing offers on Pabbly, you can check the one-time offers listed below. You just need to pay once and use the application forever -
     

    🔥 Pabbly Connect One Time Plan for $249 (🏆Lifetime Access) -  View offer 

    🔥 Pabbly Subscription Billing One Time Plan for $249 (🏆Lifetime Access) - View offer

Help with Country Code for WhatsApp API (AiSensy)

jhashank

Member
Your Task History ID
IjU3NjIwNTZiMDYzMzA0MzE1MjZlNTUzMjUxMzI1MTY3NTQzMSI_3D_pc
Workflow Link / ID : https://connect.pabbly.com/workflow...ZADhfS1dTAVcEd1NKBDhRUgZ8BktVZlAZCzgBX1Z-AmM#

I run Paid Lead generation ADs on Facebook / Instagram and LinkedIn and have used Pabbly to create a workflow as below :

Step 1 : Add new leads to Google Sheets & MailChimp for Automated Drip Mail Sequence (working fine, no issue)

Step 2 : After a slight delay, send SMS (via Textlocal) and WhatsApp (via AiSensy) to these prospective buyers and this is where I have a small problem.

The problem is that while entering their details in the Lead Ad forms on FB / IG / LinkedIn, some people forget to enter the country code and type in their mobile numbers without the country code.

Sometimes they type in the country code with a "+" symbol and sometimes without it.

Sometimes there could be a gap in numbers as well, such as +91 99999 99999 or +91 9999999999 etc

AiSensy sends out a WhatsApp message ONLY WHEN the number is entered WITHOUT GAPS and with the proper country code and a "+" symbol in the beginning.

So when the country code is not present, just the mobile number with a "+" sign gets passed onto AiSensy which then fails to send a message saying "Invalid Number".

I am able to sort out the above 2 problems using Text Formatter by first removing all non-numerical characters so I get just the number without any gaps or symbols and later map the value with a manual "+" sign to ensure the output is as +919999999999 as this is the way AiSensy accepts numbers.

Incase someone has not entered country code at all, I have also seen another article where the CONCATENATE function takes the last 10 digits of a given number and then adds the country code which is a good way to handle most of the issues.

However the above CONCATENATE option works ONLY IF all the numbers are of a SINGLE COUNTRY i.e. all numbers are of India as this way, we can blindly add +91 and it will work as intended.

However the problem here is that we have people responding even outside of India (NRIs who were previously in India but currently reside abroad) and in such a case, they may give us their USA number or UK number etc.

This means we cannot simply add +91 to all numbers, as then non-India numbers will get modified incorrectly and not work on AiSensy and other apps.

For this, I saw this article where some Javascript was used to identify which country the number belongs to and then adds the corresponding country code IF the country code is already not present. Here is the link to this article : https://forum.pabbly.com/threads/split-text-phone-number.15694/

What I need help with is a way to separate the country prefix from the rest of the phone number - and then clean up any zeroes in the beginning and remove any gaps in the mobile number - and finally add back the country code with a "+" sign in the beginning as this is the only way to get the AiSesny Whatsapp function to work successfully :

But then countries have prefixes with different numbers of characters:

+1 (1 character) Ex: USA

+44 (2 characters) Ex: United Kingdom

+966 (3 characters) Ex: Saudi Arabia

+1876 (4 characters) Ex: Jamaica

Can you help with the same JS Script as shown below in below example for my workflows as well?

Example Link : https://forum.pabbly.com/threads/split-text-phone-number.15694/

You can add any new steps BEFORE the 6th step in my workflow :
 
P

Pabblymember11

Guest
However the problem here is that we have people responding even outside of India (NRIs who were previously in India but currently reside abroad) and in such a case, they may give us their USA number or UK number etc.

This means we cannot simply add +91 to all numbers, as then non-India numbers will get modified incorrectly and not work on AiSensy and other apps.

For this, I saw this article where some Javascript was used to identify which country the number belongs to and then adds the corresponding country code IF the country code is already not present. Here is the link to this article : https://forum.pabbly.com/threads/split-text-phone-number.15694/

What I need help with is a way to separate the country prefix from the rest of the phone number - and then clean up any zeroes in the beginning and remove any gaps in the mobile number - and finally add back the country code with a "+" sign in the beginning as this is the only way to get the AiSesny Whatsapp function to work successfully :

But then countries have prefixes with different numbers of characters:

+1 (1 character) Ex: USA

+44 (2 characters) Ex: United Kingdom

+966 (3 characters) Ex: Saudi Arabia

+1876 (4 characters) Ex: Jamaica

Can you help with the same JS Script as shown below in below example for my workflows as well?

Example Link : https://forum.pabbly.com/threads/split-text-phone-number.15694/

You can add any new steps BEFORE the 6th step in my workflow :
You can refer to the following shared workflow where we have implemented the same Code logic to get the country code.

I hope this might probably work for you - https://connect.pabbly.com/workflow...YV2wPGwsPVwFSIV1EU39TUFMpUB1ULwBNDD9cAlZ-Xz4#
 
Top