# AI Form Assistant

Answer out loud. The form fills itself.

A form you fill by talking instead of typing. Answer in your own words, by voice or text, and the fields fill in as you go: an open-source starting point for anyone whose signup or intake form loses people halfway.

## Tags

Next.js, AI SDK, Google Gemini, OpenAI, React Hook Form, Zod, shadcn/ui

![AI Form Assistant: a chat panel on one side, form fields filling in on the other](https://lxbpjvrr41.ufs.sh/f/6KZjuRTQYJxHr9JkA8WCDykaivLS2NVATJ0QlYugPF1sHbRM)

## At a glance

- **Role:** Solo build
- **Scope:** Demo and reference implementation
- **Status:** Open source, MIT licensed

## Two demos

### The form builder

Add fields, pick types, set validation rules. The result is a JSON schema kept in localStorage, so a new form takes no code.

[Form builder interface showing dynamic form creation with field type selection and validation configuration. (video)](https://lxbpjvrr41.ufs.sh/f/6KZjuRTQYJxHVuhr8WUsIS2Yw6ONg4BKAnphZLJcMrHvQ3VC)

### Filling it by conversation

The assistant asks, you answer however you like, and the fields update while you talk.

[AI conversation interface showing natural language form filling with automatic field updates as user responds to questions. (video)](https://lxbpjvrr41.ufs.sh/f/6KZjuRTQYJxHtEhvVNH6ciESV8PasdW2jmf5AGgXRIexqOor)

## How the conversation writes to the form

Gemini 2.5 Flash runs the chat: fast and cheap enough to keep a back-and-forth conversation going. It sits behind the Vercel AI SDK, so swapping the model leaves the form code untouched.

Field updates happen through tool calls, not through parsing the model's prose. Each call carries a field name and a value, checked against the same Zod schema React Hook Form validates on. One sentence can fire several of those calls at once, which is how "my name is John Doe" reaches `firstName` and `lastName` in a single turn. When a value fails validation the assistant is told which field and why, so it asks again instead of dropping the answer.

Twelve field types ship with matching validation: text, textarea, email, phone, URL, number, date, time, checkbox, single choice, multiple choice, and a range slider.

## Voice on both ends

Speech-to-text is the browser's SpeechRecognition API. In Chromium it runs on the device: no audio upload, no per-minute cost, works offline. Spoken output goes to OpenAI TTS-1 and plays back automatically, so the form can be finished without looking at the screen. That matters most on mobile, where forms hurt the most.

## Where it fits

### Structuring messy input

Paste a resume or a block of notes, watch the fields populate, correct whatever is wrong.

### Long multi-step forms

Answer questions instead of clicking through steps and back again.

### Mobile

Talking beats typing on a phone keyboard, by a wide margin.

### Hands-free entry

Voice in, voice out: a whole form completed without touching the device.

## Beyond form filling

The system prompt and tools live in `src/app/api/chat/route.ts`. Edit those and the same conversation loop does other jobs: guiding someone toward a purchase while they fill the form, explaining what an option means before they pick it, suggesting a value from an earlier answer, or chaining several forms and showing fields only when they become relevant.

## Stack

Next.js 16 with the App Router, TypeScript throughout, shadcn/ui and Tailwind for the interface. React Hook Form holds form state, Zod owns validation and the inferred types, and the schema persists in localStorage.

## Open source

MIT licensed, on [GitHub](https://github.com/Mark-Life/ai-form).

One caveat worth stating plainly: this is a demo and teaching repo. Field updates are applied client-side. In a product you are charging for, the write goes to the server first, where it can be validated and stored without trusting the browser.

## Links

- Project page: https://andrey-markin.com/projects/ai-form
- All projects: https://andrey-markin.com/projects.md
- GitHub: https://github.com/Mark-Life/ai-form
- Contact: https://andrey-markin.com/#contact
