Skip to main content

Pygwan

Unofficial Python wrapper for the WhatsApp Cloud API by Tarmica Chiwara.

Installation

To install the WhatsApp Python wrapper, use the following command:

pip install pygwan

Usage

Import the WhatsApp class from the package and initialize an instance with your WhatsApp token and phone number ID:

from pygwan import WhatsApp

whatsapp = WhatsApp(token="your_token", phone_number_id="your_phone_number_id")

Sending a Message

You can send a text message to a WhatsApp user using the send_message method:

whatsapp.send_message("Hello, this is a test message.", "recipient_phone_number")

Replying to a Message

Reply to a message using the reply_to_message method:

whatsapp.reply_to_message("message_id", "recipient_phone_number", "Reply message.")

Sending a Template

Send a template message using the send_template method:

components = [
    # List of template components
    # Example: {"type": "text", "text": "Hello, this is a template message."}
]
whatsapp.send_template("template_name", "recipient_phone_number", components)

Sending a Location

Send a location message using the send_location method:

whatsapp.send_location("-23.564", "-46.654", "Location Name", "Location Address", "recipient_phone_number")

Sending an Image

Send an image message using the send_image method:

image_link = "https://example.com/image.jpg"
whatsapp.send_image(image_link, "recipient_phone_number")

LATEST NOTES:

Here's what changed and why: The rabbit 🐇 — human_reply

wa.human_reply(message_id, "263779281345", "Sure, let me check that for you!")
  • One call does: read receipt → typing bubble → 1.5s pause → reply. Your bot instantly feels like a person. For even more realism, use a length-aware delay:
delay=len(response_text) * 0.03  # ~30ms per character

Template improvements

wa.send_simple_template("hello_world", "263779281345")           # static templates

wa.send_flow_template("agentd", "263779281345")                  # flow templates, zero config

wa.send_flow_template("onboarding", "263779281345",              # flow + variables
    body_variables=["Alice"], flow_token="sess-123")
  • TemplateComponents builder for anything more complex — chainable, readable, no raw dicts:
components = (
    TemplateComponents()
    .add_header("Invoice #1023")
    .add_body("Alice", "shipped")
    .add_flow_button()
    .add_quick_reply_button("CONFIRM")
    .build()
)
wa.send_template("order_update", "263779281345", components)
  • Also quietly fixed:

send_templatev2 was calling send_template without self, get_message now also handles list_reply, and create_button is kept as an alias so nothing breaks.

For more detailed usage and information, please refer to the official documentation in the code lol

License

This project is licensed under the MIT License.

Metadata

Release files for pygwan 0.3.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pygwan 0.3.6
File Size Uploaded Provenance Actions
pygwan-0.3.6.tar.gz 21.6 kB Without provenance Details for pygwan-0.3.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pygwan 0.3.6
File Interpreter ABI Platform Actions
pygwan-0.3.6-py3-none-any.whl Python 3 none any Details for pygwan-0.3.6-py3-none-any.whl

Total release size: 42.6 kB

Release files / pygwan-0.3.6.tar.gz

Download URL pygwan-0.3.6.tar.gz
Size 21.6 kB
Tags Source
SHA-256 checksum
How to use checksums
21e199b0d0ca4893af6f8600f04dfe676fb557b572288a2868a5274cfed3c162
BLAKE2b-256 checksum
How to use checksums
61dba047027a0d494e1a7f960d2444dfac18d7c1dbafb0a97cf54d21d2f9b080
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.4

Release files / pygwan-0.3.6-py3-none-any.whl

Download URL pygwan-0.3.6-py3-none-any.whl
Size 21.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b4290288d804321a3e1aeeb7851ce9681ba808f2d798f461bb213e840a07d472
BLAKE2b-256 checksum
How to use checksums
3189ebdd2686a322ea40131311ca9cd78f466d40b87a1c7a4761e58f3900167e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.4

Security for pygwan 0.3.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page