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