NowVoiceService class - Android

  • Release version: Zurich
  • Updated July 21, 2026
  • 1 minute to read
  • Manages voice agent sessions for a single ServiceNow instance.

    Note:
    Initialize a NowVoiceService by calling NowVoiceSDK - makeVoiceService(instanceURL: URL).
    Table 1. Properties
    Name Type Description
    configuration NowServiceConfiguration The service configuration for the ServiceNow instance.
    nowVoiceEndpoints List<NowVoiceEndpoint> Read-only. The list of available voice endpoint configurations retrieved from the instance.

    NowVoiceService - start(context: Context, endpoint: NowVoiceEndpoint, uiConfiguration: NowVoiceUiConfiguration, callbacks: NowVoiceCallbacks?, theme: NowVoiceTheme)

    Launches the full-screen voice agent Activity. This is a suspend function that returns after the session ends.

    Table 2. Parameters
    Name Type Description
    context Context An Android Context used to launch the voice Activity. Typically your current Activity.
    endpoint NowVoiceEndpoint The voice agent endpoint to connect to. Obtain from NowVoiceService.nowVoiceEndpoints.
    uiConfiguration NowVoiceUiConfiguration Optional. Presentation options for the voice agent UI. If omitted, uses the default values for NowVoiceUiConfiguration.
    callbacks NowVoiceCallbacks? Optional. Callbacks for voice session events. If null, events are silently ignored.
    theme NowVoiceTheme Optional. The visual theme applied to the voice UI.

    Default: The prebuilt light theme.

    Table 3. Returns
    Type Description
    None

    The following code example shows how to call this function.

    //voiceService is an initialized NowVoiceService
    val endpoint = voiceService.nowVoiceEndpoints.firstOrNull() ?: return
    
    voiceService.start(
        context = this@MainActivity,
        endpoint = endpoint,
        uiConfiguration = NowVoiceUiConfiguration(
            hidePostCallTranscript = false,
            shouldBlockAttachmentSharing = false
        ),
        callbacks = object : NowVoiceCallbacks {
            override fun onCallEnd(conversationId: String?, error: NowVoiceError?) {
                if (error != null) {
                    Log.e("NowVoice", "Session ended with error: $error")
                } else {
                    Log.d("NowVoice", "Session complete. ID: $conversationId")
                }
            }
    
            override fun onMuteStateChanged(isMuted: Boolean) {
                // Update your UI to reflect the current mute state
                Log.d("NowVoice", "Microphone muted: $isMuted")
            }
    
            override fun onMessageReceived(message: TranscriptMessage) {
                // Receive real-time transcript messages
                Log.d("NowVoice", "${message.role}: ${message.content}")
            }
        },
        theme = object : NowVoiceTheme {}  // Uses default light theme
    )

    NowVoiceService - updateTheme(theme: NowVoiceTheme)

    Updates the visual theme of the currently active voice UI.

    This function has no effect if no voice session is currently active. To apply a visual theme at voice session launch, provide a theme when calling start(context:endpoint:uiConfiguration:callbacks:theme:).

    Table 4. Parameters
    Name Type Description
    theme NowVoiceTheme The theme to apply to the active voice UI.
    Table 5. Returns
    Type Description
    None

    The following code example updates the visual theme of the currently active voice UI.

    //voiceService is an initialized NowVoiceService
    voiceService.updateTheme(NowVoiceThemeDark())