We are storing phone number to to send SMS to our customers but it is not in the e.164 format. Before I go back to our data team, is there a way to transform the phone numbers into the correct format within Customerio?
Reformat phone numbers within Customer.io?
Best answer by joecomotion
Hey Rachel,
If you’re only sending SMS to a maximum of one country or area code, then yes it’s possible to transform a phone number attribute to E.164 format!
To do so, you’ll create a campaign triggered by a segment which captures everyone who has the phone number attribute. Then in the workflow, you’ll have a create or update person block which updates their phone attribute. You’ll set the value of the attribute to liquid and use the following code:
{% assign x = customer.phone | replace:” “, “” | replace: “(”, “” | replace: “)”, “” | replace: “-”,‘’ %}
{% if x.size == 10 %} +1{{x}}
{% elsif x.size == 11 %} +{{x}}
{% elsif x.size == 12 %}{{x}}
{% endif %}
How this code works is it’ll remove all spaces, parentheses, and dashes and then it’ll add a +1 or + if needed.
The liquid example above is for US area codes, but you can modify it for your country. For example, if you send to France, you’d change +1 to +33, for example.
Once the create or update person action block is configured, then you can run the campaign to apply this update to everyone!
I hope this helps!
Reply
Login to the community
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.