💬 Updates

💬 Updates#

Updates are the incoming events from WhatsApp Cloud API. They are sent to your webhook URL and constructed by the library to be easily and type-safely to handle.

In WhatsApp Cloud API, the updates called fields and need to be subscribed to in order to receive them to your webhook URL.

The currently supported fields by PyWa are:

  • messages (all user related updates: messages, callbacks and message status updates)

  • message_template_status_update (template got approved, rejected, etc.)

Important

If you register your callback URL manually (not using PyWa), you need to subscribe to the fields you want to receive. Go to your app dashboard, click on the Webhooks tab (Or the Configuration tab > Webhook fields). Then, subscribe to the fields you want to receive.

Subscribe to webhook fields

Tip

If you do want to handle other types of updates (fields), you can use the RawUpdateHandler (or the on_raw_update() decorator) to handle them.

The supported fields are automatically handled by PyWa and converted to the following types:

User related updates:

Type

Description

Message

A message sent by a user (text, media, order, location, etc.)

CallbackButton

A Button pressed by a user

CallbackSelection

A SectionRow chosen by a user

FlowCompletion

A flow completed by a user

MessageStatus

A message status update (e.g. delivered, seen, etc.)

ChatOpened

A chat opened by a user

Account related updates:

Type

Description

TemplateStatus

A template status update (e.g. approved, rejected, etc.)

All updates have common methods and properties:

Property

Description

id

The update ID

raw

The raw update data

timestamp

The timestamp of the update

stop_handling()

Stop handling the update

All user-related-updates have common methods and properties:

Method / Property

Description

sender

The user id who sent the update

message_id_to_reply

The message id to reply to

reply_text()

Reply to the update with a text message

reply_image()

Reply to the update with an image message

reply_video()

Reply to the update with a video message

reply_audio()

Reply to the update with an audio message

reply_document()

Reply to the update with a document message

reply_location()

Reply to the update with a location message

reply_contact()

Reply to the update with a contact message

reply_sticker()

Reply to the update with a sticker message

reply_template()

Reply to the update with a template message

reply_catalog()

Reply to the update with a catalog message

reply_product()

Reply to the update with a product message

reply_products()

Reply to the update with a list of product messages

react()

React to the update with a emoji

unreact()

Unreact to the update

mark_as_read()

Mark the update as read