Message Fields#

class pywa.types.others.Reaction#

Represents a reaction to a message.

Variables:
  • message_id (str) – The ID of the message that was reacted to.

  • emoji (str | None) – The emoji that was used to react to the message (optional, None if removed).

property is_removed: bool#

Check if the reaction is removed.

class pywa.types.others.Location#

Represents a location.

Variables:
  • latitude (float) – The latitude of the location.

  • longitude (float) – The longitude of the location.

  • name (str | None) – The name of the location (optional).

  • address (str | None) – The address of the location (optional).

  • url (str | None) – The URL of the location (optional).

property current_location: bool#

Check if the shared location is the current location or manually selected.

in_radius(lat: float, lon: float, radius: float | int) bool#

Check if the location is in a radius of another location.

Parameters:
  • lat – The latitude of the other location.

  • lon – The longitude of the other location.

  • radius – The radius in kilometers.

class pywa.types.others.Contact#

Represents a contact.

Variables:
  • name (Name) – The name of the contact.

  • birthday (str | None) – The birthday of the contact (in YYYY-MM-DD format, optional).

  • phones (Iterable[Phone]) – The phone numbers of the contact.

  • emails (Iterable[Email]) – The email addresses of the contact.

  • urls (Iterable[Url]) – The URLs of the contact.

  • addresses (Iterable[Address]) – The addresses of the contact.

  • org (Org | None) – The organization of the contact (optional).

to_dict() dict[str, Any]#

Get the contact as a dict.

as_vcard() str#

Get the contact as a vCard.

class Name(formatted_name: str, first_name: str | None = None, last_name: str | None = None, middle_name: str | None = None, suffix: str | None = None, prefix: str | None = None)#

Represents a contact’s name.

  • At least one of the optional parameters needs to be included along with the formatted_name parameter.

Variables:
  • formatted_name (str) – The formatted name of the contact.

  • first_name (str | None) – The first name of the contact (optional).

  • last_name (str | None) – The last name of the contact (optional).

  • middle_name (str | None) – The middle name of the contact (optional).

  • suffix (str | None) – The suffix of the contact (optional).

  • prefix (str | None) – The prefix of the contact (optional).

class Phone(phone: str | None = None, type: str | None = None, wa_id: str | None = None)#

Represents a contact’s phone number.

Variables:
  • phone (str | None) – The phone number (If wa_id is provided, No need for the phone).

  • type (str | None) – The type of the phone number (Standard Values are CELL, MAIN, IPHONE, HOME, and WORK. optional).

  • wa_id (str | None) – The WhatsApp ID of the contact (optional).

class Email(email: str | None = None, type: str | None = None)#

Represents a contact’s email address.

Variables:
  • email (str | None) – The email address.

  • type (str | None) – The type of the email address (Standard Values are WORK and HOME. optional).

class Url(url: str | None = None, type: str | None = None)#

Represents a contact’s URL.

Variables:
  • url (str | None) – The URL.

  • type (str | None) – The type of the URL (Standard Values are WORK and HOME. optional).

class Org(company: str | None = None, department: str | None = None, title: str | None = None)#

Represents a contact’s organization.

Variables:
  • company (str | None) – The company of the contact (optional).

  • department (str | None) – The department of the contact (optional).

  • title (str | None) – The title of the business contact (optional).

class Address(street: str | None = None, city: str | None = None, state: str | None = None, zip: str | None = None, country: str | None = None, country_code: str | None = None, type: str | None = None)#

Represents a contact’s address.

Variables:
  • street (str | None) – The street number and name of the address (optional).

  • city (str | None) – The city name of the address (optional).

  • state (str | None) – State abbreviation.

  • zip (str | None) – Zip code of the address (optional).

  • country (str | None) – Full country name.

  • country_code (str | None) – Two-letter country abbreviation (e.g. US, GB, IN. optional).

  • type (str | None) – The type of the address (Standard Values are WORK and HOME. optional).

class pywa.types.others.Product#

Represents a product in an order.

Variables:
  • sku (str) – Unique identifier of the product in a catalog (also referred to as Content ID or Retailer ID).

  • quantity (int) – Number of items ordered.

  • price (float) – Price of the item.

  • currency (str) – Currency of the price.

property total_price: float#

Total price of the product.

class pywa.types.others.Order#

Represents an order.

Variables:
  • catalog_id (str) – The ID for the catalog the ordered item belongs to.

  • products (tuple[pywa.types.others.Product, ...]) – The ordered products.

  • text (str | None) – Text message from the user sent along with the order (optional).

Properties:

total_price: Total price of the order.

property total_price: float#

Total price of the order.

class pywa.types.others.ReferredProduct#

Represents a product this message is referring to.

Variables:
  • catalog_id (str) –

  • sku (str) – Unique identifier of the product in a catalog (also referred to as Content ID or Retailer ID).

class pywa.types.others.System#

Represents a system update (A customer has updated their phone number or profile information).

Variables:
  • type (str | None) – The type of the system update (customer_changed_number or customer_identity_changed).

  • body (str | None) – Describes the change to the customer’s identity or phone number.

  • identity (str | None) – Hash for the identity fetched from server.

  • wa_id (str | None) – The WhatsApp ID for the customer prior to the update.

  • new_wa_id (str | None) – New WhatsApp ID for the customer when their phone number is updated.

class pywa.types.others.User#

Represents a WhatsApp user.

Variables:
  • wa_id (str) – The WhatsApp ID of the user (The phone number with the country code).

  • name (str | None) – The name of the user (None on MessageStatus or when message type is MessageType.SYSTEM).

class pywa.types.others.ReplyToMessage#

Represents a message that was replied to.

Variables:
  • message_id (str) – The ID of the message that was replied to.

  • from_user_id (str) – The ID of the user who sent the message that was replied to.

  • referred_product (pywa.types.others.ReferredProduct | None) – Referred product describing the product the user is requesting information about.

class pywa.types.others.Metadata#

Represents the metadata of a message.

Variables:
  • display_phone_number (str) – The phone number to which the message was sent.

  • phone_number_id (str) – The ID of the phone number to which the message was sent.

class pywa.types.message_status.Conversation#

Represents a conversation.

Variables:
class pywa.types.message_status.ConversationCategory#

Conversation category.

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

  • MARKETING – The conversation is related to marketing.

  • 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.