how can I create a bulk sms code on twilio? Right now, I'm using Twilio Service api which can send up to 10k sms in 1 request. But I read that it only sends 1 sms per second so it means 10k messages means all will be sent after 3 hours.
Is it possible to do it like this on Twilio?
All of these should happen using Twilio API
Can create/delete lists that will identify the phone #.
Can add/delete phone numbers on the list.
Can request twilio to trigger a notification which will only ask for the list id instead of looping all phone numbers (which is the current way I'm doing it).
Currently im doing it like this:
$to = array();
$x = 0;
$message = 'Test';
foreach($phone_numbers as $phone_number){
$to[$x] = '{"binding_type":"sms", "address":"'.$phone_number.'"}';
$x++;
}
$notification = $client
->notify->services($service_id)
->notifications->create([
"toBinding" => $to,
"body" => $message
]);
If the phone numbers are more than 10k, it will not send all of them.
is there a way to make it like this?
the phone numbers are not stored on the database but instead stored on a list in twilio database then you will only need to call that list to send a message
also i can add multiple list which will identify what the notification is for
ex.
list #1 name is Room 1
list #2 name is Room 2
list #1 has phone number a, phone number b
list #2 has phone number a, phone number c
Twilio developer evangelist here.
The existing way you are using the bulk notifications API, by sending the numbers as part of the request, is just one part of the Twilio Notify API.
You can save numbers within Twilio and tag them as part of different lists. To do so, you need to create a binding. A binding is the connection of an identity and an address, in this case, the user's mobile number.
Notably though, this won't solve your delivery speed. There is a 1 message per second, per number limit when sending messages in the US to avoid carrier filtering. We also recommend you don't send more than 200 messages per day, per number to avoid the number being flagged for spam too.
Outside of the US things are less strict and the limit for sending messages is 10 per second, per number.
To overcome this you should either choose to use more numbers. If you are using Notify, then you are already using a messaging service with a number in the number pool. You can add more numbers to the number pool and the messaging service will distribute the messages between them. This will increase your throughput.
If you are sending that many messages in the US, then I would likely recommend using a short code. They are expensive, but they offer 100 messages per second throughput and, because they are more regulated, you don't need to use many different numbers.
Let me know if that helps at all.
Related
I am working on a project where I have a table data with Name,city,age,Phone Numbers and we have an Internal SMS API URL where the Phone numbers data which I have got has to send an SMS message by triggering the API URL by using POST method.
Let's Say I have 100 phone numbers in my table and the SMS has to be send to those 100 numbers one by one by using that API.
I have searched lot of articles but couldn't find my solution. So can anyone Kindly suggest how can I achieve it.
=> Get all Phone Numbers from db check Example.
=> Iterate all records using while loop .
=> Set all Phone Numbers to your API.
i'm working on an web app that has a message thread within and each time a new message is sent to a person a SMS is sent to that person, so what we want to do is to include the person's response to that SMS, lets say A sends a message to B, B receives both an email and a SMS, if B responses to A via the phone we need to be able to add that response to the thread. Is there a way to add additional information when you send a message using the API?
The sending SMS code looks like this:
$client = new Services_Twilio($accountSID,$authToken);
$sms = $client->account->messages->sendMessage("TwilioNumber",$toNumber,$message);
So, is there a way in which i could add some type of information to track this SMS thread, so when i get the response to the Request URL i could actually know that this message is being sent from B as a response from the message sent from A.
Thanks in advance.
Twilio evangelist here.
Unfortunately SMS does not have the idea of "meta-data" so there is nothing you can include that would tell you a message is in "response" to another message, but there are some solutions here.
You could create a convention of commands that are included in the actual body of the text message that tell you the message is ins response to a specific thread. But thats not super user friendly.
You're best bet is probably going to using multiple phone numbers and phone number tracking.
For example, when A sends the message to B you'll need to store both of their phone numbers along with the Twilio phone number that is receiving and relaying those messages. This allows you to map the two users together in a "thread" even though they are not directly texting each other.
But what happens when A wants to have seperate thread with both B and C? With a single Twilio phone number how do you know what thread to route their message to? The simplest way to allow this is to have multiple phone numbers. To send a message to B, A sends to 555-555-5555, to send a message to C, A sends to 555-555-6666. In this scenario you might think about buying a pool of numbers that you can draw from and recycle so you don't have to continuously buy new numbers.
Hope that helps.
I am using the Esendex Rest API http://developers.esendex.com/APIs/REST-API/inbox and I am trying to get all the messages in the inbox from a particular phone number.
This is basically so if I do a send out of SMS's and someone replies I am able to retrieve the reply.
I can currently get all the messages in the inbox into an array and sort them, but this is too slow with over 4000 messages.
Does anyone know if I can filter by phone number, or at least date-received in my API requests? Even if I could get the last weeks worth of SMS's.
You can try to use the conversation API if you want to filter by a phone number. The drawback is that you can get only the latest 15 messages, also that there is no reliable way to detect if a reply has been received from a phone number other than the inbox API. Apart from this I wasn't able to find anything that can help you. Their API is very restrictive and minimal.
There's currently no way to do this via the REST API but I'll see if we can add it over the next couple of weeks (I work for Esendex). As you note the functionality already exists in the Conversations API albeit in a more minimal form.
In the meantime you could achieve this by checking all messages that arrive either by polling the Inbox or using Push Notifications.
This specific example is using AT&T as the carrier of the receiver.
When sending SMS messages to clients via their carrier email address (1234567890#txt.att.net) from a static email address, the messages arrive on the phone from a number in the format of 1 (400) 000-244. Every time a new SMS message is sent, that number changes slightly. This causes phones, such as the iPhone, from properly threading the SMS messages that are coming from the same source email address.
Basic research shows that this has something to do with how AT&T's gateway handles turning emails into SMS messages. We've also looked at and decided that Common Short Codes (CSC) are not worth $1000 per month to purchase, so this is not an option for us.
Does anyone know of another way around this limitation in which it would be possible to force all SMS messages from the same source email to appear that way on the phone so that they are threaded correctly?
In our configuration, the emails are going out via SMTP using the PHP PEAR Mail_Mime package. We're really looking for a way we can do it on our end without the purchase of a shared or dedicated CSC.
Use:
<10 digit phone number>#mms.att.net
Instead of 'txt.att.net'
This will solve the short code dilemma.
For your AT&T issue they use a cluster model to send out SMS using the email gateway. To over come your problem there might be a couple of solutions but it all depends on what your needs are looks like they increment the phone number by one for each new message. Not sure how you could thread these.
Zeep Mobile lets you send SMS with a shared Short Code but they tag the end of your SMS message with ads, but the service is free (limited text per month I think)
Twilio might be a good cheap alternative as they offer such services. No short code but I believe they use the same From number for your threading issue.
Using your own GSM Modem could be an option but there is some work on getting this to work properly. Also it uses a Long Code (Think telephone number) instead of a Short Code.
There are a couple of other solutions so I will update my answer soon.
UPDATE:
Tropo
Google Voice
I currently have a php script that reads email messages sent from phones and then it posts them on the internet...
I want to do the same thing but instead of reading emails, I would like to process the data through a SMS.
so, if someone sends a sms to X number, my program would get the message through this X number and use it in the site.
What would I need?
You have a lot of options here. Generally speaking you need to first acquire the number that people can SMS to. Afterwards a callback will be issued to you when someone sends and SMS and your PHP script can process the message and figure out what to do with it.
You essentially have a few options for exposing the SMS
Go with a dedicated short-code. Eg someone sends a text to 53234 and you will get a callback to deal with it. This is an expensive option. It will cost you generally around $2500/mo minimum not including per messaging fees. You can requisition a short code through a provider such as Open Market. You have to get approval for the short code which might take as much as 6 weeks.
Go with a shared short code. This is a bit cheaper -- you pay per message and it usually costs anywhere from .02 - .10 /msg depending on your msg volume. You get a keyword such as DOLLY that people have to preface before texting. So they would text DOLLY INPUT TEXT HERE to 53234 now and you would receive the callback with INPUT TEXT HERE. Celltrust and others provide shared short codes.
Use a public api that allows people to text in through something such as TextMarks. Textmarks is like a shared short code requires keyword usage + users to subscribe. However it is free which is great and has a nice callback API. I believe a service called Mozes also provides similar service. Finally, if you want you can set up a Twitter account and have people text to their number. Facebook also a similar API that allows you to use their FBOOK shortcode.
Ish's answer was great. I'd like to point out an additional free option.
Most carriers allow you to send SMS messages to email addresses. The SMS text gets inserted into the body of the email and the subject is carrier dependent. Once the email is sitting in your inbox, you can access it by the method of your choice.
This method has worked for me in a personal project requiring remote communication with my computer when all I had was a cell phone without internet capabilities.
This Wikipedia page shows how many carries support this (practically all).
Just try not to violate anyone's terms of service, you could always host the email account yourself.