Message Status#

class pywa.types.message_status.MessageStatus#

Represents the status of a message.

MessageStatus is a generic class, so when providing a factory parameter in callback handlers, you can specify the type of the factory to get autocomplete in the tracker attribute.

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 – The message was sent.

  • DELIVERED – The message was delivered.

  • READ – The message was read.

  • FAILED – The message failed to send (you can access the .error attribute for more information).

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:
class pywa.types.message_status.ConversationCategory#

Conversation category.

Variables:
  • AUTHENTICATION – The conversation is related to authentication.

  • MARKETING – The conversation is related to marketing.

  • MARKETING_LITE – The conversation is related to marketing lite.

  • UTILITY – The conversation is related to utility.

  • SERVICE – The conversation is related to service.

  • REFERRAL_CONVERSION – The conversation is related to referral conversion.

  • UNKNOWN – The conversation category is unknown.

class pywa.types.message_status.Pricing#

Represents the pricing of a message.

Variables:
class pywa.types.message_status.PricingModel#

Pricing model.

Variables:
  • CBP – Indicates conversation-based pricing applies.

  • 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 an authentication template message.

  • AUTHENTICATION_INTERNATIONAL – Indicates an authentication template message sent to a WhatsApp user in a country or region that has authentication-international rates.

  • MARKETING – Indicates a marketing template message.

  • MARKETING_LITE – Indicates a marketing template message sent via MM Lite API.

  • UTILITY – Indicates a utility template message.

  • SERVICE – Indicates a non-template message.

  • REFERRAL_CONVERSION – Indicates the message is part of a free entry point conversation.