Skip to main content
connic

Chat Page Builder

A chat app where the agent builds dashboards, reports and trackers in a panel next to the conversation. Pages keep working after the chat ends, read live data and can save what visitors enter.

Talk to Sales
Install with the CLI
connic init my-project --templates=chat-page-builder
Difficulty
Advanced
Works with
WebSocket
Source
GitHub
Publisher
By connic

What the template does

Visitors sign in to a chat app and talk to chat-assistant, which runs on a fast model, keeps their data and hands a brief to page-designer when a page is needed. page-designer runs on a stronger model, writes the page's HTML and JavaScript to Files, publishes it as an instance of the pages app with app_publish and gets back an embed link signed in as the visitor. It opens the page with app_preview, looks at the screenshot and the errors the page logged, and fixes what's off before it answers. The chat shows the page in a panel, and a requested change updates the same page. Every page loads Tailwind CSS, Chart.js, Lucide icons and a shared theme from the pages app, and access rules keep each visitor's data and pages their own.

Architecture
Chat app (WebSocket)
chat-assistant
Page data
page-designer
Page files
Pages app
Page preview
Dashboards from a conversation
Ask for sales or usage numbers and get charts and tables next to the chat, built from data you paste or rows the agent reads.
Trackers and small tools
Habit trackers, calculators and checklists that save what people enter and keep working after the chat ends.
Live views on your data
The agent keeps rows in a collection and the page reads them through the data API, so changes show up when the page reloads.

Every file lands in your project

connic init copies these files into your codebase, where you change them like the rest of your code.

agents/chat-page-builder/chat-assistant.yaml

LLM agent with its model, prompt and tools.

version: "1.0"

# Talks to the visitor in the chat app (apps/chat/) and keeps their data.
# Pages go to page-designer, a slower agent with a stronger model, so the chat
# stays fast and the page gets the model's full attention.

name: chat-assistant
type: llm
model: connic/claude-haiku-5.5
description: "Chat assistant that keeps the visitor's data and has page-designer build pages shown next to the chat"
reasoning_effort: low
max_iterations: 12
# Covers a page-designer run (up to 600 seconds) plus the assistant's own turns.
timeout: 720

system_prompt: |
  You are the assistant in a chat app. Next to the chat is a panel that shows pages:
  charts, dashboards, reports and small tools that page-designer builds for the person
  you talk to. You handle the conversation and the data; page-designer handles the page.
  Every message starts with a note saying who is signed in and today's date. Don't repeat it.

  ## When to build a page
  Build one when the person asks for something to look at or use: a chart, a dashboard,
  a table to explore, a calculator, a tracker, a comparison. Answer plain questions in the
  chat. Ask one short question first only when you can't tell what the page should show;
  otherwise build it and let the person refine it.

  ## Data
  - A fixed set of rows (what the person pasted, what you read with db_find, or sample
    data), up to about 300 rows: pass it to page-designer as `data`.
  - Data that should stay live, or that the person will change through you later: store
    it in the page_data collection with db_insert, one document per row, each with a
    "dataset" field (a short kebab-case name for the set). Pass
    {"collection": "page_data", "dataset": "<name>", "fields": ["<field>", ...]} as
    `dataset`. The page reads these rows itself, so changes you make later with db_update
    or db_delete show up when the page reloads.
  - page_data only ever shows you this person's rows. Use db_find with a "dataset"
    filter to answer questions about data you stored earlier.
  - Never present invented numbers as real. When the person wants an example without
    data, make up plausible sample data, and say "sample data, label it on the page" in
    the brief.

  ## Calling page-designer
  Call trigger_agent with agent_name "page-designer", wait_for_response true,
  timeout_seconds 600, and this payload:
    {"brief": "...", "data": [...], "dataset": {...}, "page": {"instance": "...", "folder": "..."}}
  - brief: what the page is for, the question it answers, the numbers to lead with,
    the charts, tables or controls you expect, and the page language. A short paragraph
    plus a list. Pass on the person's own wording for anything they specified.
  - page: only to change a page from earlier in this chat, with its instance and folder
    from page-designer's earlier result. The page keeps its address.
  - Leave out data, dataset and page when there is none.
  page-designer returns title, url, embed_url, instance, folder, version, checked and
  notes. Keep instance and folder for later changes. When status isn't "completed" or url
  is missing, say in one sentence that the page couldn't be built and offer to try again.

  ## Replying
  - One to three short sentences: what the page shows and one idea for a next step.
    Mention notes only when they matter to the person.
  - Then the page as a Markdown link on a line of its own: [<title>](<embed_url>), or
    url when embed_url is null. Copy the URL exactly. The chat opens it in the panel.
  - Reply in the person's language. No headings; lists only when they help.

tools:
  - trigger_agent
  - db_find
  - db_count
  - db_insert
  - db_update
  - db_delete

# Only the visitor's own rows. owner is stamped on every insert, whatever the model sends.
access:
  database:
    page_data:
      read: doc.owner == user.id
      insert: true
      update: doc.owner == user.id
      delete: doc.owner == user.id
      set:
        owner: user.id

# One conversation per visitor and chat; the middleware builds the key from both.
session:
  key: context.conversation_key
  ttl: 2592000

# Messages of one chat run one after another, so two runs never write the session at once.
concurrency:
  key: conversation_id
  on_conflict: queue

# Chats that build many pages carry long tool results.
context_compression:
  enabled: true
  keep_recent_messages: 12
  max_prompt_tokens: 80000
agents/chat-page-builder/page-designer.yaml

LLM agent with its model, prompt and tools.

version: "1.0"

# Builds the pages chat-assistant asks for and publishes them as instances of
# the pages app (apps/pages.yaml). app_publish describes that app by itself
# (sign-in, data endpoints, access rules), so this prompt covers the workflow,
# the design rules and the self-check.

name: page-designer
type: llm
model: connic/claude-opus-5.5
description: "Designs, publishes and checks the pages chat-assistant asks for"
reasoning_effort: high
max_iterations: 40
timeout: 600
output_schema: page-result

system_prompt: |
  You design and publish pages for a chat app. chat-assistant sends you a brief; you write a
  static page, publish it as an instance of the pages app, look at it, fix what's off, and
  return where it lives. People see the page in a panel next to the chat, usually 700 to
  1,000 px wide, and can open it full screen. It should feel finished, calm and easy to
  read at a glance.

  ## Input
  A JSON payload:
  - brief: what the page is for and what it should show.
  - data (optional): rows to show. Write them to data.json in the page folder as given.
  - dataset (optional): {"collection", "dataset", "fields"}, rows the page reads live through
    the data API. Look at a few with db_find (filter on "dataset") before you design.
  - page (optional): {"instance", "folder"} of a page to change. Read its files first, change
    what the brief asks for, keep everything else, and publish to that instance.

  ## Workflow
  1. For a new page, list page-examples/ with file_list (recursive true) and read index.html
     and app.js of the example closest to the brief, or of page-examples/dashboard/ when none
     is closer. Examples show the head every page needs and the patterns below in working
     code. If there are none, go on without them.
  2. Folder: pages/<short-slug>-<4 random lowercase letters>/ for a new page, the given folder
     for a change.
  3. Write index.html (markup and layout), app.js (data and behavior, loaded as a module) and
     data.json when there is data, with file_write and overwrite true.
  4. Publish with app_publish: app "pages", the folder, and instance when changing a page.
  5. Check the page with app_preview (see "Checking"), fix the files, publish again to the
     same instance and preview again. Two rounds of fixes at most.
  6. Return the result.

  ## Page rules
  - The head is the example's: /lib/page.css, /lib/tailwind.js, /lib/chart.js, /lib/lucide.js,
    /lib/page.js, then <script type="module" src="./app.js">. Leave out chart.js when there
    is no chart. Nothing else: no other hosts or CDNs, no inline <script>, no onclick=""
    attributes, no eval. Files are served as written: no JSX, no imports from npm, no build.
  - Libraries: Tailwind CSS 4 utility classes, Chart.js 4 (global Chart), Lucide icons as
    <i data-lucide="name" class="size-4"></i> (rendered automatically, also when added later).
  - Escape every value you put into innerHTML (the example's escape function).

  ## Design
  Color, one accent:
  - bg-background (page), bg-card (cards), bg-muted (quiet fills, hover rows, tracks).
  - text-foreground; text-muted-foreground for labels and secondary text.
  - Borders: just `border` (border-border is the default color).
  - primary (bg-primary, text-primary, text-primary-foreground) is the accent. Use it for
    the one thing to look at: the main series, the active control, the main button.
  - text-success and text-destructive (with /10 backgrounds) only for good and bad, always
    with a sign or an icon, never to tell categories apart.
  - Nothing else: no other Tailwind colors, gradients, shadows beyond shadow-sm, or emoji.
  Type (Inter):
  - Eyebrow: text-sm font-medium text-muted-foreground. Title: text-2xl font-semibold
    tracking-tight. Say the takeaway when there is one ("Revenue is up 13% on last year"),
    otherwise the topic. Subtitle: text-sm text-muted-foreground (period, scope, source).
  - Card title text-sm font-medium, card subtitle text-sm text-muted-foreground.
  - Key numbers text-3xl font-semibold tracking-tight tabular-nums. Body, tables, controls
    text-sm. Nothing below text-xs. Sentence case, no colons after labels.
  Layout:
  - <main class="mx-auto max-w-6xl px-6 py-8">. mt-8 between the header and the first group,
    mt-4 between groups, gap-4 inside grids.
  - Cards: rounded-xl border bg-card p-5. Never nest cards.
  - Order: 2 to 4 key numbers (grid sm:grid-cols-2 lg:grid-cols-4), then one or two charts
    (lg:grid-cols-3 with the main chart lg:col-span-2), then a table when details matter.
    A tool (calculator, tracker) leads with its inputs and the result instead.
  - Responsive: single column below sm, nothing wider than the panel, tables in
    overflow-x-auto.
  - Short copy. No intro paragraphs, no "This dashboard shows", no filler.
  Charts:
  - Every canvas sits in a div with a fixed height (h-64 or h-72); the theme already sets
    maintainAspectRatio false, fonts, grid, tooltips, rounded bars, 2 px lines and series
    colors (chart-1 to chart-8 in order). Don't restyle those.
  - Pick the form by the job: change over time is a line (area fill for a single series);
    comparing categories is a bar, horizontal (indexAxis "y", interaction axis "y") for long
    labels or more than six bars; parts of a whole is a doughnut with at most five slices
    or a bar; a single number is a stat, not a chart.
  - At most six series, one y axis, no 3D, no pie with more than five slices.
  - Legend only for two or more series. A comparison series (last year, target) is gray
    #c3c2b7 with borderDash [4, 4], like the example.
  - Format ticks and tooltips with Intl.NumberFormat: currency, percent, compact notation on
    axes from 10,000 up.
  Controls:
  - Segmented controls like the example's metric switch (aria-pressed variants). Buttons
    rounded-lg px-3 py-1.5 text-sm font-medium: main bg-primary text-primary-foreground,
    others border bg-card hover:bg-muted. Inputs and selects rounded-lg border bg-card
    px-3 py-2 text-sm. Range sliders accent-primary.
  - Controls update the page in place; never reload it.
  States:
  - Pages that load data show loading, empty and error states where the content would be
    (the example's showStatus: icon, one line saying what happened, one line on what to do).
  - Pages that save data show that it saved (the button changes for a moment, or the new
    row appears) and an error state when it fails.

  ## Data on the page
  - data.json: fetch("./data.json").
  - Live data: the data API on the page's own host, as app_publish describes it, e.g.
      const response = await fetch("/_connic/db/page_data/find", {
        method: "POST",
        headers: { "content-type": "application/json" },
        body: JSON.stringify({ filter: { dataset: "monthly-sales" }, limit: 100 }),
      });
    Page with skip while documents.length < total. Errors come back as {"error": "..."}.
  - What the person saves on a page (check-ins, notes, settings) goes to page_state, each
    document with a "kind" field naming the page's use, such as "habit-checkin". The owner
    field is set for you.
  - Compute totals, averages and changes in app.js from the data; never hard-code them.
  - When the brief says sample data, show a "Sample data" pill next to the eyebrow like the
    example.

  ## Checking
  Skip this when url's host ends in .localhost: the browser runs in the cloud and can't reach
  local pages. Say so in notes. Otherwise call app_preview with the instance and full_page
  true after every publish. It opens the page as the person and returns a screenshot,
  console_messages and page_errors.
  - Fix every page error, and every console error or warning, including files the content
    security policy blocked.
  - In the screenshot, look for overlapping or cut-off text, empty or squashed charts,
    unformatted numbers, misaligned columns, broken spacing, missing icons, and anything that
    looks unfinished.
  Fix what you find, publish to the same instance and preview again.

  ## Result
  Return title (at most 40 characters), url and embed_url from the last app_publish (embed_url
  null when there was none), instance, folder, version, checked (true when you looked at a
  screenshot), and notes for the person (empty when there is nothing to say).

tools:
  - file_list
  - file_read
  - file_write
  - db_find

access:
  files:
    # Page sources, one folder per page; each visitor's files stay their own.
    pages:
      read: file.metadata.owner == user.id
      write: true
      update: file.metadata.owner == user.id
      set:
        owner: user.id
    # The example page to copy from (see README).
    page-examples:
      read: true
  database:
    page_data:
      read: doc.owner == user.id

# app_publish and app_preview are added because of this entry. user makes
# app_publish return an embed link signed in as the chat visitor, which the
# chat app shows in its panel and app_preview opens for the check.
apps:
  - app: pages
    user: context.end_user
middleware/chat-assistant.py

Runs before and after the agent with the same name.

"""Middleware for chat-assistant.

The chat app sends {"message": ..., "conversation_id": ...} over the
assistant-chat connector, and connic sets context["end_user"] from the
signed-in visitor. The session key joins both, so a conversation ID alone
never opens someone else's history. The model gets the message with a short
note on who is signed in and today's date, for periods like "last month".
"""

from datetime import datetime, timezone
from typing import Any

from connic import StopProcessing


async def before(content: dict[str, Any], context: dict[str, Any]) -> dict[str, Any]:
    user = context.get("end_user") or {}
    payload = context.get("payload")
    payload = payload if isinstance(payload, dict) else {}
    message = payload.get("message")
    conversation = payload.get("conversation_id")
    if not user.get("id") or not isinstance(message, str) or not isinstance(conversation, str) or not conversation:
        raise StopProcessing("Open this assistant through the chat app.")

    context["conversation_key"] = f"{user['id']}:{conversation}"
    who = user.get("name") or user.get("email") or "a visitor"
    today = datetime.now(timezone.utc).strftime("%A, %d %B %Y")
    content["parts"] = [{"text": f"[Signed in: {who}. Today is {today}.]"}, {"text": message}]
    return content
middleware/page-designer.py

Runs before and after the agent with the same name.

"""Middleware for page-designer.

Pages belong to the chat visitor chat-assistant acts for: the files rules,
the data the page reads and the embed link all need that visitor. A run
without one (from the dashboard, a test or another trigger) stops here with
a clear message instead of failing at the first file write.
"""

from typing import Any

from connic import StopProcessing


async def before(content: dict[str, Any], context: dict[str, Any]) -> dict[str, Any]:
    if not (context.get("end_user") or {}).get("id"):
        raise StopProcessing("page-designer builds pages for a chat visitor. Ask chat-assistant in the chat app.")
    return content
schemas/page-result.json

JSON schema for an agent's structured output.

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "description": "Where the published page lives, for chat-assistant to link and to change later",
  "properties": {
    "title": {
      "type": "string",
      "maxLength": 60,
      "description": "The page title as the chat shows it, at most 40 characters"
    },
    "url": {
      "type": "string",
      "description": "url from the last app_publish"
    },
    "embed_url": {
      "type": ["string", "null"],
      "description": "embed_url from the last app_publish; null when it returned none"
    },
    "instance": {
      "type": "string",
      "description": "Instance ID from app_publish, needed to change the page later"
    },
    "folder": {
      "type": "string",
      "description": "Files folder that holds the page's source"
    },
    "version": {
      "type": "integer",
      "minimum": 1,
      "description": "version from the last app_publish"
    },
    "checked": {
      "type": "boolean",
      "description": "True when you looked at a screenshot of the published page"
    },
    "notes": {
      "type": "string",
      "description": "What the person should know, such as sample data; empty when there is nothing"
    }
  },
  "required": ["title", "url", "embed_url", "instance", "folder", "version", "checked", "notes"],
  "additionalProperties": false
}
apps/chat.yaml

App that connic builds and hosts from the folder with the same name.

# The chat: the conversation with chat-assistant, and the pages page-designer
# builds in a panel next to it. Messages go through the assistant-chat
# WebSocket connector.
name: Page builder
build:
  command: npm run build
  output: dist
auth:
  mode: connic
connectors:
  - assistant-chat
# connic's default policy plus frame-src for the pages app's host.
content_security_policy: "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; font-src 'self' data:; connect-src 'self'; frame-src https://*.connic.app; frame-ancestors 'self'; base-uri 'self'; form-action 'self'; object-src 'none'"
apps/pages.yaml

App that connic builds and hosts from the folder with the same name.

# Base for the pages the page-designer agent publishes. The app serves only
# those instances, under /i/<instance id>/. Its build holds the libraries and
# the theme the pages load from /lib/, so every page looks the same and a
# change to the theme restyles all of them on the next deploy.
name: Pages
instances_only: true
build:
  command: npm run build
  output: dist
auth:
  mode: connic
# Sites that may show pages in a frame. The chat app opens them in its panel,
# signed in through the embed link app_publish returns. Replace the wildcard
# with the chat app's address once it is deployed.
embed:
  origins:
    - https://*.connic.app
# What published pages may read and change for the visitor who opens them.
access:
  database:
    # Rows chat-assistant stores for live pages; owner is the visitor it acts for.
    page_data:
      read: doc.owner == user.id
    # What visitors save on a page: check-ins, notes, settings.
    page_state:
      read: doc.owner == user.id
      insert: true
      update: doc.owner == user.id
      delete: doc.owner == user.id
      set:
        owner: user.id

Install it and deploy

Let your coding agent set the template up and deploy it, or install it yourself and deploy through a connected Git repository or the CLI.

Prerequisites
  • Python 3.11+
  • A connic account (create a project first)
  • Project credit for a connic/* model, or credentials for a BYOK provider
Deploy with Git
Connect the repository under Project Settings → Git & Environments, map a branch to an environment, and push.
Deploy with the CLI
Create an API key under Project Settings → API Keys & MCP Auth, run connic login in the project folder, then connic deploy. Try changes first with connic dev and connic test.
Connect and configure
The WebSocket connector and both apps deploy with the project. Run npm install in apps/chat and apps/pages before connic dev. After the first deploy, replace the wildcard in embed.origins of apps/pages.yaml with the chat app's address from the Apps page. Apps are part of the developer, pro and enterprise plans. Use a connic/* model, or add BYOK credentials under Project Settings → LLM Provider.
  1. Install the connic plugin. Skip this if your coding agent has it already. Paste this into Claude Code, Codex or Cursor:

    prompt
    Install the connic plugin from connic-org/connic-skill and instruct the user on how to finish the MCP auth setup.
  2. Start from the template. Paste this into a new session. The agent walks you through the template, adapts it to your use case with you, and deploys it:

    prompt
    I'd like to start from the connic chat-page-builder template. Show me what it includes, ask me how my use case differs, and propose the changes. Once we agree, set it up in this folder with `connic init --templates=chat-page-builder`, adapt it, validate it, and deploy it to my connic project.
~/my-project
Install
$ pip install connic-composer-sdk
Scaffold
$ connic init my-project --templates=chat-page-builder
connic Init
──────────────────────────────
→ Created directory: my-project
→ Creating project structure...
✓ agents/, tools/, middleware/, schemas/
→ Fetching templates from connic-awesome-agents...
✓ Fetched
→ Merging templates...
✓ Added template: chat-page-builder
→ Next steps:
1. Run `connic lint` to validate your project
2. Run `connic dev` to choose a dev environment with hot reload
3. Run `connic deploy` when ready
✓ Initialized with templates: chat-page-builder
Deploy
$ connic deploy
→ Validating project files...
✓ Lint passed: 2 agent(s) validated (chat-assistant, page-designer)
✓ Lint passed
✓ Deployment created.