The agent's settings
Everything the dashboard decided, in one call — so a custom interface does not quietly lose it.
The account configures the agent in the dashboard: its name, how it greets people, the questions it offers, the colours, the language. Building your own interface should not mean losing any of that. If the shop owner changes the greeting on Monday, your interface should say the new one on Monday, without a deploy.
config()
The minimal call
const agent = await tigerbase.config();
agent.botName; // "Pine"
agent.starterQuestions; // ["Do you deliver to Leeds?", …]A realistic one
Harbor & Pine’s chat panel paints its header and its empty state from the settings, so the copy is the shop’s, not the developer’s.
import type { AgentConfig } from "@tigerbase/client";
export function ChatHeader({ agent }: { agent: AgentConfig }) {
return (
<header dir={agent.language === "ar" ? "rtl" : "ltr"}>
<h2>{agent.botName ?? "Harbor & Pine"}</h2>
{agent.tagline && <p>{agent.tagline}</p>}
</header>
);
}
export function EmptyState({ agent, send }: { agent: AgentConfig; send: (q: string) => void }) {
return (
<div>
{/* initialMessage is the resolved value; welcomeMessage is the older name */}
<p>{agent.initialMessage ?? agent.welcomeMessage}</p>
{agent.starterQuestions.map((q) => (
<button key={q} onClick={() => send(q)}>{q}</button>
))}
</div>
);
}What comes back
| botName · tagline | What it calls itself, and the line under the name. |
|---|---|
| initialMessage · welcomeMessage | The agent's opening line. initialMessage is the resolved value — the server fills it from a fallback when the setting is empty — so prefer it. |
| starterQuestions | Always an array, empty when none are set — map over it without checking. Render these rather than inventing your own: they are chosen to match what the agent actually knows. |
| language | en or ar. Drives direction as well as copy. |
| primaryColor · backgroundColor · textColor · userMessageBg · botMessageBg · headerBg | The palette, as the account set it. Strings, usually hex. |
| borderRadius | none, sm, md, lg, xl or full — a name, not a length. theme() turns it into one. |
| fontFamily | Written as it would be in CSS. |
| handoffEnabled | Whether to show a “talk to a person” affordance at all. |
| greetingEnabled · greetingMessages · greetingDelaySeconds | The proactive opener, if the account turned one on. |
| widgetTemplate | Which layout the web widget uses. Yours to ignore. |
| showBranding | False only on plans that allow white labelling. |
| extra | Everything the server sent, flat — the escape hatch for a field the dashboard gained after this version of the package shipped. |
NoteWhy extra is a separate object
An index signature on the type would make every typo compile: agent.botNme would be unknown instead of an error. A new server field is reachable through extra today and gets a real name in the next release.
Fetched once, failures forgotten
The result is cached as a promise, so two components mounting at the same moment make one request, not two. A failure is not cached: one bad minute on a train must not mean the agent never loads for the rest of the visit. Calling config() from every component that needs it is fine.
WarningWhen it fails
config() is usually the first request a page makes, so it is where a wrong key or a missing domain shows up first. Both arrive as a TigerbaseError that will fail the same way every time until somebody changes a setting — there is no point retrying. See Errors.Keeping it in a store
It is a plain object, so putting it wherever your state already lives is a one-liner. Fetch it once — it changes when the account edits the dashboard, not between renders.
import { createAsyncThunk, createSlice } from "@reduxjs/toolkit";
import type { AgentConfig } from "@tigerbase/client";
import { tigerbase } from "@/lib/tigerbase";
export const fetchAgent = createAsyncThunk("agent/fetch", () =>
tigerbase.config(),
);
const slice = createSlice({
name: "agent",
initialState: {
data: null as AgentConfig | null,
status: "idle" as "idle" | "ready" | "failed",
},
reducers: {},
extraReducers: (b) => {
b.addCase(fetchAgent.fulfilled, (s, a) => {
s.data = a.payload;
s.status = "ready";
});
b.addCase(fetchAgent.rejected, (s) => {
s.status = "failed";
});
},
});
export default slice.reducer;Zustand, Jotai, React Query, a context — all the same. The call returns a promise and an object.
theme()
The same colours, as CSS custom properties, with readable foregrounds you did not ask for and should not compute yourself.
Applying it
import { applyTheme } from "@tigerbase/client";
applyTheme(await tigerbase.theme()); // on <html>
applyTheme(await tigerbase.theme(), panelElement); // or on one elementapplyTheme is a convenience, not magic: it loops over theme.css and calls style.setProperty. Read theme.css yourself if you want the values in a stylesheet or a CSS-in-JS object instead.
What is in it
css = {
"--tb-primary": "#1f4d3a", // primaryColor, or #dc2626 if unset
"--tb-on-primary": "#ffffff", // ← computed from the brand colour
"--tb-surface": "#ffffff", // backgroundColor
"--tb-text": "#111827", // textColor
"--tb-user-bg": "#1f4d3a", // userMessageBg, or the brand
"--tb-on-user-bg": "#ffffff", // ← computed
"--tb-bot-bg": "#f3f4f6", // botMessageBg
"--tb-header-bg": "#1f4d3a", // headerBg, or the brand
"--tb-on-header": "#ffffff", // ← computed
"--tb-radius": "1rem", // borderRadius "lg", as a length
"--tb-font": "system-ui, -apple-system, Segoe UI, sans-serif",
}
needsOutline = false // true when the brand is pale enough to vanish on whiteWarningWhy --tb-on-primary is not just white
The brand colour arrives at runtime from somebody else’s dashboard. White text is right on a mid red and absent on a pale yellow, a mint or a light grey — not hard to read, not there.
It is computed with WCAG relative luminance rather than a lightness threshold, because #0000FF and #FFFF00 sit at nearly the same lightness and need opposite foregrounds. And you would never catch it in testing: your own account’s colour works.
Rendering with it
{agent.starterQuestions.map((q) => (
<button
key={q}
onClick={() => send(q)}
style={{
background: "var(--tb-primary)",
color: "var(--tb-on-primary)",
borderRadius: "var(--tb-radius)",
// A near-white brand on a near-white page needs an edge
border: theme.needsOutline ? "1px solid rgb(0 0 0 / 0.15)" : "none",
}}
>
{q}
</button>
))}TipA surface theme() does not know about
readableOn("#f5e6c8") returns "#000000" or "#ffffff", and contrastRatio(a, b) gives you the number.