Chatstate trait provides methods for sending typing indicators and recording notifications to recipients.
Access
Access chatstate operations through the client:Methods
send
Send a chat state update to a recipient.to- Recipient JID (user or group)state: ChatStateType- Type of chat state to send
Result<(), ClientError>- Success or client error
send_composing
Convenience method to send typing indicator.send_recording
Convenience method to send audio recording indicator.send_paused
Convenience method to send paused/stopped typing indicator.ChatStateType Enum
as_str()- Returns"composing","recording", or"paused"
Wire Format
Composing (Typing)
Recording (Voice)
<composing media="audio"> rather than a separate tag.
Paused (Stopped)
Usage Patterns
Typing Indicator Lifecycle
Recording Audio
Throttling
To avoid spamming chat state updates:Group Chats
Chat state indicators work in group chats as well:Error Handling
All methods returnResult<(), ClientError>. Common errors:
- Not connected: Client not connected to WhatsApp
- Invalid JID: Malformed recipient JID
- Network errors: Connection issues
Best Practices
- Throttle updates: Don’t send chat state updates more than once every 2-3 seconds
- Clear on send: Send
Pausedbefore sending the actual message - Auto-timeout: Consider auto-clearing typing indicators after 10-15 seconds of inactivity
- Don’t spam: Only send when state actually changes
- Groups: Be mindful that all group members will see the indicator