Use this guide when you want to show that your account is online, offline, composing, or recording, or when you want to subscribe to another chat's presence feed.
Quick start
Mark the current account as available:
:ok = BaileysEx.send_presence_update(connection, :available)Options
These options matter most for presence work:
to_jidsends a chatstate update such as:composing,:recording, or:pausedto one chatme_id:sets the sender JID for phone-number chats when you send a chatstate updateme_lid:sets the sender JID for LID-addressed chats when you send a chatstate updatename:sets the account name for:availableand:unavailableupdates when you call the lower-level helper directly
→ See Event Catalog Reference for the emitted :presence_update payload.
Common patterns
Mark the account online or offline
:ok = BaileysEx.send_presence_update(connection, :available)
:ok = BaileysEx.send_presence_update(connection, :unavailable)Show typing in one chat
:ok =
BaileysEx.send_presence_update(
connection,
:composing,
"15551234567@s.whatsapp.net",
me_id: "15550001111@s.whatsapp.net"
)Subscribe to another chat's presence feed
:ok = BaileysEx.presence_subscribe(connection, "15551234567@s.whatsapp.net")Handle incoming presence updates
unsubscribe =
BaileysEx.subscribe(connection, fn
{:presence, update} -> IO.inspect(update, label: "presence")
_other -> :ok
end)Limitations
- Chatstate updates such as
:composingand:recordingneedme_id:orme_lid:so BaileysEx can build the correct sender JID. - Presence subscriptions depend on what WhatsApp shares for that chat. Some contacts and groups expose limited presence information.
- Subscription handlers run inside the connection event emitter. Keep them short and move heavier work into a
Taskor your own GenServer.
See also: