
Set of APIs facilitates creating scalable chat rooms for diverse scenarios, ranging from one-on-one to mass communication, suitable for livestreams, gaming, and customer support. Utilizes core service for efficient architectures.
Ably Chat is a set of purpose-built APIs for a host of chat features enabling you to create 1:1, 1:Many, Many:1 and Many:Many chat rooms for any scale. It is designed to meet a wide range of chat use cases, such as livestreams, in-game communication, customer support, or social interactions in SaaS products. Built on Ably's core service, it abstracts complex details to enable efficient chat architectures.
Everything you need to get started with Ably Chat for JVM and Android:
Ably aims to support a wide range of platforms. If you experience any compatibility issues, open an issue in the repository or contact Ably support.
This SDK supports the following platforms:
| Platform | Support |
|---|---|
| Android | Android 7.0+ (API level 24+) |
| Java | Java 8+ |
[!NOTE] Key functionality such as sending and receiving messages is powered by the ably-java library. The
ably-javalibrary is included as an api dependency within the Chat SDK, so there is no need to manually add it to your project.
The Ably Chat SDK is available on the Maven Central Repository. To include the dependency in your project, add the following to your build.gradle file:
For Groovy:
implementation 'com.ably.chat:chat:1.2.0'For Kotlin Script (build.gradle.kts):
implementation("com.ably.chat:chat:1.2.0")For Android (build.gradle.kts):
implementation("com.ably.chat:chat:1.2.0")
implementation("com.ably.chat:chat-extensions-compose:1.2.0")The following code connects to Ably's chat service, subscribes to a chat room, and sends a message to that room:
import com.ably.chat.ChatClient
import com.ably.chat.RoomOptions
import com.ably.chat.RoomStatus
import io.ably.lib.realtime.AblyRealtime
import io.ably.lib.types.ClientOptions
// Initialize Ably Realtime client
val realtimeClient = AblyRealtime(
ClientOptions().apply {
key = "<your-ably-api-key>"
clientId = "your-client-id"
}
)
// Create a chat client
val chatClient = ChatClient(realtimeClient)
// Get a chat room
val room = chatClient.rooms.get("my-room", RoomOptions())
// Monitor room status
room.onStatusChange { statusChange ->
when (statusChange.current) {
RoomStatus.Attached -> println("Room is attached")
RoomStatus.Detached -> println("Room is detached")
RoomStatus.Failed -> println("Room failed: ${statusChange.error}")
else -> println("Room status: ${statusChange.current}")
}
}
// Attach to the room
room.attach()
// Subscribe to messages
val subscription = room.messages.subscribe { message ->
println("Received message: ${message.text}")
}
// Send a message
room.messages.send(text = "Hello, World!")The CHANGELOG.md contains details of the latest releases for this SDK. You can also view all Ably releases on changelog.ably.com.
Read the CONTRIBUTING.md guidelines to contribute to Ably or Share feedback or request a new feature.
For help or technical support, visit Ably's support page. You can also view the community-reported GitHub issues or raise one yourself.
Ably Chat is a set of purpose-built APIs for a host of chat features enabling you to create 1:1, 1:Many, Many:1 and Many:Many chat rooms for any scale. It is designed to meet a wide range of chat use cases, such as livestreams, in-game communication, customer support, or social interactions in SaaS products. Built on Ably's core service, it abstracts complex details to enable efficient chat architectures.
Everything you need to get started with Ably Chat for JVM and Android:
Ably aims to support a wide range of platforms. If you experience any compatibility issues, open an issue in the repository or contact Ably support.
This SDK supports the following platforms:
| Platform | Support |
|---|---|
| Android | Android 7.0+ (API level 24+) |
| Java | Java 8+ |
[!NOTE] Key functionality such as sending and receiving messages is powered by the ably-java library. The
ably-javalibrary is included as an api dependency within the Chat SDK, so there is no need to manually add it to your project.
The Ably Chat SDK is available on the Maven Central Repository. To include the dependency in your project, add the following to your build.gradle file:
For Groovy:
implementation 'com.ably.chat:chat:1.2.0'For Kotlin Script (build.gradle.kts):
implementation("com.ably.chat:chat:1.2.0")For Android (build.gradle.kts):
implementation("com.ably.chat:chat:1.2.0")
implementation("com.ably.chat:chat-extensions-compose:1.2.0")The following code connects to Ably's chat service, subscribes to a chat room, and sends a message to that room:
import com.ably.chat.ChatClient
import com.ably.chat.RoomOptions
import com.ably.chat.RoomStatus
import io.ably.lib.realtime.AblyRealtime
import io.ably.lib.types.ClientOptions
// Initialize Ably Realtime client
val realtimeClient = AblyRealtime(
ClientOptions().apply {
key = "<your-ably-api-key>"
clientId = "your-client-id"
}
)
// Create a chat client
val chatClient = ChatClient(realtimeClient)
// Get a chat room
val room = chatClient.rooms.get("my-room", RoomOptions())
// Monitor room status
room.onStatusChange { statusChange ->
when (statusChange.current) {
RoomStatus.Attached -> println("Room is attached")
RoomStatus.Detached -> println("Room is detached")
RoomStatus.Failed -> println("Room failed: ${statusChange.error}")
else -> println("Room status: ${statusChange.current}")
}
}
// Attach to the room
room.attach()
// Subscribe to messages
val subscription = room.messages.subscribe { message ->
println("Received message: ${message.text}")
}
// Send a message
room.messages.send(text = "Hello, World!")The CHANGELOG.md contains details of the latest releases for this SDK. You can also view all Ably releases on changelog.ably.com.
Read the CONTRIBUTING.md guidelines to contribute to Ably or Share feedback or request a new feature.
For help or technical support, visit Ably's support page. You can also view the community-reported GitHub issues or raise one yourself.