NowVoiceSDK object - Android
The NowVoiceSDK factory object creates NowVoiceService instances.
Use NowVoiceService to start and manage voice agent sessions.
For more information about configuring NowVoice, including prerequisites and call order, see Embed an AI voice agent with NowVoice.
NowVoiceSDK - makeVoiceService(instanceURL: URL)
Creates a NowVoiceService instance for the specified ServiceNow instance. This is a suspend function.
Call from a coroutine after NowSDK.configure() has been called. This function fetches instance settings over the network, validates that voice is enabled on the instance, and retrieves available voice endpoint configurations.
Throws NowServiceError on failure.
| Name | Type | Description |
|---|---|---|
| instanceURL | URL | URL of the ServiceNow instance, for example
URL("https://instancename.service-now.com"). |
| Type | Description |
|---|---|
| Result<NowVoiceService> | Result.success(NowVoiceService) if initialization succeeds,
or Result.failure(NowServiceError) if setup fails. |
The following code example creates an instance of NowVoiceService.
import com.servicenow.nowsdk.voice.NowVoiceSDK
import kotlinx.coroutines.launch
import java.net.URL
lifecycleScope.launch {
val result = NowVoiceSDK.makeVoiceService(
instanceURL = URL("https://your-instance.service-now.com")
)
result
.onSuccess { voiceService ->
// Service is ready; proceed to select an endpoint
}
.onFailure { error ->
// Handle NowServiceError
Log.e("NowVoice", "Service creation failed: $error")
}
}