ClosDesign
ClosDesign

Reputation: 3924

Can Twilio collect phone numbers to send SMS at a later date? C# code examples?

Does Twilio have the ability to collect FROM numbers in a "bank" so we can send text messages at a later date. More or less like an opt in form.
We are building a form to collect phone numbers of people who want to opt in to receive text messages. What would be the best way to do this? Does Twilio store phone numbers? Or do we have to collect the phone numbers in a database and send the phone numbers through our service call to Twilio to send the phone numbers to send the text messages to.

Our application is using C#.

I have found code examples on how to send text messages from C# only to a static number, but nothing with a DB of numbers or collection of numbers.
I was just wondering if there were any good examples of how to do this and send Twilio the list of phone numbers to send the text message to.

Upvotes: 0

Views: 576

Answers (2)

WindedHero
WindedHero

Reputation: 185

I suggest you collect the numbers in a separate database so that people who submit their number can also request it to be removed, and so that you can manage it on your end instead of theirs. I don't believe twilio has any method of storing lists of phone numbers yet, nor do they intend to. The flexibility of their system is to your advantage in that aspect.

For sending mass texts, your best bet is to do a for or while loop and send a request to their API for each number. The API only supports sending an sms to a single phone number per request, and does not currently support "short code" phone numbers.

Upvotes: 0

Devin Rader
Devin Rader

Reputation: 10366

Twilio evangelist here.

In your scenario you would need to store those phone numbers, then make a call to our REST API for each phone number you want to send your message to:

var client = new TwilioRestClient("[YOUR_ACCOUNT_SID]", "[YOUR_AUTH_TOKEN]");
foreach(var number in yourDatabase.PhoneNumbers) {
    client.sendMessage("[YOUR_TWILIO_PHONE_NUMBER]", number, "[MESSAGE]");
}

Hope that helps.

Upvotes: 1

Related Questions