Here’s the minimal code to get a voice conversation working:
Copy
Ask AI
import OutspeedSDK// Create a session configurationlet config = OutspeedSDK.SessionConfig()// Create callbacks to handle eventslet callbacks = OutspeedSDK.Callbacks()callbacks.onMessage = { message, role in print("Received message from \(role.rawValue): \(message)")}callbacks.onError = { message, error in print("Error: \(message)")}callbacks.onStatusChange = { status in print("Status changed to: \(status.rawValue)")}// Start the conversationTask { do { let conversation = try await OutspeedSDK.Conversation.startSession( config: config, callbacks: callbacks, apiKey: "<YOUR_OUTSPEED_API_KEY>" ) // When done with the conversation conversation.endSession() } catch { print("Failed to start conversation: \(error)") }}
let agentConfig = OutspeedSDK.AgentConfig( prompt: "You are a helpful assistant with a witty personality.", firstMessage: "Hey there, how can I help you with Outspeed today?")let config = OutspeedSDK.SessionConfig( overrides: OutspeedSDK.ConversationConfigOverride(agent: agentConfig))