Graine AI

Chat: the window, its sizes and the Garage's controls

Open the SDK's chat window at the size you want — compact, large or full screen — or place it yourself, send for the user, hear the agent speak up first, draw your own chat from the turns, and set every piece the window shows in the Garage.

The agent typed, in your design: bubbles, the components it draws, the user's booked calls, the earlier conversation and New conversation. The bar carries the chat already where the agent offers it; this page is for opening it at a size, placing it on a screen of your own, and drawing your own.

The chat window on an iPhone, mid-conversation with a component, beside the dashboard's Android preview of a new chat with its starters

What it needs in the dashboard

WhereSettingValue
Agent → Embed & Widgets → Appearance → SetupWhat visitors getChat, or Call and chat for both with a switch
Embed & Widgets → Appearance → the Garage → Chat tabWindow sizeCompact (the window above the bar), Large (a sheet over most of a phone) or Full screen
The Garage → Chat tabTitle and subtitle, Avatar, Header, Background, Starters, Composer → Placeholder, TimestampsWhat the window says and how it looks
The Garage → Chat tabBooked calls, Earlier messages, New conversation buttonWhich pieces it draws

Every control, with what it changes: The Garage → The chat window.

What to do, in order

  1. Configure the SDK (install) and, for a chat that continues, identify the user.
  2. Open the chat — from the bar's switch, from your own button at a size, or as a screen of your own. → It connects, shows the earlier messages for a returning user, else the welcome and your starters.
  3. Send for the user if a button of yours should start the conversation. → The message shows at once; typed offline, it waits and goes when the chat reconnects.
  4. Hear the agent speak up first — badge or open your chat when it does.
  5. Draw your own chat from the turns, if the SDK's window does not fit.
  6. Close it when the user leaves the screen: the chat hangs up; what was said stays.

The size, in order of precedence: the open call's own argument, then your config's chatSize, then the Garage's Window size.

The code, platform by platform

2. Open it — with the bar on screen, from any button, at a size for this open:

GraineInApp.shared.chat.open(size: .large)         // .compact, .large or .full; nil: the config's, then the Garage's

→ The bar moves to the chat and draws it as a sheet. Or place the chat yourself:

struct SupportScreen: View {
    @State private var chatOpen = false
    var body: some View {
        Button("Chat with us") { chatOpen = true }
            .fullScreenCover(isPresented: $chatOpen) {
                GraineChatView(onClose: { chatOpen = false })      // the window, filling what it is given
            }
    }
}

UIKit: present GraineChatViewController().

3. Send for the user: GraineInApp.shared.chat.send("Where is my order?").

4. The agent spoke up first:

final class ChatBadge: GraineListener {
    func onChatMessage(_ turn: GraineChatTurn) {
        if turn.proactive { print("Badge the chat button: \(turn.text)") }
    }
}

5. Your own chat — GraineChat is an ObservableObject:

struct MyChat: View {
    @ObservedObject var chat = GraineInApp.shared.chat
    var body: some View {
        List(chat.turns) { turn in
            Text(turn.text).foregroundStyle(turn.role == .agent ? .primary : .secondary)
        }
        .onAppear { chat.open() }
        .onDisappear { chat.close() }
    }
}

→ turns (oldest first; restored for earlier messages, channel .voice for lines said on a call), status, typing, upcomingCalls.

6. Close it: GraineInApp.shared.chat.close().

Troubleshooting

What you seeWhyFix
chat.open() does nothing visibleNo bar on screen: open connects and moves a mounted bar to the chatMount the bar, or show the chat view (GraineChatView, GraineChatActivity, GraineChat, GraineChatScreen)
The window is compact whatever the Garage saysA chatSize in your config or the open call winsRemove the override
Offline after a dropSix retries failed (1, 2, 4, 8, 15, 15 s)The next message, or retry(), tries again
No Book a call in the chatBooking is not available for this user, or Booked calls is hiddenBooking with the SDK's sheet

In depth: Chat · the chat object on each platform: SDK reference → Chat.

On this page