When I first made a chatbot, I wanted to communicate to it by texting. First thing I did was google “texting python” and a bunch of articles using Twilio came up.
I was so excited that Twilio was well documented and easy to set up. But after a year they booted my free account. So here’s how to send text messages for free in Python.
To text in Python you don’t need much besides the standard libraries. We’ll use Python 3 and take advantage of the core libraries.
Did you know you can use email to send text messages? Yep!
- Verizon — <YOUR_NUMBER>@vzwpix.com
- ATT — <YOUR_NUMBER>@txt.att.net
And you can also send text’s to email addresses. Bye bye Twilio
We’re going to use Gmail to receive texts. First create an account.
Python Code — Github Link
I was hoping there would be a “emails” library, like requests (HTTP for Humans) but alas you have to do a bit of annoying stuff here. The good news is that the libraries are all included in Python.
The Email Libraries Suck
A lot of the code could be abstracted away. Someone maybe me should setup a simple email_client that can send AND RECEIVE emails.
The Original Chatbot, Joshua
I used the chatbot to tell me train schedules because I was so fed up with all the ads on the Chicago L monitors and Google was unreliable.
Could I have downloaded the CTA’s app like a normal person? Sure. But what fun is clicking an app->navigating to your line->your stop->and then seeing the schedule.
Wouldn’t a text “brown southport” be so much nicer? And if you wanted to remember your betting locks for the night, say “nba preds”? All from one location. So that’s what I made.
One Communication Platform to Rule them All?
I hope something emerges. Email looks like a good candidate with large device support but it has bad branding. And companies all want you on their platform (Facebook Messenger, phone network, facetime, twilio, skype, etc.)
Very high ranking post, How to Send SMS Text Messages with Python, from Full Stack Python is written by some guy who is the “Developer Evangelist @ Twilio.” but doesn’t add the disclaimer on his blog post. They do a damn good job of marketing over there, this is mildly shady though.