Guide · Developer
How to Build a Voice Chat App
Build a voice chat app with VoltKit RTC: tokens from your backend, a room with a stage and listeners, raise hand, seats, speaking rings, chat and what it costs.
- Author
- VoltKit
- Published
- Reading time
- 9 min read
A voice chat app has two parts: the screen your users see, and the audio that has to reach everyone quickly and keep going when a phone changes network. With VoltKit RTC you build the first and call an API for the second. Your backend decides who may join and in what role, the SDK handles the microphone, the audio routing and reconnection, and the service runs the media servers.
This guide builds a voice chat room: a few people speak on a stage, everyone else listens, and a listener can raise a hand. A one-to-one voice call is the same room with two people in it, and it comes at the end. The examples are Kotlin (Android SDK). The same room works from the JavaScript, React Native and Flutter SDKs. The room, hand and seat calls are named the same in JavaScript and Flutter; audio routing is per platform.
Before you start
You need a VoltKit account and an RTC project; the quickstart creates both and gives you the API base URL and secret. VoltKit may ask you to verify the account before you create a project, which takes a minute.
A new project starts with every media option off. Open the project's Settings tab, find Media and quality, and switch on standard voice. Allowing a mode costs nothing by itself. Until you do, people can join the room but nobody can publish, and the SDKs refuse the microphone with the code media-disabled.
Step 1: choose the roles
Your backend chooses each person's role when it mints their token:
| Role | On stage (speaks) | Moderates | Typical use |
|---|---|---|---|
host | yes | yes | the room's owner |
cohost | yes | no | a speaker on stage |
moderator | no | yes | someone who keeps order |
viewer | no | no | a listener |
Roles change during the room without your backend: the host promotes a listener to cohost to bring them on stage and back to viewer to send them back.
Step 2: mint a token on your backend
The app never holds your API secret. Your backend signs the user in with your own login, creates the room if needed and returns a short-lived token for that person. With the Node.js server SDK:
// Create the room, or get it back if it already exists.
const room = await rtc.ensureRoom({ roomId: "show-42", hostIdentity: "user-7" });
// -> { roomId, originNode, hostToken, wsUrl, expiresAt, existed, ... }
// Let someone in, with the role YOU decide.
const { token, wsUrl, expiresAt } = await rtc.createToken({ roomId: "show-42", identity: "user-99", role: "viewer" });
const { room: live, participants } = await rtc.getRoom("show-42"); // the authoritative view
const { rooms } = await rtc.listRooms(); // every live room: an object, not an array
const people = await rtc.listParticipants("show-42"); // [{ identity, role, handRaised, muted, joinedAt, metadata }]
await rtc.deleteRoom("show-42"); // ends it for everyone
Ask for a token right before joining. Build a token server has the whole endpoint in Node.js, Spring Boot, Python, Go and PHP.
Step 3: join the room
val client = StreamClient(context, wsUrl, token)
scope.launch { client.participants.collect { roster -> renderRoom(roster) } } // kept current for you
scope.launch { client.onActiveSpeakers.collect { ids -> highlight(ids) } } // who is talking now
scope.launch { client.onTrackMuted.collect { m -> showMuted(m.identity, m.paused) } }
val join = client.connect(mapOf("name" to "Ravi", "avatar" to avatarUrl))
if (join.role.canPublish) client.publish(PublishOptions(video = false)) // hosts and speakers
participants is a StateFlow of everyone in the room, yourself included, with each person's role, the metadata they joined with, and whether their hand is raised. It follows the room's events, so you never refetch it. Remote audio plays by itself: there is nothing to subscribe to and nothing to render.
Ask for RECORD_AUDIO before publish(). Without it, publish() throws media-unavailable. A listener does not publish, so ask when they come on stage.
Step 4: raise a hand and bring someone on stage
// A listener asks to speak, saying for which seat:
client.raiseHand(mapOf("slot" to "seat-3"))
client.lowerHand() // changed their mind
// The host sees the requests:
scope.launch {
client.onHandRaised.collect { hand ->
if (hand.raised) showRequest(hand.identity, hand.slot) else removeRequest(hand.identity)
}
}
client.promote("user-42", Role.cohost) // accept: on stage
client.lowerHand("user-42") // decline (reason "declined")
client.promote("user-42", Role.viewer) // back to the audience
client.release("seat-3") // and free their seat: a role change leaves it
On the listener's side, a promotion arrives as onRoleChanged for their own identity. That is the moment to publish:
scope.launch {
client.onRoleChanged.collect { change ->
if (change.identity != client.identity) return@collect
if (change.role.canPublish) {
try {
client.publish(PublishOptions(video = false)) // brought on stage: speak
} catch (e: RpcError) {
if (e.code != "disconnected") showError(e.code) // disconnected: redone after the move
}
} else {
showListenerUi() // sent back to the audience
}
}
}
A speaker sent back to the audience stops publishing by itself: the microphone is released and everyone sees onTrackEnded.
Step 5: seats
Most voice chat rooms draw a grid of seats. Seats are named slots one person holds at a time, kept by the server:
client.claim("seat-3") // slot-taken, slot-blocked
client.release("seat-3")
client.claim("seat-5", identity = "user-42") // moderators may seat someone
client.blockSlot("seat-8") // moderators: lock an empty seat (slot-occupied while held)
scope.launch { client.onClaimChanged.collect { c -> drawSeat(c.key, c.identity, c.state) } } // held, away, free, blocked
A holder whose connection drops keeps the seat for a grace window, with the state away. Draw it as still taken, greyed.
Step 6: show who is speaking
scope.launch {
client.onAudioLevels.collect { levels -> // twice a second while collected
levels.forEach { seat(it.identity).ring(it.speaking) }
}
}
scope.launch { client.onActiveSpeakers.collect { ids -> spotlight(ids.firstOrNull()) } }
onAudioLevels covers every speaker you receive and your own microphone; onActiveSpeakers ranks who is talking, most active first, and fires only when the order changes.
Step 7: chat and music
Every room has a chat on the same connection: sendMessage, getMessages for history, deleteMessage, setTyping, and onMessage, onTyping and the rest. See Chat and live chat. Chat messages are not billed.
A host can play music from inside the app with publishMusic, so the song is never picked up by the microphone. React Native rejects publishMusic, and Flutter needs a native audio source on phones: the platforms table has each one. How to play music in a voice chat room has the switch and the code, and music sharing explains what the room hears.
One-to-one voice calls
A call is a room with two people, each publishing their microphone. Your backend creates a room for the call, mints a token for the caller (host) and one for the callee (cohost), and rings the callee through your own push channel with the call id. Both apps then connect and publish:
class CallViewModel(app: Application) : AndroidViewModel(app) {
private var client: StreamClient? = null
private var peerAway: Job? = null
val status = MutableStateFlow("connecting")
val peerMuted = MutableStateFlow(false)
fun start(wsUrl: String, token: String, speakerphone: Boolean) {
val c = StreamClient(getApplication(), wsUrl, token, StreamOptions(speakerphone = speakerphone))
client = c
// Collect before connect(): the other side may already be there.
viewModelScope.launch {
c.onTrackMuted.collect { m -> if (m.identity != c.identity && m.kind == "audio") peerMuted.value = m.paused }
}
viewModelScope.launch {
c.onParticipantLeft.collect { gone ->
if (gone.reason == "left") {
hangUp() // they hung up
} else {
status.value = "reconnecting…" // their connection dropped: give it time
peerAway = viewModelScope.launch { delay(30_000); hangUp() }
}
}
}
viewModelScope.launch { c.onParticipantJoined.collect { peerAway?.cancel(); status.value = "connected" } }
viewModelScope.launch {
c.onConnectionStateChanged.collect { s ->
status.value = when (s.state) {
ConnectionState.reconnecting -> "reconnecting…"
ConnectionState.connected -> "connected"
else -> status.value
}
}
}
viewModelScope.launch { c.onClosed.collect { reason -> status.value = "ended ($reason)" } }
viewModelScope.launch {
try {
c.connect(mapOf("name" to "Asha"))
c.publish(PublishOptions(video = false)) // the microphone only
} catch (e: RpcError) {
status.value = "failed: ${e.code}"
c.close()
}
}
}
fun setMuted(muted: Boolean) = viewModelScope.launch { client?.setMicEnabled(!muted) }
fun setSpeaker(on: Boolean) = client?.setSpeakerphoneOn(on)
fun hangUp() { client?.close() }
override fun onCleared() { client?.close() }
}
onParticipantLeft says why: left when the other side hung up, disconnected when their connection dropped. Their SDK then reconnects by itself and they come back, usually within seconds, so wait before ending the call. One-to-one voice calls covers ringing, the earpiece and speaker, and calls with the screen off, and the voice calling API page sets out what VoltKit does and what your app builds.
Test it
Test on two real phones, with one person speaking and one listening, and try the moments that go wrong: lock the screen, switch from Wi-Fi to mobile data, refuse the microphone permission. Put both phones on the loudspeaker, in different rooms, with both people speaking: if one person hears their own voice back, the cause is the other phone, and Echo shows how to find it and what to change. On a change from Wi-Fi to mobile data the SDK repairs the media path without dropping the call. A host on a weak connection can check it first:
Check a connection with theInternet Speed TestWhat it costs
Each connected participant is billed per second, listeners included. A listener who receives only audio stays on a voice rate, and chat, API calls, tokens and an empty room cost nothing. On standard voice:
2 people × 10 minutes = 20 participant-minutes
20 participant-minutes × 39 ÷ 1,000 = 0.78 credits, ₹0.78 (≈ $0.01) at today's rate
Standard Voice: 39 credits per 1,000 participant-minutes. Billed per second, so a 7½-minute call costs 7½ minutes.
Prices are in Indian rupees; dollar figures are approximate, at ₹95 per US dollar on 24 October 2026, for orientation only. You are billed in rupees.
50 people × 60 minutes = 3,000 participant-minutes
3,000 participant-minutes × 39 ÷ 1,000 = 117 credits, ₹117.00 (≈ $1.23) at today's rate
Standard Voice: 39 credits per 1,000 participant-minutes. Billed per second, so a 7½-minute call costs 7½ minutes.
What is a participant-minute? explains the unit, and pricing in India has a calculator for your own rooms.
Where to go next
- Group audio rooms: moderation, room settings and large rooms.
- Voice chat rooms: what VoltKit does and what your app builds, at a glance.
- Android SDK and Flutter SDK: the SDK for your platform.
- Build a live audio room with React Native and add voice chat to a browser game: the same room on React Native and in a web game.
While you develop, the JWT Decoder shows a test token's expiry on your own device and never sends it anywhere:
Inspect a test token with theJWT DecoderUse test tokens only: a token is a credential for a room, and production tokens belong nowhere but the app that asked for them.
Frequently asked questions
What do I need to build a voice chat app?
Your own app and a small backend. The backend creates rooms and mints a short-lived token for each person, with the role you choose. The app connects with the token and publishes the microphone. VoltKit RTC runs the media servers, so you have none to run.
What is the difference between a voice call and a voice chat room?
A voice call is a room with two people, both publishing their microphone. A voice chat room has a few speakers on a stage and many listeners who only receive, and a listener can raise a hand and be brought on stage.
Which platforms can I build a voice chat app for?
The examples here are Kotlin for Android. The same room works from a website and from phones, through the JavaScript, React Native and Flutter SDKs. The room, hand and seat calls are named the same in JavaScript and Flutter; audio routing is per platform.
How much does a voice chat room cost?
VoltKit RTC bills each connected participant per second, listeners included, at the rate of the media they use. A listener who receives only audio stays on a voice rate. Chat messages, API calls and tokens are not billed, and a room costs nothing until someone joins. This guide works out two sessions at the live rates.
Do listeners need microphone permission?
No. A listener only receives, so ask for microphone permission when someone is brought on stage. Without it, publish fails with the code media-unavailable.
Can a host play music in the voice room?
Yes, on Android and in the browser, with publishMusic, which plays music from inside the app so the microphone never picks it up. A Flutter host needs a native audio source on phones, and React Native cannot publish music. In a voice project it needs the music add-on switched on in the project's settings.