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)
participant attribute identifying the sender.
Delivery receipts (type=
"delivery") are sent automatically. This is different from read receipts (type="read"), which you send manually with mark_as_read().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.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:Receipt Event Structure
List of message IDs this receipt applies to. Usually contains a single ID, but can have multiple.
Source information:
chat- Chat JID where the receipt originatedsender- JID of the user who sent the receiptis_group- Whether this is from a group
When the receipt was received (local time)
Type of receipt (Delivered, Read, Played, etc.)
JID of the user who sent the receipt (same as
source.sender)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.