How to Build an AI-Powered Smart Form

Forms that understand intent and fill themselves out

Ad placeholder (leaderboard)

What you are building

This tutorial builds a smart form that understands intent. Instead of presenting a wall of empty inputs, you let a user paste or dictate a free-form description — “I’m Dana, need a 2-bed flat in Tbilisi under $900, moving next month” — and an LLM pre-fills the structured fields for them. The model then validates the result with reasoning and surfaces only the follow-up questions that still matter. The human always stays in control: the AI proposes, the user confirms.

How it works

You start by describing your form as a JSON schema — field names, types, and which are required. When a user submits free text, you send that text plus the schema to the model using structured output (or function calling) so it returns an object whose keys exactly match your fields, not loose prose. You render those values into the real, still-editable form. A second pass sends the filled values back and asks the model which required fields are still ambiguous or missing; it returns a short list of targeted follow-up questions, which you show one at a time. Every value stays editable and nothing auto-submits, so a misread name or amount is caught by the person, not shipped silently.

Tips and the planner below

Keep your schema and rules in the system prompt and treat the user’s text as untrusted data — that is your main defence against prompt injection through form content. Always validate the parsed object against the schema server-side before trusting it, and re-prompt on a mismatch. Ask follow-ups only for what the model could not infer, so users answer far fewer questions than a static form would demand. The planner below estimates your monthly token spend from submission volume, average input size, and model price, so you can budget the extraction call before you ship.

Ad placeholder (rectangle)