Skip to content

averille-demo/twilio-sms-api

Repository files navigation

Twilio Messaging API Demo

Python 3.12 License pre-commit Code style: black Checked with mypy Linting: Ruff

Send text messages programmatically with Twilio SMS API. Extract message history to JSON.

image

Update API Credentials:

# setup Twilio account
# update *_secret.toml file to include your API credentials and phone number
cp './config/twilio_sms_example.toml' './config/twilio_sms_secret.toml'

within './config/*_secret.toml':
[twilio.LIVE]
    account_sid = "123456789abcdefg"   # <-- UPDATE
    auth_token = "abcdefg123456789"

[twilio.digits]
  to_number = "+1222333444"    # <-- UPDATE
  from_number = "+1222333444"

Dependency Setup:

# update poetry
poetry --version
poetry self update

# use latest python version for venv
pyenv install --list | grep " 3.12"
pyenv install 3.12.0
pyenv local 3.12.0

# update poetry settings
poetry config virtualenvs.in-project true
poetry config virtualenvs.prefer-active-python true
poetry config experimental.new-installer false
poetry config --list

# create venv in project
poetry check
poetry lock

# upgrade pip within venv
poetry run python -m pip install --upgrade pip

# setup pre-commit
poetry run pre-commit autoupdate
poetry run pre-commit install

Run Demo:

poetry run python ./src/twilio_sms_api/twilio_rest_demo.py

Processing Steps:

  1. Send test SMS message with random text (+emoji strings) to validated 'to_number'
  2. Extract prior test message by string identifier (SID)
  3. Redact message body of test message
  4. Validate redaction results
  5. Delete prior test message
  6. Extract entire message history for account

Resources:

About

DEMO: send/retrieve text messages with Twilio SMS API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages