Thursday, October 31, 2019

Send SMS from Python

1) Create a trail account on https://www.twilio.com/try-twilio
2) Install the Twilio Python client library:

pip3 install twilio

3) Send SMS
Complete Python Code

from twilio.rest import Client

# Twilio account details
twilio_account_sid = 'Your Twilio SID here'
twilio_auth_token = 'Your Twilio Auth Token here'
twilio_source_phone_number = 'Your Twilio phone number here'

# Create a Twilio client object instance
client = Client(twilio_account_sid, twilio_auth_token)

# Send an SMS
message = client.messages.create(
    body="This is my SMS message!",
    from_=twilio_source_phone_number,
    to="Destination phone number here"
)

No comments: