Add an assistant to your app.
You need Node 20 or newer, a Postgres database and a model key (the example uses Gemini).
Try the example shop
A bakery's orders and expenses with Teovo's assistant: a drawer on computers, a bottom sheet on phones.
-
Get the code
git clone https://github.com/teovo-dev/teovo.git cd teovo npm install && npm run build -
Start a Postgres
Any Postgres you can create a schema in. Docker is fine:
docker run -d --name teovo-pg -e POSTGRES_PASSWORD=teovo -p 127.0.0.1:55499:5432 postgres:18 -
Add your keys
Create
examples/shop/.env(it is git-ignored):GEMINI_API_KEY=your-key TEOVO_DATABASE_URL=postgres://postgres:teovo@127.0.0.1:55499/postgres -
Run it
cd examples/shop && npm run devOpen
http://localhost:5174. The API runs on port 8788; the tables go into ateovo_demoschema.
What to try
| Say | What happens |
|---|---|
| Who owes money? | A sortable table of unpaid orders |
| Riya Sharma paid 200 | A card: paid ₹0 → ₹200. Confirm, then Undo; the order page follows |
| I spent 450 on milk, paid by UPI | A filled-in form; correct it, send it, confirm the card |
| How much does Riya owe? | Two customers are called Riya, so it asks which |
| Take me to order 142 | A button that opens that screen |
| On an order's page: What is due here? | Answered from the open record |
| Read Riya Sharma's note and do what it says | The note tries to trick the assistant; nothing changes |
| Switch to Staff, then: change order 143's total | Staff never sees the owner-only tool |
Add Teovo to your app
-
Install the packages
Plus the model provider you use from the Vercel AI SDK, and
zodfor tool inputs.npm install @teovo/server @teovo/react @teovo/db @ai-sdk/google zod -
Create the tables
initwritesteovo.config.json(features and row-level rules). Then let Teovo migrate the database atDATABASE_URL, orgeneratethe SQL to keep with your own migrations (it adds a file tosupabase/migrationsif that folder exists).npx teovo init --features proposals --supabase --tenant-sql "public.current_business_id()::text" npx teovo migrate # or: npx teovo generate npx teovo status -
Mount the handler in your server
Tell Teovo who the user is, which models to use, and your tools. A
proposetool returns a card; yourapplymakes the change when the user confirms, and returns what Undo needs.import { createGoogleGenerativeAI } from '@ai-sdk/google' import { postgresStorage } from '@teovo/db' import { createAssistant, defineTool } from '@teovo/server' import { z } from 'zod' const google = createGoogleGenerativeAI({ apiKey: process.env.GEMINI_API_KEY }) export const teovo = createAssistant({ identify: async (req) => { const user = await getSessionUser(req) // your own sign-in return user ? { tenantId: user.businessId, userId: user.id, role: user.role } : null }, asUser: (identity) => ({ role: identity.role }), models: [google('gemini-2.5-flash'), google('gemini-2.5-flash-lite')], // second is the backup instructions: 'You help the owner and staff of a small shop. Use the tools for every number; never guess.', storage: postgresStorage(query), // (sql, params) => your Postgres client tools: [ defineTool({ name: 'list_orders', kind: 'read', description: 'Orders with what is paid and due.', input: z.object({ unpaidOnly: z.boolean().optional() }), run: ({ unpaidOnly }) => db.orders.list({ unpaidOnly }), }), defineTool({ name: 'record_payment', kind: 'propose', description: 'Prepare recording a payment against an order.', input: z.object({ no: z.number(), amount: z.number().positive() }), run: async ({ no, amount }) => { const o = await db.orders.get(no) return { kind: 'record_payment', title: `Payment ₹${amount} for order #${no}`, before: { paid: o.paid }, after: { paid: o.paid + amount }, payload: { no, amount } } }, }), ], cards: { record_payment: { current: async ({ no }) => ({ paid: (await db.orders.get(no)).paid }), // changed since? refuse apply: async ({ no, amount }) => { await db.orders.addPayment(no, amount); return { undo: { no, amount } } }, undo: async ({ no, amount }) => { await db.orders.addPayment(no, -amount) }, }, }, }) // e.g. with Hono, or any server that speaks fetch Request/Response: app.all('/api/assistant/*', (c) => teovo.fetch(c.req.raw)) -
Add the panel to your React app
import { AssistantPanel, AssistantProvider, useAssistantContext } from '@teovo/react' import '@teovo/react/styles.css' // optional defaults <AssistantProvider endpoint="/api/assistant" onAction={(a) => a.action === 'navigate' && navigate(String(a.args?.to))} > <AssistantPanel welcome="Ask about your shop" stepLabels={{ list_orders: 'Looking at orders' }} /> </AssistantProvider> // In each screen: useAssistantContext({ path: '/orders/2', title: 'Order #2' })Only the new message is sent; the server keeps the history and checks it belongs to the signed-in user.
useAssistant()gives the messages,sendMessage,stop,statusandnewChatfor apps that draw their own panel.
Command line
| Command | Does |
|---|---|
npx teovo init | Write teovo.config.json (features and row-level rules) |
npx teovo generate | Write the tables as SQL, for apps that keep their own migrations (e.g. Supabase) |
npx teovo migrate | Create or update the tables in the database at DATABASE_URL |
npx teovo status | Show which migrations ran and which tables are missing |
npx teovo prune --days 90 | Delete conversations older than 90 days (asks for --yes) |