Elizon Docs
Voice Integration

Session Management

Ending a call and controlling the microphone during a voice session.

Ending the session

Call room.disconnect() when the user hangs up, navigates away, or the component unmounts. The Elizon voice agent worker detects the LiveKit disconnect and fires an audio_session_ended event on its side — you don't need to call any Elizon API to close the session.

room.on(RoomEvent.Disconnected, () => {
  // update your own UI state back to "idle"
})

room.disconnect()

Always disconnect on unmount too, not just on an explicit "end call" action — an open Room left dangling keeps the microphone stream active.

// Swift
room.disconnect()

Audio controls

Checking mic state

const micEnabled = room.localParticipant.isMicrophoneEnabled

Muting and unmuting

await room.localParticipant.setMicrophoneEnabled(false) // mute
await room.localParticipant.setMicrophoneEnabled(true) // unmute
// Swift
try await room.localParticipant.setMicrophone(enabled: false) // mute
try await room.localParticipant.setMicrophone(enabled: true) // unmute

setMicrophoneEnabled(false) stops publishing your audio track — the agent can no longer hear you, but you can still hear the agent. It's a no-op if the mic is already in that state, so it's safe to call from a toggle handler without tracking extra state yourself.