Home > database >  How to deal with differences in Phone Numbers using Twilio?
How to deal with differences in Phone Numbers using Twilio?

Time:03-16

Tools

Django - Twilio WSP API

Context

I send a message to my own number as 54 9 (1234) 123456

But when I answer back Twilio receives the msg from 54 (1234) 123456

Problem

If I save " 54 9 (1234) 123456" in the database and receive validation from " 54 (1234) 123456" I can't get a match to verify.

CodePudding user response:

This is an interesting problem! I had to go do some research on Argentinian numbers to see what was happening here.

According to Wikipedia:

To send an SMS text message to an Argentine cell phone from another country, the 9 used internationally when dialing the number for a voice call (and the 15 used for calls within Argentina) is omitted. For example, if the mobile number in Argentina is (11) 15 1234–5678, a voice call from abroad would be dialled as 54 9 11 1234 5678, but a text message would require 54 11 1234 5678, with 54 9 11 1234 5678 usually being invalid. If a text message is received from Argentina, the reply can be sent to the number displayed as the sender. Not all mobile providers in Argentina have SMS agreements with every carrier in the world, so it may not be possible to send an international SMS.

It seems that when Twilio receives a message from an Argentinian number it will do without the 9. It might be best for you to store the number in both forms (with and without the 9) in your database, so you can use it to send and receive messages.

I don't have a real Argentinian mobile number to test with, but you might find that the Twilio Lookup API can help you format numbers.

  • Related