Definition
A third-party module and cloud service that allows Python programs to send and receive text messages (SMS) and phone calls.
Why It Matters
Twilio democratized global communication. It allowed software developers to programmatically send and receive SMS and voice calls, turning the ‘physical’ world of telecommunications into a simple API call, enabling the modern era of notification-driven apps.
Core Concepts
- Auth Model: Requires an Account SID and an Auth Token provided by the Twilio dashboard.
- Sending Messages:
from twilio.rest import Client client = Client(account_sid, auth_token) message = client.messages.create( body='Text body', from_='+123456789', # Your Twilio number to='+987654321' ) - Cost: Unlike email, SMS carries a per-message or subscription cost.
- Direct I/O: Acts as a bridge between high-latency manual communication (phones) and low-latency automated logic.