π¬ Updates#
Updates are the incoming events from the WhatsApp Cloud API. They are sent to your webhook URL and converted by PyWa into type-safe objects that are easy to handle.
In WhatsApp Cloud API, updates are called fields, and you need to subscribe to them in order to receive them at your webhook URL.
Supported Fields#
The currently supported fields in PyWa are:
messagesβ all user-related updates (messages, callbacks, message status updates)callsβ call connect, terminate, and status updatesmessage_template_status_updateβ template approved, rejected, etc.message_template_quality_updateβ template quality score changedmessage_template_components_updateβ template components changed (header, body, footer, buttons)template_category_updateβ template category changeduser_preferencesβ user marketing preferences
Tip
If you want to handle other types of updates, use on_raw_update() decorator or the RawUpdateHandler class.
from pywa import WhatsApp, types
wa = WhatsApp(...)
@wa.on_raw_update
def handle_raw_update(wa: WhatsApp, raw: dict):
print("Received raw update:", raw)
Update Types#
The supported fields are automatically handled by PyWa and converted into Python classes.
π To learn how to handle them, see: Handlers
User-related updates:
Type |
Description |
|---|---|
A message sent by a user (text, media, order, location, etc.) |
|
A |
|
A |
|
A flow completed by a user |
|
A message status update (delivered, seen, etc.) |
|
A chat opened by a user |
|
A userβs phone number changed |
|
A userβs identity changed |
|
A call connected by a user |
|
A call terminated by a user |
|
A call status update (ringing, busy, etc.) |
|
A call permission update (permission granted or denied) |
|
A user marketing preferences update (e.g. opted in, opted out) |
Account-related updates:
Type |
Description |
|---|---|
A template status update (approved, rejected, etc.) |
|
A template category update (category changed) |
|
A template quality update (quality score changed) |
|
A template components update (header, body, footer, buttons changed) |
Common Properties#
All updates share common methods and properties:
Property |
Description |
|---|---|
The update ID |
|
The raw update data |
|
The update timestamp (UTC) |
|
Prevent further handlers from processing the update |
|
Force the update to continue to the next handler |
User-related updates share additional properties:
Method / Property |
Description |
|---|---|
The phone ID of the sender |
|
The phone ID of the recipient |
|
The message ID to reply to |
|
Reply with a text message |
|
Reply with an image message |
|
Reply with a video message |
|
Reply with an audio message |
|
Reply with a document message |
|
Reply with a location message |
|
Request the userβs location |
|
Reply with a contact message |
|
Reply with a sticker message |
|
Reply with a template message |
|
Reply with a catalog message |
|
Reply with a product message |
|
Reply with a list of product messages |
|
React to the update with an emoji |
|
Remove a reaction |
|
Mark the update as read |
|
Indicate typing to the user |
|
Block the sender |
|
Unblock the sender |
|
Start a call with the sender |
- Message
- Callback Button
- Callback Selection
- Flow Completion
- Message Status
- Chat Opened
- Phone Number Change
- Identity Change
- Call Connect
- Call Terminate
- Call Status
- Call Permission Update
- User Marketing Preferences
- Template Status Update
- Template Category Update
- Template Quality Update
- Template Components Update
- Common methods
BaseUpdateBaseUserUpdateBaseUserUpdate.reply_text()BaseUserUpdate.reply_image()BaseUserUpdate.reply_video()BaseUserUpdate.reply_audio()BaseUserUpdate.reply_document()BaseUserUpdate.reply_location()BaseUserUpdate.reply_location_request()BaseUserUpdate.reply_contact()BaseUserUpdate.reply_sticker()BaseUserUpdate.reply_template()BaseUserUpdate.reply_catalog()BaseUserUpdate.reply_product()BaseUserUpdate.reply_products()BaseUserUpdate.react()BaseUserUpdate.unreact()BaseUserUpdate.mark_as_read()BaseUserUpdate.indicate_typing()BaseUserUpdate.call()BaseUserUpdate.senderBaseUserUpdate.recipientBaseUserUpdate.block_sender()BaseUserUpdate.unblock_sender()BaseUserUpdate.message_id_to_reply