You can automate sending out SMS messages with any language.
Python perennially tops the list of popular languages, so let’s look at how to
The trick isn’t so much the language you use to send text messages, but rather the API you employ.
Sure, theoretically you could write code from scratch that accepted text, formatted it for SMS, and forwarded it to a telecom provider. Fifteen years ago, maybe you would have done just that, but thanks to cloud service providers, nobody needs to do that anymore.
Today we have dozens of cloud communications platforms that offer application programming interfaces (API) that anyone can use to add text messaging to applications quickly.
An SMS API lets developers integrate sending and receiving text messages with their existing applications. On the back end, it communicates with a communications platform that interfaces with the telecommunications networks and does the actual processing of messages.
To see how it works, we looked at Plivo’s
To get started, sign up for a free Plivo account and use the free credits provided to lease a phone number with which to send and receive messages.
Plivo’s documentation provides instructions on
You don’t need Flask or ngrok to send SMS messages, but if you plan to receive them, you’ll need to use tools like these.
Now you can dive right into coding. Create a file called send_sms.py and paste into it this code.
Replace the auth placeholders with the authentication credentials for your account, which you can find on the front page of the Plivo console.
Replace the phone number placeholders with actual phone numbers in E.164 format (for example, +12025551234). Pick your own mobile number as the destination so you can see the code in action. Then save the file.
import plivo
client = plivo.RestClient('<auth_id>','<auth_token>')
response = client.messages.create(
src='<sender_number>',
dst='<destination_number>',
text='Hello, world!',)
print(response)
Now run the program.
$ python send_sms.py
You should receive a “Hello, world!” message on your phone.
Of course this example is about as simple as they come.
You can imagine more complex scenarios — looking up a customer’s phone number and sending them an appointment reminder, for example, or sending someone a security code they can use for two-factor authentication.
However you use it, integrating SMS with your Python applications is simpler than you might have imagined. Text messaging opens up all kinds of opportunities for businesses. There’s no time like the present to use SMS to give your business a competitive advantage.