John Moran
John Moran

Reputation: 27

Twilio phone number management / architecture

Hi I'll keep this as short as possible.

I'm running through designing a international Twilio SMS system. I understand you can purchase / delete numbers 'on the fly' using the API, and also list your currently purchased numbers using area code as a filer.

My question is given I want pay local rate text charges to send / reply, what's the most cost effective way of managing phone numbers when my new system will have a small amount of international users (initially at least)? I noticed toll free isn't available in the UK- my main user base...

My rough idea is to first off generate a local SMS number for the user in a given country, then next time that country is sent from check if we have an existing number and if so use it, if not purchase a new one, both with the API.

The problem here is that obviously I'll need to clear out numbers that haven't been used for say a month, (to keep prices down / within the Twilio monthly charge), not sure how I can do that except to store in our database....)

So is this the way the API is intended to be used? ie purchase numbers on the fly, on a monthly basis and if used again within that time keep the existing number, if not purchase a new one? My emphasis is on keeping costs down...

Or have I totally missing the point and it's maybe possible to get an international number and send a one off SMS without having to purchase the number for a month?

Any advice you have on the best layout for this system would help, or guides on similar systems.

Upvotes: 1

Views: 407

Answers (1)

Marcos Placona
Marcos Placona

Reputation: 21720

Hi Twilio developer evangelist here.

I will try to break your questions down.

given I want pay local rate text charges to send / reply, what's the most cost effective way of managing phone numbers when my new system will have a small amount of international users (initially at least)? I noticed toll free isn't available in the UK- my main user base...

If you are just sending messages, you may opt for just buying a number, and using that number to send all your messages. this will lower the cost of having to buy local numbers. However, if your users need to reply, then it would be beneficial (to your customers) that you used local numbers as they won't have to pay for international charges to reply. The prices to send messages from each country to each country can be seen here. As an aside we do have toll free for voice in the UK.

My rough idea is to first off generate a local SMS number for the user in a given country, then next time that country is sent from check if we have an existing number and if so use it, if not purchase a new one, both with the API.

This sounds about right, but to keep track of wether a number has been used or not, you will have to store that somewhere. My suggestion would be to use something like a StatusCallback that will notify you every time a number is used. That way, you can query your database everyday and check whether a number has not been used in the last 30 days, and then delete it via the REST API.

The problem here is that obviously I'll need to clear out numbers that haven't been used for say a month, (to keep prices down / within the Twilio monthly charge), not sure how I can do that except to store in our database....)

That is correct (as stated on my previous comment). Storing this information on a database will make it much easier for you, and will give you the ability of being smarter about when to release numbers. If you don't want to pay the monthly fee for a number and then release it on the next day because it's now 30 days old, you can choose to have some logic on your code that will check for the likelihood of a number being used on say.. the next week.

So is this the way the API is intended to be used? ie purchase numbers on the fly, on a monthly basis and if used again within that time keep the existing number, if not purchase a new one? My emphasis is on keeping costs down...

This will vary, but most people tend to keep the numbers instead of releasing them. This way you have a number that is yours, and if you decide to contact your users again, you will be contacting from the same number, and the previous messages sent will be nicely threaded. You may upset users by sending messages from different numbers all the time, so ideally I'd say keep the numbers if you can.

Upvotes: 1

Related Questions