Loops AI Docs

Quickstart

Present the Loops assistant in a few lines — SwiftUI or UIKit.

Present the assistant with your agentId. That's the minimum integration.

import SwiftUI
import LoopsAIChatSDK

struct ContentView: View {
  @State private var showChat = false

  var body: some View {
    Button("Ask the assistant") { showChat = true }
      .sheet(isPresented: $showChat) {
        LoopsAIChatView(
          config: LoopsAIChatConfig(agentId: "YOUR_AGENT_ID"),
          onClose: { showChat = false }
        )
        .ignoresSafeArea()
      }
  }
}
import UIKit
import LoopsAIChatSDK

final class ProductViewController: UIViewController {
  @objc func openChat() {
    let config = LoopsAIChatConfig(agentId: "YOUR_AGENT_ID")
    LoopsAIChat.present(from: self, config: config, style: .fullScreen)
  }
}

Add product context

On a product page, tell the assistant what the user is looking at so its answers and try-on are relevant:

let config = LoopsAIChatConfig(
  agentId: "YOUR_AGENT_ID",
  initialContext: LoopsAIChatContext(
    productContext: ["productCode": "SKU123", "productName": "Linen Shirt"]
  )
)
LoopsAIChat.present(from: self, config: config)

Observe what happens

Pass a delegate (UIKit) or closures (SwiftUI) to react to chat events:

LoopsAIChat.present(from: self, config: config, delegate: self)

extension ProductViewController: LoopsAIChatDelegate {
  func loopsAIChatDidBecomeReady(_ vc: LoopsAIChatViewController) { /* push context */ }
  func loopsAIChat(_ vc: LoopsAIChatViewController, isResponding: Bool) { /* spinner */ }
  func loopsAIChat(_ vc: LoopsAIChatViewController, didFailWith error: LoopsError) { /* log */ }
}

All delegate methods are optional and have sensible defaults — didRequestClose dismisses/pops, didRequestOpenURL opens the system browser.

Next: Configuration.

On this page