Skip to main content
Beyond sending new messages, Baileys gives you methods to manage the lifecycle of messages: deleting them for all participants, editing previously sent content, marking messages as read, and broadcasting your presence state (typing, recording, online) to a chat.

Delete a message for everyone

Pass the key of the message you want to remove inside a delete content object. This removes the message for all participants in the chat.
To delete a message only for yourself (not for other participants), use sock.chatModify with the clear operation instead. See the chat management page for details.

Edit a message

Pass the updated content along with the edit field set to the key of the original message. You can include any editable content type in the same call.

Mark messages as read

Baileys requires you to mark individual message keys as read explicitly — you cannot mark an entire chat read in one call. This means you need to track the keys of unread messages yourself (for example, by storing them in your data store as they arrive).
You can access the message ID from any WAMessage using message.key.id.

Update presence

Call sendPresenceUpdate to broadcast your current state to a specific chat. This is how WhatsApp shows “typing…” or “recording audio…” indicators.
The presence argument accepts the following values from the WAPresence type:
Presence updates expire after approximately 10 seconds. If you want to keep showing “typing…” you need to send repeated updates.
If a desktop client is active, WhatsApp does not send push notifications to your phone. Mark your Baileys client as offline using sock.sendPresenceUpdate('unavailable') if you want push notifications to reach your phone while the bot is running.
For handling incoming calls, see Handle WhatsApp calls.