The chat
How it works
The bubble on this site is a small digital twin. It answers as me, from notes I keep in the repo, and it is built to stay on free tiers.
The chat agent idea is inspired by Matthias Manzone and sayheyto.me.
What you see
A greeting shows up soon after the page loads, in the language your browser reports. Open it and you get a few suggested questions, a typing indicator, and replies rendered as simple markdown. The thread stays in sessionStorage for the tab. Escape closes the panel. Nothing here needs an account.
The request
The page is a static Nuxt site. Chat goes to a Node serverless function at /api/chat, using the Vercel AI SDK. The reply is streamed so the first words can show up while the rest is still being written. The target is a first response in about a second and a half to two seconds on a warm model.
By default the call goes through the Vercel AI Gateway, which bills the free monthly credits. The primary model is google/gemini-3.5-flash-lite, with google/gemini-3.1-flash-lite as the next model if the first one fails. Thinking is set to the minimum level so the model does not spend a few seconds reasoning in silence.
If the gateway is not configured, the same route can call Google AI Studio directly with GOOGLE_GENERATIVE_AI_API_KEY. That is the free-tier alternative. With no key at all, or with CHAT_MOCK=1, the function answers from the notes without calling a model. Useful locally. Honest about being a preview.
Web search grounding is off. It is not worth a paid add-on for a personal site, and the twin is supposed to stick to the notes anyway.
Why the notes stay still
On a cold start the function reads every markdown file in /knowledge, sorts them by path, and keeps that text in memory. That string is the system prompt, and it does not change between turns. Per-turn details (language, page, referrer, how many tokens the session has used) are added to the latest visitor message, not to the system prompt. A stable prefix is what lets the model reuse its implicit cache, which is both faster and cheaper.
Dropping another markdown file into knowledge/ is enough to extend the notes. The loader does not have a hard-coded list.
After the reply
Saving the transcript and sending mail happen in waitUntil, so they do not hold the response. Redis (Upstash, including the old Vercel KV env names) is optional. If it is configured, the transcript is kept for 30 days, along with a one-paragraph summary of the visitor: who, company, role, and contact only when they said so about themselves, otherwise unknown. That summary is a small extra model call. It is throttled during the chat, and filled in when the log is opened if it is still missing and the session has gone quiet. If Redis is not configured, the chat still answers and nothing is kept once that server instance goes away.
Mail goes out only when a visitor leaves an email address, not when they merely say hello. A Zod schema pulls the name, the email, and a short note. If Resend is not configured, the lead is still stored with the session and no email is sent.
GET /api/admin/sessions returns recent sessions and those summaries. ?id= returns one session with the full message list. It asks for Authorization: Bearer matching ADMIN_TOKEN. With no token configured, the route answers 404. /admin is a plain page that calls the same endpoint and can open a conversation. It does not remember the token.
One config file
knowledge/agent_config.json sets the goal (actively_looking, open_to_opportunities, or networking), which contact channels the twin may say out loud, and an optional booking link. Phone is off unless you turn it on and supply a number. An empty booking link means the twin will not invent a calendar URL. The file is read into the same cached system prompt, so a change ships with the next deploy rather than through an admin screen.
Limits
There is a per-IP rate limit, a per-session token budget, a per-IP daily budget, and a site-wide daily budget. They exist so a busy day or a stuck loop does not burn the free Gateway credits, the Upstash free plan, or the Resend free plan. The numbers are environment variables. See the README.
This setup does not turn on Observability Plus, a paid Redis plan, or search grounding.