Page-Builder im Chat
Eine Chat-App, in der der Agent Dashboards, Berichte und Tracker in einem Panel neben dem Gespräch baut. Die Seiten funktionieren auch nach dem Chat weiter, zeigen Live-Daten und speichern, was Besucher eingeben.
connic init my-project --templates=chat-page-builderWas das Template macht
Besucher melden sich in einer Chat-App an und schreiben mit chat-assistant. Der Agent läuft auf einem schnellen Modell, verwaltet ihre Daten und gibt page-designer einen Auftrag, wenn eine Seite gebraucht wird. page-designer läuft auf einem stärkeren Modell, schreibt HTML und JavaScript der Seite in Files, veröffentlicht sie mit app_publish als Instanz der Pages-App und bekommt einen Embed-Link zurück, der als der Besucher angemeldet ist. Mit app_preview öffnet er die Seite, prüft den Screenshot und die Fehler, die die Seite protokolliert hat, und behebt, was nicht passt, bevor er antwortet. Der Chat zeigt die Seite in einem Panel, und eine gewünschte Änderung aktualisiert dieselbe Seite. Jede Seite lädt Tailwind CSS, Chart.js, Lucide Icons und ein gemeinsames Theme aus der Pages-App, und Zugriffsregeln sorgen dafür, dass jeder Besucher nur seine eigenen Daten und Seiten sieht.
- Dashboards aus dem Gespräch
- Frag nach Umsatz- oder Nutzungszahlen und bekomm Diagramme und Tabellen neben dem Chat, aus Daten, die du einfügst, oder aus Zeilen, die der Agent liest.
- Tracker und kleine Tools
- Habit-Tracker, Rechner und Checklisten, die speichern, was eingegeben wird, und auch nach dem Chat weiter funktionieren.
- Live-Ansichten deiner Daten
- Der Agent legt Zeilen in einer Collection ab, und die Seite liest sie über die Data API. Änderungen erscheinen beim nächsten Neuladen.
Jede Datei landet in deinem Projekt
connic init kopiert diese Dateien in deine Codebase. Dort änderst du sie wie den Rest deines Codes.
LLM-Agent mit Modell, Prompt und 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: 80000LLM-Agent mit Modell, Prompt und 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_userLäuft vor und nach dem gleichnamigen Agenten.
"""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 contentLäuft vor und nach dem gleichnamigen Agenten.
"""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 contentJSON-Schema für die strukturierte Ausgabe eines Agenten.
{
"$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
}App, die connic aus dem gleichnamigen Ordner baut und hostet.
# 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'"App, die connic aus dem gleichnamigen Ordner baut und hostet.
# 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.idInstallieren und bereitstellen
Lass deinen Coding-Agenten das Template einrichten und deployen, oder installiere es selbst und starte das Deployment über ein verbundenes Git-Repository oder die CLI.
- Voraussetzungen
- Python 3.11+
- Ein connic-Konto mit einem angelegten Projekt
- Projektguthaben für ein connic/* KI-Modell oder Zugangsdaten für einen BYOK Provider
- Deployment mit Git
- Verbinde das Repository unter Projekt Settings → Git & Environments, ordne einen Branch einem Environment zu und pushe.
- Deployment mit der CLI
- Erstelle unter Projekt Settings → API Keys & MCP Auth einen API Key, führe im Projektordner connic login aus und danach connic deploy. Änderungen probierst du vorher mit connic dev und connic test aus.
- Verbinden und konfigurieren
- Der WebSocket-Connector und beide Apps werden mit dem Projekt deployt. Führe vor connic dev in apps/chat und apps/pages npm install aus. Ersetze nach dem ersten Deployment den Platzhalter in embed.origins von apps/pages.yaml durch die Adresse der Chat-App von der Apps-Seite. Apps gehören zu den Tarifen Developer, Pro und Enterprise. Ein connic/* KI-Modell nutzen oder BYOK-Zugangsdaten unter Projekt Settings → LLM Provider hinterlegen.
connic-Plugin installieren. Überspring diesen Schritt, wenn dein Coding-Agent es schon hat. Füge das in Claude Code, Codex oder Cursor ein:
promptInstalliere das connic-Plugin aus connic-org/connic-skill und erkläre dem Nutzer, wie er die MCP-Authentifizierung abschließt.Mit dem Template starten. Füge das in eine neue Session ein. Der Agent zeigt dir das Template, passt es gemeinsam mit dir an deinen Anwendungsfall an und deployt es:
promptIch möchte mit dem connic-Template chat-page-builder starten. Zeig mir, was es enthält, frag mich, worin sich mein Anwendungsfall unterscheidet, und schlag die Änderungen vor. Sobald wir uns einig sind, richte es in diesem Ordner mit `connic init --templates=chat-page-builder` ein, passe es an, prüfe es und deploye es in mein connic-Projekt.
Weitere Agent Templates
Browser Automation Demo
Der Browser-Agent fragt E-Mail-Adresse, Passwort und Projekttitel ab, meldet sich bei connic an und erstellt das Projekt über das Dashboard.
Produktivität · EinsteigerCompliance-Auditor
Zeitgesteuerte Compliance-Prüfungen werten regulatorische Neuerungen aus der Websuche, per MCP abrufbare Dokumentation und frühere Prüfergebnisse aus dem Retrieval aus. Daraus entstehen Zusammenfassungen mit einer Bewertung.
Compliance · Experte- Cron
- HTTP Webhook
E-Mail-Helpdesk
Der E-Mail-Helpdesk fragt Postfächer per IMAP ab, filtert automatische Antworten und klassifiziert Nachrichten nach Anliegen. Kontextbezogene Antwortentwürfe stammen aus dem konfigurierten Retrieval.
Kommunikation · FortgeschrittenKundensupport
KI-gestützte Ticket-Triage mit Sentimentanalyse und RAG-gestützten Antwortentwürfen. Der Agent ordnet Tickets nach Priorität ein, blockiert Spam und speichert neue Lösungen.
Kundensupport · Einsteiger- WebSocket
- HTTP Webhook
Persönlicher Telegram-Assistent
Der multimodale Telegram-Assistent verarbeitet Text, Bilder, Sprache, Video und Dokumente. Er durchsucht das Web, speichert Notizen und Wissen und plant Erinnerungen mit persistenten Sessions.
Kommunikation · Einsteiger- Telegram
Voice-Kundensupport
Entwickle einen Voice-Agenten, der dein Kundenwissen in connic retrieval durchsucht und mit einem Mock-Tool die Ticketerstellung demonstriert.
Kundensupport · Einsteiger- Twilio Voice