Embed an AI voice agent with NowVoice
Use the NowVoice module to embed a real-time AI voice agent session into your Android application.
NowVoice features
NowVoice gives your app a complete, ready-to-launch voice agent experience. When a user starts a voice agent session, the SDK:
- Authenticates against your ServiceNow instance using the token your app provides.
- Opens a WebSocket connection to the configured voice agent endpoint.
- Launches a full-screen
Activitywith microphone controls and a live transcript. - Delivers real-time transcript messages and mute-state changes to your app through callbacks.
- Shows an optional post-call transcript summary screen on session end.
All public types in the NowVoice module are in the com.servicenow.nowsdk.voice package.
Theming
NowVoice integrates with the NowUI theming system. Implement NowVoiceTheme to apply
custom colors. NowVoiceThemeDark is provided as a built-in alternative to the
default light theme.
Mobile SDK instance settings
The NowVoice module reads the following keys from your ServiceNow instance's Mobile SDK settings response.
{
"voice": {
"enabled": true,
"configurations": [
{
"voiceServiceId": "String",
"voiceWebhookURL": "String",
"mobileChannelType": "String",
"mobileChannelId": "String"
}
]
}
}
Configure NowVoice
Configure NowVoice to add a real-time voice agent to your Android application.
Before you begin
Role required: admin
- Mobile SDK 2.22.0 or later must be added to your project via Gradle.
- Your ServiceNow instance must have voice agent services
enabled. Confirm that
sdk.voice.enabledistruein the Mobile SDK settings.
Procedure
Result
The voice agent Activity launches full-screen. The user can begin a real-time voice session with transcript and mute-state updates delivered to your app through the configured callbacks.
Complete example
import com.servicenow.nowsdk.voice.*
import kotlinx.coroutines.launch
import java.net.URL
class MainActivity : AppCompatActivity() {
private fun launchVoiceSession() {
lifecycleScope.launch {
val result = NowVoiceSDK.makeVoiceService(
instanceURL = URL("https://your-instance.service-now.com")
)
result.onSuccess { voiceService ->
val endpoint = voiceService.nowVoiceEndpoints.firstOrNull() ?: return@onSuccess
voiceService.start(
context = this@MainActivity,
endpoint = endpoint,
callbacks = object : NowVoiceCallbacks {
override fun onCallEnd(conversationId: String?, error: NowVoiceError?) {
runOnUiThread { updateUI(ended = true) }
}
override fun onMuteStateChanged(isMuted: Boolean) {
runOnUiThread { updateMuteButton(isMuted) }
}
override fun onMessageReceived(message: TranscriptMessage) {
runOnUiThread { appendTranscript(message) }
}
}
)
}.onFailure { error ->
Log.e("NowVoice", "Failed: $error")
}
}
}
}