Twilio is a web application programming interface (API) that software developers can use to add communications such as phone calling, messaging, video and two-factor authentication into their Python applications.
Interacting with the standard telephone networks to send and receive phone calls and text messages without Twilio is extremely difficult if you do not know the unique telecommunications protocols such as Session Initiation Protocol (SIP). Twilio's API abstracts the telecommunications pieces so as a developer you can simply use your favorite programming languages and frameworks in your application. For example, here's how you can send an outbound SMS using a few lines of Python code:
# import the Twilio helper library (installed with pip install twilio) from twilio.rest import TwilioRestClient # replace the placeholder strings in the following code line with # your Twilio Account SID and Auth Token from the Twilio Console client = TwilioRestClient("ACxxxxxxxxxxxxxx", "zzzzzzzzzzzzz") # change the "from_" number to your Twilio number and the "to" number # to any phone number you want to send the message to client.messages.create(to="+19732644152", from_="+12023358536", body="Hello from Python!")
Learn more about the above code in the How to Send SMS Text Messages with Python tutorial.
Twilio is a developer-focused company, rather than a traditional "enterprise company", so their tutorials and documentation are written by developers for fellow developers.
Most Twilio Tutorials have idiomatic Python versions with entire open source applications in Django and Flask.
Automate the Boring Stuff with Python includes a chapter on sending text messages that uses Twilio to get the job done.
Build a Simpsons Quote-Bot with Twilio MMS, Frinkiac, and Python combines picture messages sent via Twilio MMS with Frinkiac to create and sent Simpsons cartoon quotes to any phone number.
Finding free food with Python is a fun web scraping tutorial that uses Beautiful Soup 4 to obtain some data from websites then uses the Twilio SMS API via some Python code to send a text message with the results.
The Python tag on the Twilio blog provides walkthroughs for Django, Flask and Bottle apps to learn from while building your own projects.
Serverless Phone Number Validation with AWS Lambda, Python and Twilio walks through using the Python runtime on AWS Lambda and Twilio's APIs for validating phone number information.
Receive Flask Error Alerts by Email with Twilio SendGrid shows how to use Twilio to add email error reports to Flask web applications.
Google Cloud recommends developers use Twilio for communications in their apps and provides a short walkthrough for Python developers.
SMS Tracking Notifications is a fun tutorial that combines two APIs together - Twilio and Easypost to track packages sent through the Easypost service. There is also another tutorial on shipment notifications specifically for Flask.
This video titled "We're No Strangers to VoIP: Building the National Rick Astley Hotline)" presents a hilarious hack that uses Python and AWS Lambda as a serverless backend to power thousands of Rick Rolling calls in several countries with Twilio.
Stripe SMS Notifications via Twilio, Heroku, and Python is a quick tutorial that demonstrates how to combine multiple services to receive helpful notifications via SMS.
I currently work at Twilio on the Developer Network and run the Developer Voices team.