Admin console and dashboard
askdare can keep a record of how your bots are used and show it to you in a console served by the chat route: each bot's resolved configuration, doctor, a playground, the conversations, and, with @boldare/askdare-admin, a dashboard of cost, ratings, unanswered questions, leads and handoffs (ADR-0016, ADR-0032). Everything is off until you turn it on, and it needs no route, sign-in or database table of its own besides the store.
| Part | What it is | Needs |
|---|---|---|
| The admin store | Where askdare writes each turn's counters, ratings and, if you choose, transcripts | admin.store: postgresAdminStore(), upstashAdminStore(), or memoryAdminStore() for development |
| The console | A page at <basePath>/admin: bots, doctor, playground, conversations | admin.console, and ADMIN_SECRET or a list of allowed users |
| The dashboard | Charts and lists inside the console | @boldare/askdare-admin, and an admin store |
What the console is
The console is a page your chat route serves, at <basePath>/admin, next to the chat itself. It is for the site's owner and the team that runs the bots, not for visitors: nothing in the chat links to it, and it opens only with ADMIN_SECRET or your own sign-in (step 3). It has nothing of its own to install, host or keep: it reads your bots from askdare.config.ts and the records from your admin store.

Once signed in, it has five views (What the console shows has the details):
-
Bots: what each bot runs with, as the server resolved it, from the model and instructions to the forms and the widget. Read-only.

-
Doctor: checks every bot with this server's OpenAI key and stores, as
npx @boldare/askdare doctordoes in a terminal.
-
Playground: talk to a bot as a visitor would, before you change the live chat.

-
Conversations: what visitors asked and how the bots answered, with their ratings, the forms the bot showed and the handoffs.

-
Dashboard: with
@boldare/askdare-admin, cost, ratings, unanswered questions, leads and handoffs over time.
It follows the system's light or dark mode, and works on a phone.

All the screenshots are of the askdare website's demo bots, for Brightloop, a fictional company, with made-up conversations.
Open the demo console to try it without installing anything: a reviewer (Roles) on a month of made-up conversations, ratings, leads and handoffs. It shows every view that only reads, the bots, the conversations and the dashboard; doctor and the playground are a developer's.
Try it locally
Is the chat already running on your machine with npm run dev? Then the console takes about two minutes, with the memory admin store, which forgets its records when the server restarts:
-
Make an admin secret and add it to
.env.local:node -e "console.log(require('node:crypto').randomBytes(32).toString('base64url'))"# .env.local ADMIN_SECRET=… -
Turn on the console where you create the chat handler, in
app/api/chat/[...path]/route.tsifinitmade it:import { memoryAdminStore } from '@boldare/askdare'; import { createChatHandler } from '@boldare/askdare/next'; import { bots } from '../../../../askdare.config'; export const maxDuration = 300; export const { GET, POST, DELETE } = createChatHandler({ bots, admin: { store: memoryAdminStore(), console: {} }, }); -
Restart
npm run dev, open http://localhost:3000/api/chat/admin, paste the secret and press Sign in. Then try each view:- Bots: what each bot runs with, as the server resolved it.
- Doctor: press Run doctor to check every bot with your OpenAI key.
- Playground: ask a bot something. Its conversation is deleted when you leave the view.
- Conversations: chat a few times with the button on http://localhost:3000, then come back to read them.
Next, each covered further down:
- Keep the records: a Postgres or Upstash admin store (step 1).
- Keep what visitors wrote, for reviews:
admin.transcripts: true(what the admin store keeps). - Sign in with your app's own users:
console.allow(step 3). - Cost, ratings and unanswered questions: the dashboard (step 4).
1. Choose an admin store
askdare writes the records itself, from the same reports your onUsage, onFeedback and onTranscript hooks get, after the response, so they never delay an answer. Your hooks keep working as before. Deleting a conversation deletes its records, and sweep() applies the retention (step 5).
| Store | Package | Use it when |
|---|---|---|
postgresAdminStore() | @boldare/askdare-postgres | You have Postgres, or keep conversations there already (Own your data). Run npx askdare-postgres migrate first: the admin part creates the askdare_admin_ tables, and on an upgrade from askdare 0.7 adds the prompt version to them |
upstashAdminStore() | @boldare/askdare-upstash | You have no SQL database. The same Upstash database as your shared limits |
memoryAdminStore() | @boldare/askdare | Development and tests. Every instance has its own and a restart forgets it; production warns |
Each reads its connection like the add-on's other stores: DATABASE_URL, or { url } or { pool }, for Postgres; UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN, or { url, token } or { redis }, for Upstash. See the Postgres and Upstash READMEs for their options.
Upgrading from 0.7: records written before 0.8 read as the default prompt version. Postgres needs migrate once, and then filters every view by version, the old records included. Upstash needs nothing; its conversation and rating lists filter by version from the upgrade on, so records from before show only without a version filter. The daily totals filter by version in both.
2. Turn on the console
A route file may export only HTTP methods, and the sweep in step 5 needs the handlers too, so create them in a module of their own:
// lib/chat.ts
import { createChatHandler } from '@boldare/askdare/next';
import { postgresAdminStore, postgresConversations } from '@boldare/askdare-postgres';
import { bots } from '../askdare.config';
export const chat = createChatHandler({
bots,
conversations: postgresConversations(),
admin: {
store: postgresAdminStore(),
console: {},
},
});// app/api/chat/[...path]/route.ts
import { chat } from '../../../../lib/chat';
export const maxDuration = 300;
export const { GET, POST, DELETE } = chat;Generate an admin secret, at least 32 random characters, different from CHAT_SECRET and IDENTITY_SECRET:
node -e "console.log(require('node:crypto').randomBytes(32).toString('base64url'))"# .env.local
ADMIN_SECRET=…Run the app, open http://localhost:3000/api/chat/admin, type the secret and press Sign in.
- Without
admin.console, every<basePath>/admin…path answers404like any unknown path. Withoutadminat all, nothing is recorded. - Without
ADMIN_SECRETand withoutallow, the console answers an error, and in development the server log says which is missing. The secret is read on the first request, sonext builddoesn't need it. - Keep the console out of your
proxy.tsmatcher, like the rest of the chat route. It sets its own headers.
The conversation store is the one the chat uses: the default (OpenAI's Conversations API) works too, but only your own store can be swept.
3. Sign in
There are two ways in. Use one or both.
The secret. Whoever knows ADMIN_SECRET signs in by typing it. It is a separate secret because it is typed into a browser, while CHAT_SECRET mints every token. The page keeps it in memory only. To end every session, change the secret: sessions signed with the old one stop at their next request.
Your own sign-in. List the users who may sign in, by the ID your app knows them by, and let an admin page of yours, behind your own sign-in, send them to the console with a short-lived identity token:
// lib/chat.ts
admin: {
store: postgresAdminStore(),
console: { allow: ['user_123', 'user_456'] },
},// app/(internal)/admin/page.tsx: behind your app's own sign-in
import { SignJWT } from 'jose';
import { requireStaff } from '@/lib/auth'; // your own check
export const dynamic = 'force-dynamic';
export default async function AdminPage() {
const user = await requireStaff();
const token = await new SignJWT({})
.setProtectedHeader({ alg: 'HS256' })
.setSubject(user.id) // must be in admin.console.allow
.setAudience('askdare:admin')
.setIssuedAt()
.setExpirationTime('5m') // at most 10 minutes
.sign(new TextEncoder().encode(process.env.IDENTITY_SECRET));
return <a href={`/api/chat/admin#identity=${token}`}>Open the askdare console</a>;
}- The token is signed with
IDENTITY_SECRET, as for signed-in visitors, with the audienceaskdare:admin, which no bot ID can have, so no visitor's token opens the console.allowneedsIDENTITY_SECRET; without it, onlyADMIN_SECRETsigns in, and the server log says so once. - The token travels in the URL's fragment, which reaches neither the server, nor its logs, nor a
Referer, and the console removes it from the address bar at once. - Removing a user from
allow, or changing their role or bots (Roles), ends their sessions at their next request. - A list such as
['user_123', 'user_456']makes each user adeveloperon every bot: what everyone could do before roles. To give someone less, or more, use a map (Roles).ADMIN_SECRETalways signs in as anowneron every bot.
Either way, the console then holds a session token for 15 minutes, in memory, sent with every request. It sets no cookies and stores nothing: a reload signs in again. Sign-ins are limited to 5 a minute per IP address and 20 an hour across the app, and the kill switch (ASKDARE_DISABLED) refuses them too. askdare checks every request itself, whatever your own sign-in did.
What the console shows
| View | What it shows |
|---|---|
| Bots | Each bot's resolved configuration, one bot at a time: the model, the instructions as the model gets them (every prompt version's, with its share of new conversations), tool names, knowledge, limits, guardrails, origins, widget settings and texts per language, in sections you open. Built from a fixed list of fields: secrets, keys, hooks and environment values never appear |
| Doctor | The same checks as npx @boldare/askdare doctor, shown bot by bot as each is checked |
| Playground | A chat with any bot, through the normal path with the bot's limits and budgets, its answers rendered as the chat renders them. Its turns reach your onUsage and are recorded as the console's, so the dashboard leaves them out. The bot can hand off and show forms as in the chat, but nothing reaches your onHandoff or onLead: a handoff shows what onHandoff would have got, and a form shows read-only, since forms are sent from the chat. A bot with prompt versions gets a version picker: the conversation runs on the version you pick, and is recorded with it. Its conversation is deleted when you start a new one or leave, as far as the browser allows; retention removes the rest |
| Tests | Each bot's test cases from eval.cases, run one at a time or all through the same path as npx @boldare/askdare eval, with the answer, its sources and tools beside every check's verdict and reason (Tests) |
| Conversations | With an admin store: visitors' or the playground's conversations, by date or by tokens, or only those with a 👎. Open one to read it, from its stored transcript or, without one, from the conversation store, with where a handoff or a form happened while the conversation store still has it, and which answers the visitor rated 👎, with their comment. From a 👎 answer, a reviewer can draft a test case (Drafting a test case). An owner can delete it from there (Deletion requests) |
| Dashboard | With @boldare/askdare-admin (next step) |
The browser never gets a conversation's ID: lists carry references sealed to your session, which stop working when it ends. Every text from a conversation is shown as text, never as HTML.
Each user sees the views of their role, and only the bots in their scope (Roles).
Roles
Everyone who signs in has one of four roles, each including the one before (ADR-0034):
| Role | Sees and does | Spends tokens | Changes or erases data |
|---|---|---|---|
viewer | The dashboard's daily totals: cost, turns, ratings counted, unanswered questions, leads, handoffs and the resolution rate, and the comparison of prompt versions. Nothing about one conversation or one visitor | No | No |
reviewer | Also the conversations and their reviews, the dashboard's lists, the 👎 answers with their comments and stored transcripts, the Bots view, and drafting a test case from a 👎 answer, which the page builds and nothing stores | No | No |
developer | Also Doctor, the Playground and the Tests view, as everyone could before roles | Yes, within each bot's limits and budgets | Only its own playground conversations |
owner | Also deleting a conversation with its records and files (Deletion requests), and any later action that erases or changes stored data | Yes | Yes |
Give each user a role, and optionally limit them to some bots, with a map in allow:
// lib/chat.ts
admin: {
store: postgresAdminStore(),
console: {
allow: {
user_1: 'owner',
user_2: { role: 'reviewer', bots: ['support'] },
user_3: 'viewer',
agency_client: { role: 'owner', bots: ['client-bot'] },
},
dashboard: adminDashboard({ prices }),
},
},- A user limited to some bots sees only those bots' configuration, records and totals: the dashboard's totals are sums over their bots, never the whole app.
doctorand the playground run on their bots only. Lists show one bot at a time, which the console asks them to pick when they have several. Withoutbots, a user sees every bot, including records of bots you have since removed. - A bot ID no bot has is said once in the server log. The user sees nothing for it until records under that ID exist, so one typo doesn't lock anyone out.
- An unknown role,
bots: []or an unknown key in a user (such asbotforbots) is a setup error: the console answers an error until it is fixed, rather than guess. It is checked on the console's first request, sonext buildpasses. - A change takes effect at the user's next request: changing a user's role or bots ends their sessions, and they sign in again to get the new ones.
- What a role can't use is hidden, and refused: askdare checks the role and the bots on every request, whatever the page shows. A refused request answers
404, as an action or a conversation that doesn't exist. - Users and roles stay in your app. askdare has no user list, invitations or role editing: you grant access by editing
allowand deploying. There is no role claim in the identity token: the map is the one place that says who may do what, and it shows every grant in code review.
Tests
The Tests view runs the test cases you keep in your repository (Testing answers) from the console, for a developer and up. Pass the case files to the handler; Next bundles them, so askdare reads no files:
import support from '@/evals/support.eval.json';
createChatHandler({ bots, admin: { store, console: { allow } }, eval: { cases: [support] } });- Pick a bot, then run one case or all of them. All runs one case at a time. Each result shows the answer as the chat renders it, its sources with their knowledge paths, the tools it called, its tokens and time, and every check's verdict with a short reason, warnings included. Results stay in the page: baselines and regressions are the CLI's.
- They are real turns. They run through the eval path (
source: 'eval'inonUsage, no admin records, nothing delivered for handoffs and forms, the conversation deleted after the run), and count against the playground's limits for you and each bot's budgets. When a limit asks to wait a short while, Run all waits and carries on. - A bot with prompt versions gets the playground's Version picker: the cases run against the version picked, the bot's own by default, never the experiment's split, and each result names its version. Picking another version clears the results, which belong to the version that ran. Results aren't compared across versions here;
askdare eval --versiondoes that (Testing answers). - A draft case (
"draft": true) is listed and can't run until someone reviews it and removes the marker. - Without
eval.cases, the view says how to add them. A case file that isn't valid is a setup error the server log names.
Drafting a test case from a rated answer
The best new cases come from answers visitors rated 👎. In a review, a 👎 answer shows the visitor's comment and, for a reviewer and up, Draft a test case. The page builds a case file from what the review shows: the bot, its language and the visitor's turns up to that answer, with an empty expect and "draft": true.
- Personal data the page can recognize becomes a placeholder before you see it: email addresses (
[email]), phone numbers ([phone]), URLs with a query string ([url]) and runs of six digits or more ([number]), highlighted for you to check. Names, addresses and anything else in a visitor's words are yours to find. askdare keeps no identity with a conversation, so when the visitor was signed in the draft says so: check for their name or account details yourself. - The comment and the bad answer are shown beside the draft, never copied into it. What the answer should have done is your judgment: write it in
expect. - Copy or download it, then add it to
evals/. Nothing is stored or sent, and there is no way to draft many at once.askdare evalrefuses a file with a draft case until you remove"draft": true, which says you reviewed it. - The language is the bot's. A bot whose language is
autofollows each visitor, and the conversation's language isn't stored: the draft saysenand asks you to check it. - A turn with files can't be part of a case: turns that were only a file are left out, and the draft says how many had files.
- The 👎 is found among the bot's ratings of the days the conversation was active and the day after. A rating given later, or on a very busy bot one past the first 500 👎 of those days, isn't marked.
4. Add the dashboard
npm install @boldare/askdare-admin// lib/chat.ts
import { adminDashboard } from '@boldare/askdare-admin';
export const chat = createChatHandler({
bots,
conversations: postgresConversations(),
admin: {
store: postgresAdminStore(),
transcripts: true,
retentionDays: 30,
console: {
allow: ['user_123'],
dashboard: adminDashboard({
// What you pay per million tokens, by model ID, in your currency.
prices: { 'your-model-id': { input: 1.25, cachedInput: 0.125, output: 10 } },
}),
},
},
});The dashboard has no route, sign-in or storage of its own: the console serves it, checks access and passes it the store. Its Dashboard view shows, for the last 7, 30 or 90 days, for all bots or one:
- Cost per bot, day and model, from your
prices. A model without a price shows its tokens and "no price". askdare keeps tokens, not money, and holds no price table: OpenAI changes prices, and you know what you pay. - Conversations, turns, 👍 and 👎 per day.
- Unanswered questions: completed answers without sources from bots with knowledge, plus withheld and failed ones. A heuristic, and the dashboard says so.
- Leads and handoffs per day, handoffs by outcome, and the resolution rate: the share of new conversations without a handoff, per day.
- The most expensive conversations, and the 👎 answers with the visitors' comments. Open one to review the conversation.
- Prompt versions: once you pick a bot, a Version filter narrows every view to one of its versions, and the Versions view compares them side by side: conversations, turns, cost, ratings, the unanswered share, the handoff rate, leads and the first day each version answered, every rate next to its n. See Reading a comparison.
dashboard needs admin.store; the route doesn't load without it. Playground turns are left out.
5. Sweep on a schedule
Records are kept for admin.retentionDays (default 30, at most 400). Nothing deletes them until your app calls sweep(), which createChatHandler returns next to GET, POST and DELETE. In one call it deletes conversations idle for idleDays (with a store that can list them, not OpenAI's), with their files and admin records, then admin records older than admin.retentionDays, and daily totals older than 400 days.
// app/api/cron/sweep/route.ts
import { chat } from '../../../../lib/chat';
export async function GET(request: Request): Promise<Response> {
const secret = process.env.CRON_SECRET;
if (!secret || request.headers.get('authorization') !== `Bearer ${secret}`) {
return new Response(null, { status: 401 });
}
// { conversations, files, records, more }: with `more`, the next run continues.
return Response.json(await chat.sweep({ idleDays: 30, signal: request.signal }));
}{ "crons": [{ "path": "/api/cron/sweep", "schedule": "0 3 * * *" }] }That goes in vercel.json; on Heroku, call chat.sweep() from Heroku Scheduler. Own your data covers the sweep in full. askdare doctor warns when an admin store holds records older than admin.retentionDays, which means the sweep isn't running. The retention is set only there: askdare passes it to the store with every record it writes, and Upstash keys also expire on their own after it, as a backstop.
What the admin store keeps
| Record | Holds | Written | Deleted |
|---|---|---|---|
| Turns | Bot, model, tokens, duration, outcome, step count, tool names and outcomes, number of sources, what output checks decided. No text | Every turn | With the conversation, or after retentionDays |
| Ratings | 👍 or 👎 per answer, and the comment the visitor wrote | When a visitor rates an answer | The same |
| Transcripts | The visitor's message after onInput, the number of files, the answer they saw after output checks, its sources | Only with admin.transcripts: true | The same |
| Daily totals | Per bot, prompt version, day and model: turns, failures, unanswered, tokens; per bot, prompt version and day: conversations, ratings, leads, handoffs by outcome. No conversation, visitor or text | Every turn, rating, lead and handoff | After 400 days; not when a conversation is deleted |
Every record carries the prompt version that answered, default unless the bot names its own. Every record but the daily totals carries the bot, the conversation's ID in your conversation store, the visitor's pseudonym (the HMAC onUsage reports, never a raw ID or IP address), the time and whether it came from the chat or the console.
- Leads and handoffs are only counted, per bot, prompt version and day. The admin store keeps no form values, contact details or requests: those go to your
onLeadandonHandoff. - Ratings need no
onFeedbackonce there is an admin store: the 👍 and 👎 buttons show for bots that don't turn them off (widget.feedback: false), and each rating is recorded, withonFeedbackcalled as well when you set it. - Transcripts are off by default. Turn them on to review conversations in the dashboard; they are personal data, kept as long as the other records.
- A failed write never fails a turn:
onErrorgetsinternal_errorwith the error's class name, and that record is lost. The stores never log what they write.
Privacy
- Where it lives: your Postgres or Upstash database. Name its host in your privacy notice, as for your own conversation store.
- What is personal data: ratings' comments and transcripts are what visitors wrote; pseudonyms and conversation IDs link records to a visitor. Daily totals hold none.
- Erasure: a visitor who starts a new conversation deletes it, and its records go with it, in the same request. A sweep does the same for idle conversations. An
ownerdeletes one on request from the console (Deletion requests). Without the console, find the person's conversations by pseudonym (visitor) and delete each with your conversation store's tools andstore.deleteConversation(conversationId). - Retention:
retentionDays, applied by your scheduledsweep(). - Who sees it: transcripts and comments, whoever signs in to the console as a
revieweror above, for their bots (Roles); aviewersees daily totals only. TreatADMIN_SECRETand theallowlist like access to your database.
See Privacy for the list to put in your notice.
Deletion requests
When someone asks you to delete what they wrote to a bot, an owner deletes the conversation from the console:
-
Find it. In Conversations, pick the bot and look for the day the person names. Open the reviews to find the one with what they wrote: with
admin.transcripts: trueevery review has its text; without it, a review shows what the conversation store still holds. The list covers the lastretentionDays; older records were already swept. -
Delete it. In its review, Delete asks first, then deletes, in this order, the same as a visitor's own delete or a sweep:
- its admin records: turns, ratings with their comments, and the transcript;
- the conversation in your conversation store, at OpenAI with the default store;
- the files the visitor attached in it.
It can't be undone. The daily totals keep counting it: they hold no conversation, visitor or text.
-
Delete what askdare doesn't keep. Copies your own hooks made are yours to delete: what
onTranscriptstored, the requestsonHandoffsent and the form valuesonLeadgot, wherever they went. OpenAI keeps its abuse monitoring logs of requests for up to 30 days, and your hosting provider keeps its own logs.
Who can delete:
- Only an
owner, withADMIN_SECRETor a role inallow. A user on a 0.7allowlist is adeveloper, who can't. Every other role gets404, as for an action that doesn't exist, and doesn't see the button. - An
ownerlimited to some bots deletes only those bots' conversations. askdare checks the bot again from the conversation's transcript and the conversation store, rather than trusting the list. A conversation neither of them names any more (no transcript, and the conversation store already deleted it) answers404for a scoped owner: its remaining records go with the retention, or an owner on every bot deletes them.
One person may have several conversations: delete each. For an anonymous visitor, only what they wrote identifies their conversations. Deleting every conversation of a signed-in visitor in one step needs a query by visitor that the admin store doesn't have yet.
Security
- Headers on the console page and every answer:
Cache-Control: no-store, a Content Security Policy that allows only the console's own scripts, styles, fonts and requests (frame-ancestors 'none', so no site can frame it),Referrer-Policy: no-referrer,X-Content-Type-Options: nosniff,Cross-Origin-Opener-Policy: same-originandX-Robots-Tag: noindex. - No cookies, no browser storage: the session token lives in the page's memory for 15 minutes.
- No raw conversation IDs reach the browser, the owner's included.
- Nothing for visitors: the widget and the React chat never load the console's code, and apps without
admin.consolenever evaluate it.
Your own admin store
The AdminStore interface and its types are exported from @boldare/askdare, and adminStoreContract from @boldare/askdare/testing runs the suite every store must pass: fixed queries bounded by a day range and a limit of 100, daily totals kept when they are written, idempotent writes and deletes. Records carry a version (ADR-0039): the daily rows are keyed by it, AdminRange.version filters days, conversations and ratings and needs a bot, and a record or row without one, written before 0.8, reads as default. Each record write gets { retentionDays, signal } (AdminWriteOptions): a store that expires records on its own, as a backstop, must not expire one sooner, and keeps 400 days when it is absent. The retention warning in askdare doctor is core's; a store's diagnose() reports only its own state. Read postgresAdminStore in @boldare/askdare-postgres as an example.