Skip to content

Releases: david-lev/pywa

4.0.0b6

25 Apr 21:00
3559a79

Choose a tag to compare

4.0.0b6 Pre-release
Pre-release

What's Changed

Update with pip: pip install -U pywa --pre
Updated Docs: pywa.readthedocs.io/en/dev/

Caution

Make sure to read the migration guide before updating to this version!

  • [client] add run method to start the webhook server and listen for updates
  • [server] refactor webhook handling to include validation and improve endpoint management
  • [user] make profile temporary optional for testing
  • [utils] add start_ngrok_tunnel function to facilitate local webhook testing
  • [templates] enhance duplicate method to include target_waba_id parameter for template creation
  • [templates] add validation for URL variables in URLButton to enforce constraints on example and variable usage

Full Changelog: 4.0.0b5...4.0.0b6

4.0.0b5

17 Apr 11:10
7748ca3

Choose a tag to compare

4.0.0b5 Pre-release
Pre-release

What's Changed

Update with pip: pip install -U pywa --pre
Updated Docs: pywa.readthedocs.io/en/dev/

Caution

Make sure to read the migration guide before updating to this version!

  • [client] add methods for creating and verifying phone numbers on WhatsApp Business Account
  • [templates] enhance Template and TemplateDetails with new methods for component retrieval and validation
  • [templates] add param_names property for introspection of named parameters
  • [templates] enhance error handling for positional and named examples in HeaderText and BodyText
  • [templates] enhance CreativeFeaturesSpec with new attributes for improved media handling and text optimization
  • [templates] remove TemplateSubCategory class and update sub_category type to string
  • [message] fix reply to message in EditedMessage and DeletedMessage

Full Changelog: 4.0.0b4...4.0.0b5

4.0.0b4

11 Apr 19:42
22edc3c

Choose a tag to compare

4.0.0b4 Pre-release
Pre-release

What's Changed

Update with pip: pip install -U pywa --pre
Updated Docs: pywa.readthedocs.io/en/dev/

Caution

Make sure to read the migration guide before updating to this version!

  • [client] update webhook_fields type to support utils.WebhookFields and enhance handling logic
  • [client] replace business_account_id with waba_id across the codebase
  • [client] add methods to retrieve shared and owned WABAs
  • [message] add OutgoingMessage, OutgoingEditedMessage and OutgoingDeletedMessage classes for message updates
  • [message] add EditedMessage and DeletedMessage classes for message updates
  • [contacts] add ContactList class for shared contacts handling
  • [media] store caption inside media objects
  • [groups] add GroupOperation class and update group-related methods to return operation responses
  • [callback] update VoiceCallButton to support timedelta for ttl_minutes
  • [errors] add raw error field and new group/template error classes

Full Changelog: 4.0.0b3...4.0.0b4

4.0.0b3

01 Apr 09:31
7f66f84

Choose a tag to compare

4.0.0b3 Pre-release
Pre-release

What's Changed

Update with pip: pip install -U pywa --pre
Updated Docs: pywa.readthedocs.io/en/dev/

Caution

Make sure to read the migration guide before updating to this version!

  • [client] add SUPPORTS_BSUID_API flag and update user identifier resolution logic
  • [templates] fix summary fields in TemplatesResult
  • [ci] update checkout action to use workflow_run head_sha reference

Full Changelog: 4.0.0b1...4.0.0b3

4.0.0b1

29 Mar 21:42
da85093

Choose a tag to compare

4.0.0b1 Pre-release
Pre-release

What's Changed

Update with pip: pip install -U pywa --pre
Updated Docs: pywa.readthedocs.io/en/dev/

Caution

Make sure to read the migration guide before updating to this version!

  • [user] implement BSUID changes
  • [user] added country_code field
  • [groups] add group management features
  • [handlers] implement GroupMessageStatuses class and handler for group message status updates
  • [message_status] add new PricingCategory: general_purpose_ai
  • [filters] update from_countries to support country_code
  • [filters] add filters for private and group chat messages
  • [templates] add ContactInfoRequestButton component
  • [templates] add to CreativeFeaturesSpec two classmethods: all_enabled and all_disabled
  • [others] add BlockedUser and UnblockedUser for user blocking functionality
  • [types] remove ChatOpened references and related code

Full Changelog: 3.9.0...4.0.0b1

3.9.0

11 Mar 21:06
cbd51fb

Choose a tag to compare

What's Changed

Update with pip: pip3 install -U pywa

  • [base_update] edit reply_template to accept Template obj
  • [templates] add auto_promotion_tag field to CreativeFeaturesSpec
  • [templates] fix template params validation in async (reported by @val-2 in #171)
  • [templates] fix filters import in wait_until_approved (reported by @SirKaiMartin in #175)
from pywa import WhatsApp
from pywa.types.templates import *

template = Template(
    name="buy_new_iphone_x",
    category=TemplateCategory.MARKETING,
    language=TemplateLanguage.ENGLISH_US,
    parameter_format=ParamFormat.NAMED,
    components=[
        ht := HeaderText("The New iPhone {{iphone_num}} is here!", iphone_num=17),
        bt := BodyText(
            "Buy now and use the code {{code}} to get {{per}}% off!",
            code="WA_IPHONE_15",
            per=17,
        ),
        FooterText(text="Powered by PyWa"),
        Buttons(
            buttons=[
                url := URLButton(
                    text="Buy Now",
                    url="https://example.com/shop/{{1}}",
                    example="iphone17",
                ),
                PhoneNumberButton(text="Call Us", phone_number="1234567890"),
                qrb1 := QuickReplyButton(text="Unsubscribe from marketing messages"),
                qrb2 := QuickReplyButton(text="Unsubscribe from all messages"),
            ]
        ),
    ],
)

wa = WhatsApp(...)

@wa.on_message
def send_marketing_message(_: WhatsApp, m: Message):
    m.reply_template(
        template=template,  # Use the template object to validate params *before* sending
        params=[
            ht.params(iphone_num=30),
            bt.params(code="WA_IPHONE_30", per=30),
            url.params(url_variable="iphone30", index=0),
            qrb1.params(callback_data="unsubscribe_from_marketing_messages", index=1),
            qrb2.params(callback_data="unsubscribe_from_all_messages", index=2),
        ],
    )

Full Changelog: 3.8.0...3.9.0

3.8.0

23 Jan 13:11
4e33b51

Choose a tag to compare

What's Changed

Update with pip: pip3 install -U pywa

  • [templates] enhance template parameters validation and improve component handling
  • [types] update BusinessProfile to allow optional 'about' field (reported by @riklaunim in #169)
from pywa import WhatsApp
from pywa.types.templates import *

template = Template(
    name="buy_new_iphone_x",
    category=TemplateCategory.MARKETING,
    language=TemplateLanguage.ENGLISH_US,
    parameter_format=ParamFormat.NAMED,
    components=[
        ht := HeaderText("The New iPhone {{iphone_num}} is here!", iphone_num=17),
        bt := BodyText(
            "Buy now and use the code {{code}} to get {{per}}% off!",
            code="WA_IPHONE_15",
            per=17,
        ),
        FooterText(text="Powered by PyWa"),
        Buttons(
            buttons=[
                url := URLButton(
                    text="Buy Now",
                    url="https://example.com/shop/{{1}}",
                    example="iphone17",
                ),
                PhoneNumberButton(text="Call Us", phone_number="1234567890"),
                qrb1 := QuickReplyButton(text="Unsubscribe from marketing messages"),
                qrb2 := QuickReplyButton(text="Unsubscribe from all messages"),
            ]
        ),
    ],
)

wa = WhatsApp(...)

wa.send_template(
    to="9876543210",
    template=template, # Use the template object to validate params *before* sending
    params=[
        ht.params(iphone_num=30),
        bt.params(code="WA_IPHONE_30", per=30),
        url.params(url_variable="iphone30", index=0),
        qrb1.params(callback_data="unsubscribe_from_marketing_messages", index=1),
        qrb2.params(callback_data="unsubscribe_from_all_messages", index=2),
    ],
)

Full Changelog: 3.7.0...3.8.0

3.7.0

11 Jan 13:46
615bd60

Choose a tag to compare

What's Changed

Update with pip: pip3 install -U pywa

  • [media] allow to override the default 1-hour TTL for No Storage-enabled business phone numbers
  • [types] add QRCodeImageType and enhance QRCode methods for image handling
  • [templates] adding product_extensions and text_formatting_optimization to CreativeFeaturesSpec
  • [api] add method to exchange Embedded Signup token for business access token
  • [ci] update GitHub Actions workflows for improved publishing and testing
  • [core] support Python 3.14

Full Changelog: 3.6.1...3.7.0

3.6.1

10 Dec 22:12
91f2d00

Choose a tag to compare

What's Changed

Update with pip: pip3 install -U pywa

  • [helpers] fix media URL in template param (reported in #160 by @riklaunim)
  • [tests] test resolve_media_param

Full Changelog: 3.6.0...3.6.1

3.6.0

26 Nov 23:11
49332ae

Choose a tag to compare

What's Changed

Update with pip: pip3 install -U pywa

  • [client] allow any media type in update_business_profile(profile_picture=...) arg
  • [sent_message] adding new SentReaction type for replying and reacting to the original message
  • [media] allowing usage in context manager to delete media after use
  • [templates] moving TemplateStatusUpdate fields into objects
  • [message_status] fixing MessageStatus.pricing.type parsing by @Janson-L in #158
  • [utils] bump flow_data_api to 4.0
from pywa import WhatsApp, filters, types

wa = WhatsApp(...)

# media will be automatically deleted from WhatsApp servers after exiting the context
with wa.upload_media("/path/to/sensitive_image.png") as media:
    wa.send_image(to=..., image=media)

@wa.on_message(filters.command("start"))
def on_start(_: WhatsApp, m: types.Message):
    doc = m.reply("Please send your ID as a document.").wait_for_reply(filters=filters.document).document
    # document will be automatically deleted from WhatsApp servers after exiting the context
    with doc:
        # process the document stream securely
        upload_to_secure_storage(file=doc.stream())
from pywa import WhatsApp

wa = WhatsApp(...)

wa.update_business_profile(
    # use any media source supported by pywa
    profile_picture=pathlib.Path("/path/to/image.png")
)

Full Changelog: 3.5.2...3.6.0