Agent Runtime with iOS
VideoSDK empowers you to integrate an AI voice agent into your iOS app within minutes. This guide shows you how to connect an iOS (SwiftUI) frontend with an AI agent created and configured entirely from the VideoSDK dashboard.
Prerequisites
- macOS with Xcode 15.0+
- iOS 13.0+ deployment target
- Valid VideoSDK Account
- Familiarity with creating a no-code voice agent. If you're new to this, please follow our guide on how to Build a Custom Voice AI Agent in Minutes first.
You need a VideoSDK account to generate a token and an agent from the dashboard.
Step 1: Clone the sample project
Clone the repository to your local environment.
git clone https://github.com/videosdk-live/agents-quickstart.git
cd mobile-quickstarts/ios/
Step 2: Environment Configuration
Create a Meeting Room
Create a meeting room using the VideoSDK API:
curl -X POST https://api.videosdk.live/v2/rooms \
-H "Authorization: YOUR_VIDEOSDK_AUTH_TOKEN" \
-H "Content-Type: application/json"
Use the returned roomId in your configuration files.
Configuration Files
Update the following files with your credentials. The Agent and Version IDs will be retrieved in a later step.
MeetingViewController.swift (line 14):
var token = "YOUR_VIDEOSDK_AUTH_TOKEN" // Add Your token here
var agentId = "YOUR_AGENT_ID"
var versionId = "YOUR_VERSION_ID"
JoinScreenView.swift (line 13):
let meetingId: String = "YOUR_MEETING_ID"
Step 3: iOS Frontend Modifications
Step 1: Add Connect Agent Button
In MeetingView.swift, add a button to connect the agent.
// Add this button to your view hierarchy
Button(action: {
meetingVC.connectAgent()
}) {
Text("Connect Agent")
}
.disabled(meetingVC.isAgentConnected)
Step 2: Implement Connect Logic
In MeetingViewController.swift, add the logic to call the dispatch API.
// Add state to track if the agent is connected
@Published var isAgentConnected = false
// ...
func connectAgent() {
guard let url = URL(string: "https://api.videosdk.live/v2/agent/general/dispatch") else { return }
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue(token, forHTTPHeaderField: "Authorization")
let body: [String: Any] = [
"agentId": agentId,
"meetingId": room?.id ?? "",
"versionId": versionId
]
request.httpBody = try? JSONSerialization.data(withJSONObject: body)
URLSession.shared.dataTask(with: request) { data, response, error in
if let error = error {
print("Connect error: \(error.localizedDescription)")
return
}
if let httpResponse = response as? HTTPURLResponse, httpResponse.statusCode == 200 {
DispatchQueue.main.async {
self.isAgentConnected = true
print("Agent connected successfully")
}
} else {
print("Failed to connect agent")
}
}.resume()
}
Step 4: Creating the AI Agent from Dashboard (No-Code)
Step 1: Create Your Agent
First, follow our detailed guide to Build a Custom Voice AI Agent in Minutes. This will walk you through creating the agent's persona, configuring its pipeline (Realtime or Cascading), and testing it directly from the dashboard.
Step 2: Get Agent and Version ID
Once your agent is created, you need to get its agentId and versionId to connect it to your frontend application.
-
After creating your agent, go to the agent's page and find the JSON editor on right side. Copy the
agentId. -
To get the
versionId, click on 3 dots besides Deploy button and click on "Version History" in it. Copy the version id via copy button of the version you want.

Step 3: Configure IDs in Frontend
Now, update your MeetingViewController.swift file with these IDs.
var agentId = "paste_your_agent_id_here"
var versionId = "paste_your_version_id_here"
Step 5: Run the iOS Frontend
-
Open Xcode:
open videosdk-agents-quickstart-ios.xcodeproj -
Configure your development team:
- Select the project in Xcode
- Go to "Signing & Capabilities"
- Select your development team
-
Build and run:
- Select your target device or simulator
- Press
Cmd + Rto build and run
Step 6: Connect and Interact
- Join the meeting from the app and allow microphone permissions.
- When you join, click the "Connect Agent" button to call the agent into the meeting.
- Talk to the agent in real time.
Troubleshooting
Common Issues
-
Build Errors:
- Ensure Xcode 15.0+ is installed
- Check iOS deployment target (13.0+)
- Verify VideoSDK package dependency
-
Authentication Issues:
- Verify
VIDEOSDK_AUTH_TOKENinMeetingViewController.swift - Check token permissions include
allow_join
- Verify
-
Meeting Connection Issues:
- Ensure
YOUR_MEETING_IDis correct - Verify network connectivity
- Check VideoSDK account status
- Ensure
-
AI Agent Issues:
- Verify
agentIdandversionIdare set correctly - Check for errors in the Xcode console when connecting the agent.
- Verify
Got a Question? Ask us on discord

