Skip to main content

A lightweight Python utility that simplifies sending WhatsApp messages using the Twilio API. It provides built-in credential validation and a clean interface for sending messages, making it easy to integrate into alerting systems, bots, and automation scripts.

Project description

📲 TwilioHelper

TwilioHelper is a lightweight and reliable Python wrapper around Twilio's WhatsApp API, designed for quick integration and automated messaging. It provides built-in credential validation and error handling out of the box, making it ideal for alerting systems, notification bots, and automation workflows.


🔧 Features

  • Credential Validation – Automatically validates Account SID and Auth Token during initialization.
  • 📤 WhatsApp Messaging – Send WhatsApp messages in just one function call.
  • Robust Error Handling – Handles common Twilio exceptions gracefully with meaningful feedback.

🚀 Installation

Install the Twilio SDK (if not already installed):

pip install twilio

🧪 Getting Started

  1. Activate Twilio Sandbox for WhatsApp: Visit https://www.twilio.com/console/sms/whatsapp/learn to enable your sandbox and verify your recipient phone number.

  2. Gather Credentials:

    • Account SID
    • Auth Token
    • From Number (typically whatsapp:+14400000000 for sandbox)
    • To Number (your verified number, e.g., whatsapp:+919900000000)

📦 Usage

from twilio_helper.main import TwilioHelper

# Initialize the helper
helper = TwilioHelper(account_sid="your_account_sid", auth_token="your_auth_token")

# Send a WhatsApp message
response = helper.send_whatsapp_message(
    message="Battery is 90%, please unplug.",
    from_number="whatsapp:+14400000000",
    to_number="whatsapp:+919900000000"
)

print(response)  # Example output: {'message_sid': 'SMXXXXXXXXXXXXXXXXXXXX'}

🛡 Error Handling

TwilioHelper raises clear, descriptive exceptions for:

  • Invalid Twilio credentials – Prevents initialization if credentials are incorrect.
  • Failed message send – Errors from invalid numbers, message content, or connectivity are caught and reported.

🧾 License

This project is licensed under the MIT License.


👨‍💻 Author

Built with ❤️ by Lav


📬 Contributions & Feedback

Feel free to open issues or PRs to improve functionality, add support for SMS or other Twilio services, or enhance testing.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

twilio_helper-0.1.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

twilio_helper-0.1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file twilio_helper-0.1.0.tar.gz.

File metadata

  • Download URL: twilio_helper-0.1.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.9.22 Linux/6.11.0-1012-azure

File hashes

Hashes for twilio_helper-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9ccf230ba3160eb3dfd98bcbce99b70964ff582af2ae1ef1ec8275516fda45ea
MD5 3acd7eaf2a15feb15acd4f5d4c338014
BLAKE2b-256 8c0e13716f751b30823060de21a7e09d96d1df950b8087e1f2e9299008431eb3

See more details on using hashes here.

File details

Details for the file twilio_helper-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: twilio_helper-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.9.22 Linux/6.11.0-1012-azure

File hashes

Hashes for twilio_helper-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ea78fddbaad7370a7b593b5c6617ce9d30d46192bb37c36579f48bd23b2406a8
MD5 aefd0f807b37b7cc2d04c26f1571e57a
BLAKE2b-256 9cd5d4967c9c21743f4d07caf5cc0eba6688db8ab7f343bc11b6c43a452c7b57

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page