Skip to main content

WhatsApp message sender using WhatsApp Business API

Project description

whatsapp-messager is a Python library that makes it easy to send messages using WhatsApp's official API. This library is built to interact with the WhatsApp Business API, providing a simple way to send text messages and OTP messages.

Features

  • Send OTP messages via WhatsApp.

  • Send general text messages via WhatsApp.

Installation

You can install the library using pip:

pip install whatsapp-sender

Usage

To start using whatsapp-sender, you need to create an instance of the WhatsAppSender class with your access token, phone number ID, and version number.

Import and Setup

from whatsapp_messager.messaging import WhatsAppSender

# Initialize the WhatsAppSender
sender = WhatsAppSender(
    access_token="your_access_token",
    phone_number_id="your_phone_number_id",
    version_number="v15.0"  # Optional, default is v15.0
)

Send OTP Message

To send an OTP message:

response = sender.send_otp_message(recipient_phone_number="1234567890", otp="123456")
print(response)

Send Text Message

To send a text message:

response = sender.send_text_message(
    recipient_phone_number="1234567890",
    message="Hello from WhatsApp Sender!",
    country_code="+1"  # Include the appropriate country code
)
print(response)

Requirements

  • Python 3.7+

  • requests library

Error Handling

The library provides basic error handling and returns success or failure messages based on the API response. If an error occurs, the response will contain details about the failure.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Author

Contributing

Contributions are welcome! Please feel free to submit a Pull Request or open an Issue to improve the library.

Links

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

whatsapp_messager-0.0.4.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

whatsapp_messager-0.0.4-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file whatsapp_messager-0.0.4.tar.gz.

File metadata

  • Download URL: whatsapp_messager-0.0.4.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for whatsapp_messager-0.0.4.tar.gz
Algorithm Hash digest
SHA256 88c118a16df2dd7a46d8df0e82444373ceacb0f4eb7cd99a4f3bd97e0ebeab18
MD5 45a56e8ca5be10eed1413368c2b19f39
BLAKE2b-256 420a2e93fed8febaf8e6ed022600b387bc8e60cdc16d2c8ea037924aca364b98

See more details on using hashes here.

File details

Details for the file whatsapp_messager-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for whatsapp_messager-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5e4aac0c819ca82088ab8c54c2bb0cc031b02a30ff98504470d05d3bfc2e2f98
MD5 b677926bf151ba810b374e7890bd68e3
BLAKE2b-256 b392fc84004b57bb7faeb7b93e48fc06c730c442720139df4b1501aa095df304

See more details on using hashes here.

Supported by

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