Releases: david-lev/pywa
1.21.0
What's Changed
Update with pip:
pip3 install -U pywa
Caution
- [server] This version drops support for non-asynchronous WSGI applications (Flask without
asgiref
) - [flows]
version
is now required inFlowJSON
- [flows] added new components
PhotoPicker
,DocumentPicker
,If
andSwitch
- [flows] added
.data_key_of
and.form_ref_of
to refer from other screens - [flows] added
description
toCheckboxGroup
and toRadioButtonsGroup
- [utils] adding
flow_request_media_decryptor
function to decrypt medias from flow requests - [client] allow updating flow application id with
update_flow_metadata
- [server] remove event loop
- [docs] update examples
- [version] bump
FLOW_JSON
version to4.0
from pywa import WhatsApp, utils, types
from pywa.types.flows import *
wa = WhatsApp(...)
my_flow = FlowJSON(
version="4.0",
screens=[
Screen(
id="UPLOAD_DRIVER_LICENSE",
title="Upload Driver License",
layout=Layout(
children=[
doc := DocumentPicker(
name="driver_license",
label="Driver License",
min_uploaded_documents=1,
max_uploaded_documents=1,
allowed_mime_types=["application/pdf", "image/jpeg"],
),
Footer(
label="Next",
enabled=True,
on_click_action=Action(
name=FlowActionType.DATA_EXCHANGE,
payload={"doc": doc.form_ref_of("UPLOAD_DRIVER_LICENSE")},
),
),
]
)
)
]
)
@wa.on_flow_request("/flow")
def on_flow_request(_, flow: types.FlowRequest):
media_id, filename, media_bytes = utils.flow_request_media_decryptor_sync(flow.data["doc"])
with open(filename, "wb") as f:
f.write(media_bytes)
...
Full Changelog: 1.20.2...1.21.0
1.20.2
What's Changed
Update with pip:
pip3 install -U pywa
- [pywa] adding official support for async (limited support for now)
- [server] expose
webhook_challenge_handler
,webhook_update_handler
andget_flow_request_handler
for custom server implementations - [server] improve continue/stop handling
- [client] adding
skip_duplicate_updates
when callbacks take too long to return (~25s), defaults to True - [client,handlers] allow to override
continue_handling
# wa.py
from pywa_async import WhatsApp, types # Import from `pywa_async` instead of `pywa`
import fastapi
fastapi_app = FastAPI()
wa = WhatsApp(..., server=fastapi_app)
@wa.on_message()
async def echo_media(_: WhatsApp, msg: types.Message):
await msg.reply("I'm using PyWa async!")
Run with uvicorn:
uvicorn wa:fastapi_app
Full Changelog: 1.18.1...1.20.2
1.19.0-rc.3
What's Changed
Update with pip:
pip3 install -U pywa==1.19.0-rc.3
- [api] fix uploads
- [server] expose
webhook_challenge_handler
,webhook_update_handler
andflow_request_handler
Full Changelog: 1.19.0-rc.2...1.19.0-rc.3
1.19.0-rc.2
What's Changed
Update with pip:
pip3 install -U pywa==1.19.0-rc.2
- [client] adding
skip_duplicate_updates
when callbacks take too long to return (~25s), defaults to True - [client,handlers] allow to override
continue_handling
- [message] fix async constructors
- [api] remove
requests_toolbelt
from deps - [handlers] fix dynamic field name when
factory_before_filters
Full Changelog: 1.19.0-rc.1...1.19.0-rc.2
1.19.0-rc.1
What's Changed
Update with pip:
pip3 install -U pywa==1.19.0-rc.1
- [async] adding beta support for async!
from pywa_async import WhatsApp, types # Import from `pywa_async` instead of `pywa`
wa = WhatsApp(...)
@wa.on_message(filters.media)
async def echo_media(_: WhatsApp, message: types.Message):
await message.copy(to=message.sender)
Full Changelog: 1.18.1...1.19.0-rc.1
1.18.1
What's Changed
Update with pip:
pip3 install -U pywa
- [client] fix document filename
Full Changelog: 1.18.0...1.18.1
1.18.0
What's Changed
Update with pip:
pip3 install -U pywa
- [client] allow to modify token and remove handlers/callbacks
- [tests] test client methods
Full Changelog: 1.17.0...1.18.0
1.17.0
What's Changed
Update with pip:
pip3 install -U pywa
- [client,message_status] Added param
tracker
to all send-message-methods in order to track the message status, allowing to passCallbackData
subclasses totracker
param - [client,api] adding
update_conversational_automation
andget_business_phone_number
to add and getcommands
,ice_breakers
and enableChatOpened
events - [filters] adding
send_to_me
filters shortcut andreplays_to
filters. mark as deprecated all match-specific-type filters and create genericmatches
,regex
filters for all text containing updates - [flows] adding
updated_at
toFlowDetails
- [message] fix
from_user
in system messages - [errors] adding optionals
error_subcode
andtype
to all errors - [logging] improve loggers performance
- [utils] bump graph api version to 19.0 and expose
Version
in the package level - [docs] switch readme to markdown
from pywa import WhatsApp, types, filters
wa = WhatsApp(...)
wa.send_message(
to="972123456789",
text="Hello from pywa!",
tracker="my_tracker",
)
@wa.on_message_status(filters.matches("my_tracker"))
def on_status(_: WhatsApp, status: types.MessageStatus):
print(status.tracker)
from pywa import WhatsApp
from pywa.types import Command
wa = WhatsApp(...)
wa.update_conversational_automation(
enable_chat_opened=True,
ice_breakers=[
"Generate me an image of a cute cat",
"Create a beautiful image of a sunset",
],
commands=[
Command(name="imagine", description="Create images using a text prompt"),
Command(name="contact", description="Contact us",),
]
)
Full Changelog: 1.16.2...1.17.0
1.16.2
What's Changed
Update with pip:
pip3 install -U pywa
- [client] fix sending single contact
- [filters] prioritize
/
over!
infilters.command(...)
andfilters.is_command
Full Changelog: 1.16.0...1.16.2
1.16.0
What's Changed
Update with pip:
pip3 install -U pywa
- [chat_opened] adding a new type:
ChatOpened
- [server] improve handlers and logs
- [types] warning on missing enum constant
- [flows] handle cases where there is no
flow_token
inFlowCompletion
(When the flow completion sent from iOS) - [tests] adding more tests
from pywa import WhatsApp
from pywa.types import ChatOpened
from flask import Flask
flask_app = Flask(__name__)
wa = WhatsApp(..., server=flask_app, verify_token=...)
@wa.on_chat_opened()
def handle_chat_opened(_: WhatsApp, chat_opened: ChatOpened):
chat_opened.reply(f"Hello, {chat_opened.from_user.name}. Welcome to our bot!")
Full Changelog: 1.15.0...1.16.0