Send text messages programmatically with Twilio SMS API. Extract message history to JSON.
# 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"
# 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
poetry run python ./src/twilio_sms_api/twilio_rest_demo.py
- Send test SMS message with random text (+emoji strings) to validated 'to_number'
- Extract prior test message by string identifier (SID)
- Redact message body of test message
- Validate redaction results
- Delete prior test message
- Extract entire message history for account