Graine AI

Install the SDK and get the first answer

From an empty project to the agent answering in your app or on your website: the package, the permissions, configure at launch, the bar, and how to know the agent's settings loaded — on iOS, Android, Flutter, React Native, Kotlin Multiplatform and the web.

The smallest integration that works end to end: the SDK installed, configured once with the agent's publishable key, and the assistant bar on screen. When it works, the launcher appears in your design, and the agent greets you when you open it. About 30 minutes.

What it needs in the dashboard

WhereSettingValue
Agent → Embed & WidgetsSet up embeddingDone once per agent; it creates the publishable key
Agent → Embed & Widgets → InstallPublishable keyCopy the pk_live_… key into your app. It is public by design: it selects the agent and cannot read your data
Agent → Embed & Widgets → InstallAllowed domainsapp:// for apps; each website host, staging included, for the web
Agent → Embed & Widgets → AppearanceWhat visitors getCall, chat, or both with a switch

The agent itself — its prompt, voice and greeting — is whatever you built in the dashboard; test it there first.

What to do, in order

  1. Install the package, and declare the microphone (the voice bar asks for it when a call starts).
  2. Configure once, at launch, with baseUrl https://www.graine.ai and the publishable key. The SDK loads the agent's settings — its design, what visitors get, its actions, its calling and booking rules — and keeps them on the device, so the next launch starts at once.
  3. Put the bar on screen. It draws the launcher, the voice call, the chat and the components in your design.
  4. Check the settings loaded — a listener, a hook or a promise, per platform.
  5. Open the bar and talk, or type. The agent greets you.
  6. Clean up only what you added yourself: a listener you registered.

The code, platform by platform

1. Install. Xcode → File → Add Package Dependencies… → https://github.com/GraineAI/inapp-ios, from 0.9.0; add the GraineInApp library to your app target. Add NSMicrophoneUsageDescription to Info.plist.

2. Configure at launch — once, before any screen uses the agent:

import SwiftUI
import GraineInApp
 
final class AppDelegate: NSObject, UIApplicationDelegate {
    func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
        GraineInApp.configure(GraineConfig(
            baseUrl: "https://www.graine.ai",
            publishableKey: "pk_live_…",          // Agent → Embed & Widgets → Install
            appVersion: "2.4.0"                   // lands on every call record
        ))
        return true
    }
}

→ GraineInApp.shared is the agent from now on; the settings load in the background.

3. Put the bar on screen:

struct RootView: View {
    var body: some View {
        AppContent()
            .overlay(GraineAgentBar())                                    // the launcher, voice and chat
            .overlay(alignment: .bottom) {
                GraineWidgetView().padding(.horizontal, 12).padding(.bottom, 96)   // the components the agent shows
            }
    }
}
 
struct AppContent: View { var body: some View { Text("Your app") } }

→ The launcher appears in your design once the settings arrive.

4. Check the settings loaded:

final class GraineStatus: GraineListener {
    func onSessionReady(_ session: GraineSessionConfig) {
        print("Agent \(session.agentId) loaded; memory on: \(session.memoryEnabled ?? false)")
    }
    func onError(_ message: String) {
        print("Graine: \(message)")                                       // a refused key or domain says so here
    }
}
 
let status = GraineStatus()
GraineInApp.shared.addListener(status)                                    // held weakly: keep `status` alive

→ onSessionReady fires once per launch with a GraineSessionConfig; GraineInApp.shared.session holds it afterwards.

5. The first answer. Tap the launcher and speak, or switch to the chat and type. → The agent greets you; captions show under the bar.

6. Clean up: GraineInApp.shared.removeListener(status) when the screen that added it goes away.

Troubleshooting

What you seeWhyFix
Nothing appears; the log or console says 403 or origin_refusedapp:// (apps) or the site's exact host is missing from Allowed domainsAdd it under Embed & Widgets → Install
Nothing appears; invalid_keyThe key is not one, or the agent was deletedCopy the key again from Embed & Widgets → Install
The bar shows Needs microphoneThe microphone was not declared, or the customer refused itPermissions
The design is the default oneThe settings have not loaded yet, or the design was not savedWait for the settings; Save design in the Garage, then restart the app
The agent never speaksThe agent has no greeting, or the call never connectedTry the agent in the dashboard first; Voice → Troubleshooting

Next: identify the user, then every other use case — Use cases by SDK.

On this page