---
title: "Getting Started with the Airia Mobile SDK"
---


AiriaKit contains Chat and Document functionality along with all UI components.

Chat functionality enables developer to integrate chatUI (AI Chat functionality provided by the Airia platform).
Document functionality enables documents to be fetched and available for download along with the functionality to interact with the documents through the chat UI

## Setup

Clients will need to provide the required configuration before using any component from the AiriaKit else they will see a crash with configuration not set. They need to call the below method:

```
AiriaKit.setup(config: AiriaKit.Configuration)
```

The AiriaKIt.Configuration object needs the minimal config along with all Agent names that are required by the chat functionality.

Below is an example. This can be called in AppDelagate's `didFinishLaunchingWithOptions` method

```Swift
    func setUpModules() {
        // Pass all chat related required pipeline names
        let pipelineConfig = AiriaKit.PipelineConfig(
            suggestedResponses: "airia_get_suggesteduserresponses",
            suggestedChatName: "chat_name_suggestion",
            returningUserPrompt: "airia_chat_returninguser",
            newUserPrompt: "airia_chat_newuser",
            getQuickPrompts: "airia_get_quickprompts"
        )
        AiriaKit.setup(
            AiriaKit.Configuration(
                bundleID: AppInfo.bundleID,
                build: AppInfo.build,
                version: AppInfo.version,
                hostname: AppInfo.hostname,
                apiKey: AppInfo.apiKey,
                dataSourceID: AppInfo.dataSourceId,
                icloudContainerId: AppInfo.icloudContainerId,
                chatPersonaName: AppInfo.chatPersonaName,
                pipelineConfig: pipelineConfig,
                authTokenProvider: {
                    // if authenticating via Airia APIKey, return an empty string here
                    return authToken
                }
            )
        )
    }
```

**Note**

You can generate an Airia APIKey from the Admin Platform. If authenticating via Airia APIKey, please provide the API Key via the `apiKey` object in the `AiriaKit.Configuration` step above, and leave the `authTokenProvider` blank. If an Airia APIKey is not provided, the SDK will default authentication to our plaform-provided authentication server. It is important to note that if this route is selected, users of the SDK from within the client app will need to provide their Airia Email and Password to login.

#### iCloudConatainerId

Clients will need to create a iClould containerID specific to their app and pass the identifier here.
(Note: Log the explicit error here for clients to know whats missing)

#### InfoPlist entries

CameraUsage: Clients will need to provide camera related entries into the info plist for scanning related functionality

### Integrating ChatSDK

Below is the minimal View and ViewModel required for Clients to configure the AiriaChatSDKView in a SwiftUI view.

#### View

```Swift
import SwiftUI
import AiriaKit
struct AiriaChatSDKView: View {
    @State private var viewModel = AiriaChatSDKViewModel()
    var body: some View {
        Group {
            if viewModel.isInitializingChatSDK {
                Text("Initializing AiriaKit Chat SDK ....")
            } else {
                AiriaChatView()
            }
        }
        .task {
            await viewModel.initialChatSDK()
        }
    }
}
#Preview {
    AiriaChatSDKView()
}
```

#### ViewModel

```Swift
import Foundation
import AiriaKit
@Observable class AiriaChatSDKViewModel {
    @ObservationIgnored
    let chatSDK = ChatSDK.shared
    var isInitializingChatSDK = true
    init() {
        chatSDK.clientDelegate = self
    }
    func initialChatSDK() async {
        chatSDK.start()
        //load user, will throw if no user does not exist
        do {
            try await chatSDK.loadUser()
            isInitializingChatSDK = false
        } catch _ {
            print("creating new user")
            let id = UUID()
            // App can manage the UDID
            do {
                try await chatSDK.createUser(userID: id)
                isInitializingChatSDK = false
            } catch let err {
                print("failed to load user: \(err)")
            }
        }
    }
}
extension AiriaChatSDKViewModel: ChatSDKDelegateProtocol {
    func track(event: String, category: String, action: String, value: Float) {
        // track chat event
    }
    func capture(_ userFeedback: UserFeedbackObj) {
        // do something with the user feedback Obj
    }
}
```

ChatSDK class is the main interface for chat related functionality and can be accessed via the shared singleton instance. The only requirement is that start() has been called and user has been configured before `AiriaChatSDKView` has been added.

### User Management

Cuurently Airia platform rest calls just need a explicit UDID and ties the user with UDID. Clients can manage the UDID at their end as well.
In future this will change to a JWT authentication token that will be passed via the same interface. Client app will be responsible for authentication and ChatSDK will provide a callback to refresh the token.

### Callbacks

ChatSDKDelegateProtocol provides delegate callbacks to app. This will have more functionality as AiriaKit evolves.