How It Works
The AI generation system is powered by the Groq SDK with thellama-3.3-70b-versatile model, designed specifically for structured JSON output.
Describe your form
Users enter a natural language prompt describing the form they need. For example:
- “Create a customer feedback form with name, email, rating, and comments”
- “Job application form with personal info, work experience, and file upload”
- “Event registration with attendee details and meal preferences”
AI processes the prompt
The system sends your prompt to Groq AI with a specialized system prompt that ensures structured JSON output matching the form schema format.
Schema validation
The generated JSON is validated using Zod to ensure all fields meet requirements before creating the form in the database.
Supported Field Types
The AI can generate 9 different field types, each with appropriate validation and options:Text Fields
Text Fields
Type:
textBasic text input with optional placeholder and validation.Email Fields
Email Fields
Type:
emailEmail input with built-in HTML5 validation.Number Fields
Number Fields
Type:
numberNumeric input with optional min/max validation.Date Fields
Date Fields
Type:
dateDate picker input.Textarea Fields
Textarea Fields
Type:
textareaMulti-line text input for longer responses.Select Dropdowns
Select Dropdowns
Type:
selectDropdown with predefined options.Radio Buttons
Radio Buttons
Checkboxes
Checkboxes
Type:
checkboxMultiple selections allowed.File Upload
File Upload
Type:
fileFile upload input.Field Rendering Status: While the validation schema supports all 9 field types, the current UI implementation fully supports
text, email, textarea, number, select, radio, and checkbox types. The date and file types are validated but display as “Unsupported field type” in the form preview and public submission pages.Example Prompts
- Customer Feedback
- Event Registration
- Job Application
Prompt:Generated Form:
- Full Name (text, required)
- Email (email, required)
- Satisfaction Rating (radio, 1-5 stars)
- Product Quality (select, Excellent/Good/Fair/Poor)
- Comments (textarea, optional)
AI System Prompt
The AI uses a carefully crafted system prompt to ensure consistent, valid output:The
response_format: { type: 'json_object' } parameter ensures Groq always returns valid JSON, reducing parsing errors.Error Handling
The system handles multiple error scenarios:Schema Validation
All generated schemas are validated using Zod before database insertion:API Endpoint
POST/api/forms/generate
Request Body:
app/api/forms/generate/route.ts