# Presence
The `Presence` interface provides methods for tracking which users are currently in a chat room. Access it via `room.presence`.
#### Kotlin
```
val presence = room.presence
```
## Enter presence
`suspend presence.enter(data: JsonObject? = null): Unit`
Enters the current user into the chat room presence set. This notifies other users that you have joined the room.
The room must be [attached](https://ably.com/docs/chat/api/kotlin/room.md#attach) before calling this method.
### Kotlin
```
room.presence.enter(jsonObject {
put("status", "online")
put("nickname", "Alice")
})
```
### Parameters
The `enter()` method takes the following parameters:
### Kotlin
```
room.presence.update(jsonObject {
put("status", "away")
put("nickname", "Alice")
})
```
### Parameters
The `update()` method takes the following parameters:
### Kotlin
```
room.presence.leave(jsonObject {
put("status", "offline")
})
```
### Parameters
The `leave()` method takes the following parameters:
### Kotlin
```
val members = room.presence.get()
members.forEach { member ->
println("${member.clientId} is present")
}
```
### Parameters
The `get()` method takes the following parameters:
### Kotlin
```
val isAliceHere = room.presence.isUserPresent("alice-123")
println("Alice is present: $isAliceHere")
```
### Parameters
The `isUserPresent()` method takes the following parameters:
### Kotlin
```
import com.ably.chat.PresenceEventType
val subscription = room.presence.subscribe { event ->
val member = event.member
when (event.type) {
PresenceEventType.Enter ->
println("${member.clientId} joined")
PresenceEventType.Leave ->
println("${member.clientId} left")
PresenceEventType.Update ->
println("${member.clientId} updated their status")
PresenceEventType.Present ->
println("${member.clientId} is present")
}
}
// To stop receiving presence events
subscription.unsubscribe()
```
### Parameters
The `subscribe()` method takes the following parameters:
### Kotlin
```
import kotlinx.coroutines.launch
launch {
room.presence.asFlow().collect { event ->
println("${event.type}: ${event.member.clientId}")
}
}
```
### Returns
`Flow
### Kotlin
```
import com.ably.chat.PresenceEventType
import com.ably.chat.asFlow
import kotlinx.coroutines.launch
import com.ably.chat.json.jsonObject
val room = chatClient.rooms.get("my-room")
room.attach()
// Subscribe to presence events with a listener
val subscription = room.presence.subscribe { event ->
val member = event.member
println("${event.type}: ${member.clientId}")
member.data?.let { data ->
println("Data: $data")
}
}
// Or use Flow for reactive collection
launch {
room.presence.asFlow().collect { event ->
println("Presence: ${event.type} - ${event.member.clientId}")
}
}
// Enter the room with custom data
room.presence.enter(jsonObject {
put("status", "online")
put("nickname", "Alice")
})
// Get everyone currently in the room
val members = room.presence.get()
println("${members.size} users in room")
// Update your status
room.presence.update(jsonObject {
put("status", "away")
})
// Check if a specific user is present
val isBobHere = room.presence.isUserPresent("bob-456")
// Leave when done
room.presence.leave()
subscription.unsubscribe()
```
## Related Topics
- [ChatClient](https://ably.com/docs/chat/api/kotlin/chat-client.md): API reference for the ChatClient interface in the Ably Chat Kotlin SDK.
- [Connection](https://ably.com/docs/chat/api/kotlin/connection.md): API reference for the Connection interface in the Ably Chat Kotlin SDK.
- [Rooms](https://ably.com/docs/chat/api/kotlin/rooms.md): API reference for the Rooms interface in the Ably Chat Kotlin SDK.
- [Room](https://ably.com/docs/chat/api/kotlin/room.md): API reference for the Room interface in the Ably Chat Kotlin SDK.
- [Messages](https://ably.com/docs/chat/api/kotlin/messages.md): API reference for the Messages interface in the Ably Chat Kotlin SDK.
- [Message](https://ably.com/docs/chat/api/kotlin/message.md): API reference for the Message interface in the Ably Chat Kotlin SDK.
- [MessageReactions](https://ably.com/docs/chat/api/kotlin/message-reactions.md): API reference for the MessageReactions interface in the Ably Chat Kotlin SDK.
- [Occupancy](https://ably.com/docs/chat/api/kotlin/occupancy.md): API reference for the Occupancy interface in the Ably Chat Kotlin SDK.
- [Typing](https://ably.com/docs/chat/api/kotlin/typing.md): API reference for the Typing interface in the Ably Chat Kotlin SDK.
- [RoomReactions](https://ably.com/docs/chat/api/kotlin/room-reactions.md): API reference for the RoomReactions interface in the Ably Chat Kotlin SDK.
## Documentation Index
To discover additional Ably documentation:
1. Fetch [llms.txt](https://ably.com/llms.txt) for the canonical list of available pages.
2. Identify relevant URLs from that index.
3. Fetch target pages as needed.
Avoid using assumed or outdated documentation paths.