A friendly, AI-powered questionnaire with a chat-like interface. The AI presents questions conversationally, appreciates responses, requests clarification when needed, and stores all responses in Google Sheets.
- Conversational AI: Questions presented in a friendly, natural way
- Multiple Input Types: Text, numeric, date, radio, checkbox, yes/no
- Smart Validation: AI requests clarification for unclear responses
- Google Sheets Integration: Responses saved automatically
- Flexible Question Management: Load from JSON or Google Sheets
uv syncCopy .env.example to .env and fill in your values:
cp .env.example .envRequired:
MODEL_API_KEY: Your Google AI API key
uv run uvicorn main:app --reloadOpen http://localhost:8000 in your browser.
To save responses to Google Sheets:
- Go to Google Cloud Console
- Create a new project
- Enable the Google Sheets API
- Go to IAM & Admin → Service Accounts
- Create a service account
- Download the JSON key file
- Save it as
credentials.jsonin the project root
- Create a new Google Sheet
- Share it with the service account email (found in credentials.json)
- Copy the Sheet ID from the URL and add to
.env
Set QUESTION_SOURCE=sheets in .env. Your sheet should have:
- Column A: Questions
- Column B: Responses (filled automatically)
Write questions naturally. The system auto-detects question types:
| Question Example | Detected Type |
|---|---|
What is your name? |
Text |
How old are you? |
Numeric |
What is your date of birth? |
Date |
Are you employed? |
Yes/No |
Gender (Male, Female, Other) |
Radio |
[checkbox] Interests (Tech, Sports, Music) |
Checkbox |
Type Markers (optional, for explicit control):
[checkbox]- Multiple selection[radio]or[select]- Single selection[yes/no]- Yes/No toggle[date]- Date picker[number]- Numeric input
Options Format:
- In parentheses:
Favorite color (Red, Blue, Green) - After colon:
Select size: Small, Medium, Large
Set QUESTION_SOURCE=json and edit questions.json:
{
"questions": [
{
"id": "q1",
"text": "What is your name?",
"type": "text",
"required": true
}
]
}| Type | Description |
|---|---|
text |
Free-form text input |
numeric |
Number input (age, quantity) |
date |
Date picker |
radio |
Single selection from options |
checkbox |
Multiple selection |
yes_no |
Yes/No toggle |
ai-based-form/
├── main.py # FastAPI application
├── config/ # Configuration
├── core/ # Business logic
│ ├── ai_client.py # AI interactions
│ ├── questionnaire.py # Flow control
│ └── question_loader.py
├── storage/ # Google Sheets
├── models/ # Data schemas
├── static/ # CSS & JS
├── templates/ # HTML
└── questions.json # Question config
MIT