Embed an AI voice agent with NowVoice
Use the NowVoice module to embed a real-time AI voice agent session into your iOS application.
NowVoice features
NowVoice gives your app a complete, ready-to-present voice agent UI. 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.
- Renders a full-screen native SwiftUI view with 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.
Theming
NowVoice integrates with the NowUI theming system. Pass any type conforming to NowVoiceThemeable to apply custom colors. NowVoiceDefaultTheme is provided as a default.
NowChat integration
If your app uses NowChat, you can enable NowVoice in the chat interface. Set NowChatConfiguration properties to configure voice within the NowChat UI and add a voice button. Tapping it launches the voice agent UI as a full-screen overlay within the chat
flow.
Mobile SDK instance settings
The NowVoice module reads the following keys from your ServiceNow instance's Mobile SDK settings response.
{
"sdk": {
"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 iOS application.
Before you begin
Role required: admin
- Mobile SDK 2.22.0 or later must be added to your Xcode project via Swift Package Manager.
- Your ServiceNow instance must have voice agent services enabled. Confirm that
sdk.voice.enabledistruein the Mobile SDK settings.
Procedure
Result
The voice agent UI is presented 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 NowSDK
import NowVoice
// --- App launch ---
try NowSDK.configure(with: NowSDKConfiguration(
authorizationProvider: self,
permissionDelegate: self
))
// --- When the user taps "Start Voice" ---
func startVoiceSession() async {
let instanceUrl = URL(string: "https://your-instance.service-now.com")!
do {
let voiceService = try await NowVoice.makeVoiceService(instanceUrl: instanceUrl)
guard let endpoint = voiceService.configurations.first else { return }
let vc = try await voiceService.startVoice(
endpoint: endpoint,
callbacks: NowVoiceCallbacks(
onMuteStateChanged: { [weak self] isMuted in
self?.updateMuteIndicator(isMuted: isMuted)
},
onMessageReceived: { [weak self] message in
self?.appendTranscript(message)
},
onCallEnded: { [weak self] _, error in
self?.dismiss(animated: true)
}
)
)
vc.modalPresentationStyle = .fullScreen
present(vc, animated: true)
} catch let error as NowServiceError {
handleServiceError(error)
}
}