mark_as_read
Send read receipts for one or more messages. Read receipts inform the sender that you’ve read their message(s). For group messages, you must pass the original sender’s JID as thesender parameter.
Chat JID where the messages were received. Can be:
- Direct message:
15551234567@s.whatsapp.net - Group:
120363040237990503@g.us
Message sender JID. Required for group messages,
None for direct messages.- For DMs: Pass
None - For groups: Pass the JID of the user who sent the message(s)
List of message IDs to mark as read. Can be a single ID or multiple IDs.If empty, this function returns immediately without sending anything.
Example: Mark DM as Read
Example: Mark Group Message as Read
Example: Mark Multiple Messages as Read
Read receipts are not sent automatically by the library. You must explicitly call
mark_as_read() when you want to notify the sender that messages have been read.send_delivery_receipt (Internal)
Sends a delivery receipt to the sender of a message. This is an internal method called automatically by the library when messages are received. You typically don’t need to call this directly.Message metadata containing:
id- Message IDsource.chat- Chat JIDsource.sender- Sender JIDsource.is_from_me- Whether this is your own messagesource.is_group- Whether this is a group message
Behavior
Delivery receipts are automatically sent for all incoming messages except:- Your own messages (
is_from_me = true) - Messages without an ID
- Status broadcast messages (
status@broadcast) - Newsletter messages
participant attribute identifying the sender.
Delivery receipts are sent automatically. Unlike other receipt types (e.g.,
type="read", type="played"), delivery receipts have no type attribute on the wire — delivery is the implicit default. The library omits the type attribute from ack responses to delivery receipts accordingly, since including an explicit type="delivery" would cause <stream:error> disconnections from the server. This is different from read receipts (type="read"), which you send manually with mark_as_read().Wire format
Internally, delivery receipts pass JID references directly to the.attr() method, avoiding allocations on the hot path:
mark_as_read) batch multiple message IDs using a <list> child node with <item> elements:
Receipt Types
WhatsApp supports multiple receipt types:Delivery receipt (type=
""). Confirms message was delivered to the recipient’s device. Sent automatically by the library.Read receipt (type=
"read"). Confirms message was read by the recipient. Sent manually via mark_as_read().Read receipt from your own device (type=
"read-self"). Received when you read a message on another device.Played receipt (type=
"played"). Confirms media (audio/video) was played by the recipient.Played receipt from your own device (type=
"played-self"). Received when you play media on another device.Retry receipt (type=
"retry"). Recipient failed to decrypt the message and is requesting a retry. Automatically handled by the library.VoIP call encryption re-keying retry receipt (type=
"enc_rekey_retry"). Sent when a peer fails to decrypt VoIP call encryption data and needs the sender to re-key. Uses an <enc_rekey> child element (with call-creator, call-id, count attributes) instead of the standard <retry> child. Automatically handled by the library.Sender receipt (type=
"sender"). Acknowledges message was sent.Server error receipt (type=
"server-error"). Message delivery failed on server.Receipt Events
You can listen for receipt events to track message delivery and read status using the Bot event handler:Receipt Event Structure
Source information:
chat- Chat JID where the receipt originatedsender- JID of the user who sent the receiptis_group- Whether this is from a group
List of message IDs this receipt applies to. Usually contains a single ID, but can have multiple.
When the receipt was received (local time)
Type of receipt (Delivered, Read, Played, etc.)
Message Tracking Example
Track message delivery and read status:Played Receipts (Media)
For media messages (audio, video), you can send played receipts to indicate the media was played: Played receipts follow the same pattern as read receipts but usetype="played":
Event::Receipt event with ReceiptType::Played.