ChatAI Docs

Examples

Runnable examples under /examples.

All examples expect a running ChatAI instance (default http://localhost:3000) and an assistant publicId. From the repo root: pnpm install.

ExamplePathOne-liner
HTML widgetexamples/html-widgetOpen index.html or self-host.html
React widgetexamples/react-widgetpnpm --filter @chatai/example-react-widget dev
Next.js portfolioexamples/nextjs-portfoliopnpm --filter @chatai/example-nextjs-portfolio dev
Node SDK chatexamples/node-sdk-chatpnpm start -- "…" with CHATAI_API_KEY
Support bot walkthroughpnpm seed:demo + playground / widget

HTML widget

Path: examples/html-widget

FilePurpose
index.htmlHosted /widget/chat.js (same pattern as Dashboard → Install)
self-host.htmlLocal ./chat.js + data-api-url
# edit asst_replace_me → your publicId
open examples/html-widget/index.html

pnpm examples:prepare-widget
open examples/html-widget/self-host.html

Details: Widget.

React widget

Path: examples/react-widget (Vite + workspace:* @chatai/react)

cp examples/react-widget/.env.example examples/react-widget/.env
# set VITE_CHATAI_ASSISTANT_ID + optional VITE_CHATAI_ORIGIN

pnpm --filter @chatai/example-react-widget dev
VariableMaps to
VITE_CHATAI_ORIGIN<ChatWidget apiUrl />
VITE_CHATAI_ASSISTANT_ID<ChatWidget assistantId /> (publicId)

Details: React.

Next.js portfolio

Path: examples/nextjs-portfolio — App Router portfolio shell with @chatai/react.

cp examples/nextjs-portfolio/.env.example examples/nextjs-portfolio/.env.local
# set NEXT_PUBLIC_CHATAI_ASSISTANT_ID (+ NEXT_PUBLIC_CHATAI_API_URL)

pnpm --filter @chatai/example-nextjs-portfolio dev

Opens http://localhost:3002. Env names use the NEXT_PUBLIC_ prefix required by Next client components; they correspond to CHATAI_API_URL / CHATAI_ASSISTANT_ID in the product plan.

Node SDK chat

Path: examples/node-sdk-chat

Requires an API key with the chat scope from Account settings.

cd examples/node-sdk-chat
CHATAI_API_KEY=sk_live_... \
CHATAI_ASSISTANT_ID=asst_... \
pnpm start -- "What is your refund policy?"

Optional: CHATAI_API_URL (default http://localhost:3000).
OpenAPI: GET /api/v1/openapi.json.

Details: SDK.

Customer support walkthrough (pnpm seed:demo)

Dogfood a support-style assistant without a separate example app:

  1. Start ChatAI (pnpm dev or docker compose up --build)

  2. Seed demo data:

    pnpm seed:demo
    # demo@chatai.local / DemoPass123!
  3. Sign in, open Support Bot in the dashboard

  4. Wait until the Refund policy document is ready (ingestion finished)

  5. In the playground, ask: “How long do refunds take?” — expect an answer grounded in the seeded FAQ

  6. Optional embeds:

    • Copy publicId from Install into examples/html-widget or examples/react-widget
    • Or set NEXT_PUBLIC_CHATAI_ASSISTANT_ID for the Next.js portfolio example

This is the v0.7 “customer support bot” path — docs-only walkthrough on top of scripts/seed-demo.mjs.