A Python library for sending SMS, email and WhatsApp messages
Project description
TextTalk Communication Library
A Python library for sending SMS, email and WhatsApp messages. This package provides a simple and efficient interface for sending both individual and bulk messages across multiple communication channels.
Features
- Send individual and bulk SMS messages
- Send individual and bulk email messages
- Send individual and bulk WhatsApp messages
- Configurable through environment variables or direct configuration
- Comprehensive error handling
- Type hints for better IDE support
- Simple and intuitive API
Installation
- Clone the repository:
git clone <repository-url>
cd chat
- Install the required dependencies:
pip install -r requirements.txt
Configuration
You can configure the SMS client in two ways:
1. Using Environment Variables
Set the following environment variables:
export SMS_API_KEY='your_api_key'
export SMS_PARTNER_ID='your_partner_id'
export SMS_SHORTCODE='your_shortcode'
2. Using Direct Configuration
from sms import SMSConfig
config = SMSConfig(
api_key='your_api_key',
partner_id='your_partner_id',
shortcode='your_shortcode'
)
Usage
Basic Usage
from sms import SMSClient
# Using environment variables
client = SMSClient()
# Send a single SMS
success = client.send_sms(
to_number='+254713164545',
message='Hello from TextTalk!'
)
# Send bulk SMS
success = client.send_bulk_sms(
message='Hello from TextTalk!',
to_numbers=['+254713164545', '+254713164546']
)
With Custom Configuration
from sms import SMSClient, SMSConfig
config = SMSConfig(
api_key='your_api_key',
partner_id='your_partner_id',
shortcode='your_shortcode'
)
client = SMSClient(config)
Error Handling
The library provides custom exceptions for better error handling:
from sms import SMSClient, SMSException, ConfigurationError, MessageError
try:
client = SMSClient()
client.send_sms(to_number='+254713164545', message='Hello!')
except ConfigurationError as e:
print(f"Configuration error: {e}")
except MessageError as e:
print(f"Message error: {e}")
except SMSException as e:
print(f"General SMS error: {e}")
API Reference
SMSClient
__init__(config: Optional[SMSConfig] = None)
Initialize the SMS client with configuration.
send_sms(to_number: str, message: str) -> bool
Send a single SMS message.
Parameters:
to_number(str): The recipient's phone numbermessage(str): The message content
Returns:
bool: True if the message was sent successfully
send_bulk_sms(message: str, to_numbers: List[str]) -> bool
Send SMS messages to multiple recipients.
Parameters:
message(str): The message contentto_numbers(List[str]): List of recipient phone numbers
Returns:
bool: True if the messages were sent successfully
SMSConfig
Configuration class for managing API credentials and settings.
Parameters:
api_key(Optional[str]): API key for authenticationpartner_id(Optional[str]): Partner ID for the serviceshortcode(Optional[str]): Shortcode for sending messages
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file texttalk-0.0.5.tar.gz.
File metadata
- Download URL: texttalk-0.0.5.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f16f45ec3a43aa9be766ba1d5dda508d4df51977fcfd8c96ca505dd441546e0
|
|
| MD5 |
ca2aee415357377fffb5b57eeb348227
|
|
| BLAKE2b-256 |
7793883a72a5c57a59a6296168444f8c28fa3385016ed506e42f9aa5c0ec6f51
|
Provenance
The following attestation bundles were made for texttalk-0.0.5.tar.gz:
Publisher:
release.yaml on thaka-creations/chat
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
texttalk-0.0.5.tar.gz -
Subject digest:
8f16f45ec3a43aa9be766ba1d5dda508d4df51977fcfd8c96ca505dd441546e0 - Sigstore transparency entry: 192994169
- Sigstore integration time:
-
Permalink:
thaka-creations/chat@46dda61e1a0e7b23216907479c698d0810f6922b -
Branch / Tag:
refs/tags/0.0.5 - Owner: https://github.com/thaka-creations
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@46dda61e1a0e7b23216907479c698d0810f6922b -
Trigger Event:
push
-
Statement type:
File details
Details for the file texttalk-0.0.5-py3-none-any.whl.
File metadata
- Download URL: texttalk-0.0.5-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce1b0d56cefddba8e94efaa5ec1092ce564192c627e027850ae2ae370dfb44b3
|
|
| MD5 |
aa70b26da7aceaa526266327f0810ec1
|
|
| BLAKE2b-256 |
38c0c5fc751becee6910607de655fc2f7be5986e025c3520ce4e638fdc60d5a9
|
Provenance
The following attestation bundles were made for texttalk-0.0.5-py3-none-any.whl:
Publisher:
release.yaml on thaka-creations/chat
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
texttalk-0.0.5-py3-none-any.whl -
Subject digest:
ce1b0d56cefddba8e94efaa5ec1092ce564192c627e027850ae2ae370dfb44b3 - Sigstore transparency entry: 192994170
- Sigstore integration time:
-
Permalink:
thaka-creations/chat@46dda61e1a0e7b23216907479c698d0810f6922b -
Branch / Tag:
refs/tags/0.0.5 - Owner: https://github.com/thaka-creations
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@46dda61e1a0e7b23216907479c698d0810f6922b -
Trigger Event:
push
-
Statement type: