-
public interface ConversationSessionRepresents an active conversation session with an ElevenLabs agent
This class provides reactive access to conversation state and enables real-time communication with AI agents through text and voice.
The session follows an event-driven architecture with observable state that can be used for UI binding in Android applications.
-
-
Method Summary
Modifier and Type Method Description abstract Unitstart()Start the conversation session This initiates the connection and begins listening for events abstract UnitendSession()End the conversation session This closes the connection and cleans up resources abstract UnitsendUserMessage(String message)Send a text message to the agent abstract UnitsendFeedback(Boolean isPositive)Send feedback for the last agent response abstract UnitsendContextualUpdate(String update)Send contextual information without triggering a response abstract StringgetId()Get the current conversation ID (e.g., conv_...) Returns null until the session is connected and the ID is known. abstract UnitsendUserActivity()Notify the agent that the user is actively typing abstract UnitsendToolResult(String toolCallId, String result, Boolean isError)Send the result of a client tool execution back to the agentThis method is useful for handling dynamic client tools that are not registered in the ClientToolRegistry. abstract UnittoggleMute()Toggle microphone mute state abstract UnitsetMicMuted(Boolean muted)Set microphone mute state abstract UnitsetMicrophoneMuted(Boolean muted)Mute the microphone at the OS/track level abstract UnitsetVolume(Float volume)Set the playback volume abstract FloatgetVolume()Get the current playback volume abstract UnitregisterTool(String name, ClientTool tool)Register a client tool that can be called by the agent abstract UnitunregisterTool(String name)Unregister a previously registered client tool abstract StateFlow<ConversationStatus>getStatus()Current connection status of the conversation session abstract StateFlow<ConversationMode>getMode()Current conversation mode (listening/speaking) abstract StateFlow<List<Message>>getMessages()The conversation transcript, reconciled by the SDK. abstract StateFlow<Boolean>getIsMuted()Whether the microphone is currently muted abstract StateFlow<Float>getAudioLevel()Current audio level from the agent (0.0 to 1. -
-
Method Detail
-
start
abstract Unit start()
Start the conversation session This initiates the connection and begins listening for events
-
endSession
abstract Unit endSession()
End the conversation session This closes the connection and cleans up resources
-
sendUserMessage
abstract Unit sendUserMessage(String message)
Send a text message to the agent
- Parameters:
message- The message content to send
-
sendFeedback
abstract Unit sendFeedback(Boolean isPositive)
Send feedback for the last agent response
- Parameters:
isPositive- true for positive feedback, false for negative
-
sendContextualUpdate
abstract Unit sendContextualUpdate(String update)
Send contextual information without triggering a response
- Parameters:
update- Context information to send to the agent
-
getId
abstract String getId()
Get the current conversation ID (e.g., conv_...) Returns null until the session is connected and the ID is known.
-
sendUserActivity
abstract Unit sendUserActivity()
Notify the agent that the user is actively typing
-
sendToolResult
abstract Unit sendToolResult(String toolCallId, String result, Boolean isError)
Send the result of a client tool execution back to the agent
This method is useful for handling dynamic client tools that are not registered in the ClientToolRegistry. When using onUnhandledClientToolCall callback, you can execute your tool and then send the result back using this method.
- Parameters:
toolCallId- The unique identifier for the tool call (from ClientToolCall event)result- The result string to send back to the agentisError- Whether the tool execution resulted in an error
-
toggleMute
abstract Unit toggleMute()
Toggle microphone mute state
-
setMicMuted
abstract Unit setMicMuted(Boolean muted)
Set microphone mute state
- Parameters:
muted- true to mute, false to unmute
-
setMicrophoneMuted
abstract Unit setMicrophoneMuted(Boolean muted)
Mute the microphone at the OS/track level
- Parameters:
muted- true to mute, false to unmute
-
setVolume
abstract Unit setVolume(Float volume)
Set the playback volume
- Parameters:
volume- Volume level from 0.0 (silent) to 1.
-
registerTool
abstract Unit registerTool(String name, ClientTool tool)
Register a client tool that can be called by the agent
- Parameters:
name- Tool identifier that the agent will usetool- Implementation of the tool functionality
-
unregisterTool
abstract Unit unregisterTool(String name)
Unregister a previously registered client tool
- Parameters:
name- Tool identifier to remove
-
getStatus
abstract StateFlow<ConversationStatus> getStatus()
Current connection status of the conversation session
-
getMode
abstract StateFlow<ConversationMode> getMode()
Current conversation mode (listening/speaking)
-
getMessages
abstract StateFlow<List<Message>> getMessages()
The conversation transcript, reconciled by the SDK.
Emits the full, ordered list of Messages whenever it changes. Messages update in place via Message.isPartial as they stream in. Prefer this for UI binding over assembling a transcript from individual callbacks.
-
getIsMuted
abstract StateFlow<Boolean> getIsMuted()
Whether the microphone is currently muted
-
getAudioLevel
abstract StateFlow<Float> getAudioLevel()
Current audio level from the agent (0.0 to 1.0) Useful for animating UI elements based on agent voice volume
-
-
-
-