Message Status#
- class pywa.types.message_status.MessageStatus#
Represents the status of a message.
MessageStatusis a generic class, so when providing afactoryparameter in callback handlers, you can specify the type of the factory to get autocomplete in thetrackerattribute.Here is an example:
>>> from pywa.types import CallbackData >>> from dataclasses import dataclass >>> @dataclass(frozen=True, slots=True) >>> class UserData(CallbackData): # Subclass CallbackData ... id: int ... name: str ... admin: bool
>>> from pywa import WhatsApp >>> from pywa.types import Button, CallbackButton >>> wa = WhatsApp(...) >>> wa.send_message( ... to='972987654321', ... text='Hi user', ... tracker=UserData(id=123, name='david', admin=True) # Here ^^^ we use the UserData class as the tracker ... ) # Here ^^^ we use the UserData class as the tracker data
>>> @wa.on_message_status(factory=UserData) # Use the factory parameter to convert the tracker data ... def on_status(_: WhatsApp, s: MessageStatus[UserData]): # For autocomplete ... if s.tracker.admin: print(s.tracker.id) # Access the tracker data
- Variables:
id β The ID of the message that the status is for.
metadata β The metadata of the message (to which phone number it was sent).
status (MessageStatusType) β The status of the message.
timestamp β The timestamp when the status was updated (in UTC).
from_user β The user who the message was sent to.
conversation (Conversation | None) β The conversation that the message was sent in (See Conversation).
pricing (Pricing | None) β The pricing of the message (Optional).
error (WhatsAppError | None) β The error that occurred (if status is
MessageStatusType.FAILED).tracker (_CallbackDataT | None) β The tracker that the message was sent with (e.g.
wa.send_message(tracker=...)).shared_data β Shared data between handlers.
- class pywa.types.message_status.MessageStatusType#
Message status type.
- Variables:
SENT β Indicates the message was successfully sent from our servers (WhatsApp UI equivalent: One checkmark).
DELIVERED β Indicates message was successfully delivered to the WhatsApp userβs device (WhatsApp UI equivalent: Two checkmarks).
READ β Indicates the message was displayed in an open chat thread in the WhatsApp userβs device (WhatsApp UI equivalent: Two blue checkmarks).
PLAYED β played β Indicates the first time a voice message is played to the WhatsApp userβs device (WhatsApp UI equivalent: Blue microphone).
FAILED β failed β Indicates failure to send or deliver the message to the WhatsApp userβs device (WhatsApp UI equivalent: Red error triangle).
- class pywa.types.message_status.Conversation#
Conversations are 24-hour message threads between you and your customers. They are opened and charged when messages you send to customers are delivered.
- Variables:
id (str) β Represents the ID of the conversation the given status notification belongs to.
category (pywa.types.message_status.ConversationCategory) β The category of the conversation.
expiration (datetime.datetime | None) β The expiration date (in UTC) of the conversation (Optional, only for sent updates).
- class pywa.types.message_status.ConversationCategory#
Conversation category.
Read more at developers.facebook.com.
- Variables:
AUTHENTICATION β Indicates an authentication conversation.
AUTHENTICATION_INTERNATIONAL β Indicates an authentication-international conversation.
MARKETING β Indicates a marketing conversation.
MARKETING_LITE β Indicates a Marketing Messages Lite API conversation.
UTILITY β Indicates a utility conversation.
SERVICE β Indicates a service conversation.
REFERRAL_CONVERSION β Indicates a free entry point conversation.
UNKNOWN β The conversation category is unknown.
- class pywa.types.message_status.Pricing#
Represents the pricing of a message.
- Variables:
billable (bool) β Indicates if the message is billable.
model (pywa.types.message_status.PricingModel) β The pricing model used for the message.
type (pywa.types.message_status.PricingType | None) β The pricing type of the message (Only available from webhook v24.0^).
category (pywa.types.message_status.PricingCategory) β The pricing category of the message.
- class pywa.types.message_status.PricingModel#
Pricing model.
- Variables:
CBP β Indicates conversation-based pricing applies. Will only be set to this value if the webhook was sent before July 1, 2025.
PMP β Indicates per-message pricing applies.
- class pywa.types.message_status.PricingType#
Pricing type.
- Variables:
REGULAR β Indicates the message is billable.
FREE_CUSTOMER_SERVICE β Indicates the message is free because it was either a utility template message or non-template message sent within a customer service window.
FREE_ENTRY_POINT β Indicates the message is free because it is part of a free-entry point conversation.
- class pywa.types.message_status.PricingCategory#
Pricing category.
- Variables:
AUTHENTICATION β Indicates authentication rate applied.
AUTHENTICATION_INTERNATIONAL β Indicates authentication-international rate applied.
MARKETING β Indicates marketing rate applied.
MARKETING_LITE β
Indicates a Marketing Messages Lite API pricing applied.
UTILITY β Indicates utility rate applied.
SERVICE β Indicates service rate applied.
REFERRAL_CONVERSION β Indicates a free entry point conversation.