April 19, 2025
O. Wolfson
Recently, I added a custom AI chatbot to my website.
It’s a simple, lightweight assistant — modeled after my professional persona — that can answer questions, remember parts of the conversation, and reference documents I provide.
It's a work in progress, but here’s a behind-the-scenes look at how it works so far.
The chatbot is made of two main parts:
The frontend handles user input, shows messages, and calls server-side functions when a question is submitted.
The server-side action processes the question intelligently using OpenAI, Supabase, and a system prompt.
Here’s the basic flow when a user sends a message:
messages state).askQuestion(question, history).One clever part:
Although there’s no "true memory" (like a database of past chats), the chatbot pretends to remember by sending the last 10 messages along with each new question.
This lets the AI keep the conversation thread alive naturally — it "feels" like memory to the user.
If you keep chatting, the AI will still be able to refer to previous topics because those are continually included in the prompt.
Frontend:
A simple ChatPage React component with useState, useTransition, and useRef for managing input, auto-scrolling, and message updates.
Server Actions:
A askQuestion function that uses:
getEmbedding(question) to create a semantic vector.Supabase RPC (match_mdx_chunks) to fetch similar documents./prompts/system-prompt.txt) that defines the assistant's personality.chatWithContext(question, [fullContext]) to call OpenAI.Supabase:
A Postgres database with a match_mdx_chunks function for fast semantic search using pgvector.
Styling:
Tailwind CSS with custom Shadcn components for inputs, buttons, and cards.
At the heart of the chatbot is the system prompt, which defines its identity:
"You are OWolf, the AI version of O. Wolfson (Oliver Wolfson), a professional software developer. You live at https://owolf.com, O. Wolfson's personal blog, where he journals about his software development journey."
This keeps the AI grounded in my voice, my background, and my professional context — even when users ask unexpected questions.
I wanted a chatbot that feels like an extension of my site and my writing —
Not just a generic AI, but something that:
And importantly, something that runs efficiently, privately, and is easy to extend later.
Future ideas I’m exploring:
If you're curious to see the chatbot in action, feel free to try it at owolf.com/chat.