Package 

Interface ConversationSession


  • 
    public interface ConversationSession
    
                        

    Represents 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 Unit start() Start the conversation session This initiates the connection and begins listening for events
      abstract Unit endSession() End the conversation session This closes the connection and cleans up resources
      abstract Unit sendUserMessage(String message) Send a text message to the agent
      abstract Unit sendFeedback(Boolean isPositive) Send feedback for the last agent response
      abstract Unit sendContextualUpdate(String update) Send contextual information without triggering a response
      abstract String getId() Get the current conversation ID (e.g., conv_...) Returns null until the session is connected and the ID is known.
      abstract Unit sendUserActivity() Notify the agent that the user is actively typing
      abstract Unit sendToolResult(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 Unit toggleMute() Toggle microphone mute state
      abstract Unit setMicMuted(Boolean muted) Set microphone mute state
      abstract Unit setMicrophoneMuted(Boolean muted) Mute the microphone at the OS/track level
      abstract Unit setVolume(Float volume) Set the playback volume
      abstract Float getVolume() Get the current playback volume
      abstract Unit registerTool(String name, ClientTool tool) Register a client tool that can be called by the agent
      abstract Unit unregisterTool(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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 agent
        isError - Whether the tool execution resulted in an error
      • 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.
      • getVolume

         abstract Float getVolume()

        Get the current playback volume

      • 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 use
        tool - Implementation of the tool functionality
      • unregisterTool

         abstract Unit unregisterTool(String name)

        Unregister a previously registered client tool

        Parameters:
        name - Tool identifier to remove
      • 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