1

Instead of

client = TwilioRestClient(account_sid, auth_token)
message = client.messages.create(to="+12316851234", from_="+15555555555",
                                 body="Hello there!")

I'd like to use the "friendly name", such as "twilio 1".

message = client.messages.create(to="+12316851234", from_="twilio 1",
                                 body="Hello there!")
2
  • Try it and see what happens? I hate to state the obvious to an experienced SO citizen, but that is our usual standard: show the output of the given code. :-)
    – Prune
    Oct 21, 2015 at 23:03
  • I went through the documentation. Although there are a couple of references to letters allowed in phone number fields, I can't find a specific reference to a string alias.
    – Prune
    Oct 21, 2015 at 23:14

2 Answers 2

2

Twilio developer evangelist here.

You can do this... sometimes.

Twilio allows you to use an alphanumeric string as the sender ID for SMS messages. And you would do it exactly as you have shown, by setting the from parameter as the string. You do need to have an upgraded Twilio account, you can't use this on the free accounts.

However, it is only supported in about 145 countries and sadly, the US is not one of those countries.

I wrote up a blog post with more detail on how you do this. It is in Ruby, but I've not doubt you can follow along.

Edit

And re-reading the post shows that maybe I misunderstood here.

If you are trying to refer to the actual number to send by its friendly name, then that will not work. As I say above, using a string as the from argument will try to send the SMS using that string as an alphanumeric sender ID. It will not send the message from the number. If you are trying to send a message in the US this will then fail as you cannot send from an alphanumeric ID there.

To send a message from your Twilio number, you need to use the number itself as the from argument.

0

SMS generally does not have a "friendly name" or "string alias" or anything like that. The names that you see on a device come from the device owner's contact list, not the message. Here is a protocol reference: https://en.wikipedia.org/wiki/GSM_03.40

Although the protocol has evolved quite a bit, I don't think there are any plans to add this type of data, as the message is intended to be very compact.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.