Spaces:
Runtime error
title: Pare AI Chatbot
emoji: ๐ข
colorFrom: blue
colorTo: indigo
sdk: docker
app_port: 7860
pinned: false
Pare AI Chatbot ๐ข
An intelligent AI-powered chatbot for Pare Interior & Exterior Solutions. Built with Flask and Google Gemini AI, this chatbot helps customers learn about products and book appointments with real-time slot management.
Features โจ
- AI-Powered Chat: Intelligent responses about Pare products using Google Gemini AI
- Product Information: Detailed info about 6 product series (INNOV+, INNOV2+, DURA+, EASY+, LUXE, Acoustic)
- Smart Appointment Booking:
- Book via chat or direct UI
- Time slots: 9 AM - 6 PM in 1-hour intervals
- Real-time slot availability checking
- Prevents double bookings
- Auto-refresh every 5 seconds when booking modal is open
- Bilingual Support: English and Hindi language support
- Real-time Validation:
- Business hours enforcement (9 AM - 6 PM only)
- Full hour slots only (no 9:30, 10:15, etc.)
- Date format normalization
- Usage Tracking: Monitor API quota usage in real-time
- Responsive Design: Works on desktop and mobile devices
- Modern UI: Clean, professional interface with smooth animations
Product Series ๐ฆ
- INNOV+: Waterproof, termite-proof wood-look interiors
- INNOV2+: 3D textured walls (Wave, Dome, Stripes, Prism)
- DURA+: UV-resistant exterior cladding (Norma, Stretta)
- EASY+: Direct installation without plywood
- LUXE: Premium dead-matt finish (Panelo, Flut, Verto)
- Acoustic: Sound absorption with louver design
Tech Stack ๐ ๏ธ
- Backend: Flask (Python 3.8+)
- AI: Google Gemini API (gemini-flash-lite-latest)
- Frontend: HTML5, CSS3, Vanilla JavaScript
- Styling: Custom CSS with modern design patterns
- Icons: Font Awesome 6.4.0
- Environment: python-dotenv for secure config
Key Features in Detail ๐
Smart Appointment System
- Dual Booking Methods: Book via AI chat or direct UI form
- Time Slot Management:
- Business hours: 9:00 AM to 6:00 PM
- 1-hour intervals only (9:00, 10:00, 11:00, etc.)
- No partial hours (9:30, 10:15 rejected)
- Real-time Sync:
- Chat bookings instantly reflect in UI
- Auto-refresh every 5 seconds when modal is open
- Visual indicators for booked slots
- Validation:
- Backend validates all time slots
- Prevents bookings outside business hours
- Checks for duplicate bookings
- Date format normalization (YYYY-MM-DD internally)
Usage Tracking
- Request Counter: Shows current API usage (X/60 requests per minute)
- Color Coding: Green (safe), Red (near limit)
- Auto-reset: Counter resets every 60 seconds
- Detailed Stats: Click info icon for full usage breakdown
- Quota Monitoring: Direct link to Google's quota dashboard
Installation ๐
Prerequisites
- Python 3.8 or higher
- Google Gemini API key (Get it here)
Setup Steps
- Clone the repository
git clone <your-repo-url>
cd Pare_chatbot
- Create virtual environment
python -m venv venv
- Activate virtual environment
# Windows
.\venv\Scripts\activate
# Linux/Mac
source venv/bin/activate
- Install dependencies
pip install flask flask-cors google-generativeai python-dotenv
- Configure API key
Create a .env file in the root directory:
GEMINI_API_KEY=your_api_key_here
- Run the application
python app.py
- Open in browser
http://localhost:5000
Project Structure ๐
Pare_chatbot/
โโโ app.py # Main Flask application
โโโ .env # Environment variables (API key)
โโโ .gitignore # Git ignore file
โโโ requirements.txt # Python dependencies
โโโ templates/
โ โโโ index.html # Main HTML template
โโโ static/
โ โโโ css/
โ โ โโโ style.css # Styling
โ โโโ js/
โ โโโ script.js # Frontend logic
โโโ venv/ # Virtual environment (not in git)
Usage ๐ฌ
Chat with AI
- Type your questions about Pare products
- Click product buttons in sidebar for quick info
- Get instant AI-powered responses in English or Hindi
- Ask in Hindi: "INNOV+ เคเฅ เคฌเคพเคฐเฅ เคฎเฅเค เคฌเคคเคพเค"
Book Appointments
Method 1: Via Chat
User: "I want to book an appointment"
Bot: "Sure! Please provide your name, address, date, and time."
User: "Name: John Doe, Address: 123 Main St, Date: tomorrow, Time: 2 PM"
Bot: *Creates appointment with validation*
Chat Booking Rules:
- AI validates time slots (9 AM - 6 PM only)
- Rejects invalid times (8 AM, 9:30 AM, 7 PM, etc.)
- Checks for duplicate bookings
- Provides helpful error messages
Method 2: Direct UI
- Click "Book Appointment" button
- Fill in your details (Name, Address)
- Select date from calendar
- Choose from available time slots
- Booked slots show as "(Booked)" and are disabled
- Only valid hours (9 AM - 6 PM) are shown
- Confirm booking
- Receive appointment confirmation with unique ID
UI Features:
- Auto-selects tomorrow if past business hours
- Real-time slot availability
- Auto-refresh every 5 seconds
- Visual "Updating..." indicator
View & Manage Appointments
- Click "View Appointments" to see all bookings
- Each appointment shows:
- Unique ID (APT-XXXX)
- Name, Address, Date, Time
- Cancel button
- Cancel appointments with confirmation
- Canceled slots become available immediately
Features in Detail ๐
Smart Time Slot Management
- 1-hour intervals: 9:00 AM, 10:00 AM, 11:00 AM, etc.
- Business hours: 9 AM - 6 PM
- Real-time availability: Shows only available slots
- Auto-date selection: Defaults to tomorrow if past business hours
- Double-booking prevention: Validates before confirming
AI Capabilities
- Product recommendations
- Detailed product information
- Bilingual responses (English/Hindi)
- Appointment booking via chat
- JSON-formatted responses
API Endpoints ๐
Chat
POST /api/chat
Content-Type: application/json
{
"message": "Tell me about INNOV+ series"
}
Response:
{
"type": "message",
"content": "INNOV+ is a waterproof, termite-proof...",
"language": "en",
"usage": {
"request_count": 1,
"timestamp": "2026-02-10T20:30:00"
}
}
Book Appointment
POST /api/appointments/book
Content-Type: application/json
{
"name": "John Doe",
"address": "123 Main St",
"date": "2026-02-11",
"time": "14:00"
}
Success Response (200):
{
"status": "confirmed",
"appointment_id": "APT-1234",
"name": "John Doe",
"address": "123 Main St",
"date": "2026-02-11",
"time": "14:00",
"created_at": "2026-02-10T20:30:00"
}
Error Response (400):
{
"status": "error",
"message": "Time slot 14:00 on 2026-02-11 is already booked."
}
View Appointments
GET /api/appointments
Response:
{
"appointments": [
{
"appointment_id": "APT-1234",
"name": "John Doe",
"address": "123 Main St",
"date": "2026-02-11",
"time": "14:00",
"status": "confirmed",
"created_at": "2026-02-10T20:30:00"
}
]
}
Cancel Appointment
POST /api/appointments/cancel
Content-Type: application/json
{
"appointment_id": "APT-1234"
}
Response:
{
"status": "cancelled",
"appointment_id": "APT-1234",
"message": "Appointment successfully cancelled"
}
Usage Statistics
GET /api/usage
Response:
{
"total_appointments": 5,
"free_tier_limit": "60 requests/minute",
"recommendation": "Monitor at https://ai.dev/rate-limit",
"current_model": "gemini-flash-lite-latest"
}
Configuration โ๏ธ
Environment Variables
GEMINI_API_KEY: Your Google Gemini API key (required)
Model Configuration
Current model: gemini-flash-lite-latest
- Temperature: 0.7
- Max output tokens: 512
- Timeout: 30 seconds
- Retry logic: 2 attempts on timeout
To change model, edit app.py:
model = genai.GenerativeModel(
"models/gemini-flash-lite-latest", # Change model here
generation_config={...}
)
Business Hours
Default: 9 AM - 6 PM (1-hour slots)
To change, edit static/js/script.js:
const startHour = 9; // Change start hour (24-hour format)
const endHour = 18; // Change end hour (24-hour format)
Also update app.py validation:
def validate_time_slot(time: str) -> tuple[bool, str]:
# Check business hours (9 AM to 6 PM)
if hour < 9 or hour > 18: # Change these values
return False, "Appointments are available only from 9:00 AM to 6:00 PM."
Auto-refresh Interval
Default: 5 seconds
To change, edit static/js/script.js:
window.timeSlotsRefreshInterval = setInterval(() => {
// ...
}, 5000); // Change milliseconds (5000 = 5 seconds)
Troubleshooting ๐ง
API Key Issues
- Ensure
.envfile exists with valid API key - Check API key at: https://aistudio.google.com/app/apikey
- Verify no quotes around the key in
.env - Format:
GEMINI_API_KEY=AIzaSyC...(no quotes)
Quota Exceeded (429 Error)
Error: "You exceeded your current quota"
- Cause: Hit free tier limit (60 requests/minute)
- Solution:
- Wait 1 minute for quota reset
- Check usage: https://ai.dev/rate-limit
- Monitor with built-in usage tracker (top-right corner)
- Consider upgrading API plan
Timeout Errors (504)
Error: "Deadline expired before operation could complete"
- Cause: API is slow or overloaded
- Solution:
- Retry after a few seconds
- Check internet connection
- Try different model (gemini-2.0-flash)
- Increase timeout in
app.py
Invalid Time Slot
Error: "Appointments are available only from 9:00 AM to 6:00 PM"
- Cause: Requested time outside business hours or not full hour
- Valid times: 09:00, 10:00, 11:00, 12:00, 13:00, 14:00, 15:00, 16:00, 17:00, 18:00
- Invalid times: 08:00, 09:30, 10:15, 19:00, etc.
Slot Already Booked
Error: "Time slot X on Y is already booked"
- Cause: Someone else booked that slot
- Solution:
- Choose different time
- Refresh booking modal to see updated slots
- Check "View Appointments" to see all bookings
Date Format Issues
- Backend stores:
YYYY-MM-DD(2026-02-11) - Display shows:
DD-MM-YYYY(11-02-2026) - AI accepts both formats, automatically normalized
Port Already in Use
# Change port in app.py
app.run(debug=True, port=5001) # Use different port
Slots Not Refreshing
- Check browser console for errors (F12)
- Ensure
/api/appointmentsendpoint is working - Hard refresh:
Ctrl + Shift + R - Clear browser cache
Security ๐
- API key stored in
.env(not in code) .gitignoreprevents committing secrets- Input validation on appointments
- CORS enabled for API access
Future Enhancements ๐
- Database integration (SQLite/PostgreSQL) for persistent storage
- User authentication and login system
- Email/SMS notifications for appointments
- Admin dashboard for managing bookings
- Payment integration for booking fees
- Multi-language support expansion (Spanish, French, etc.)
- Voice input/output capabilities
- Image upload for product queries
- Calendar integration (Google Calendar, Outlook)
- Appointment reminders (24 hours before)
- Customer feedback and ratings
- Analytics dashboard (booking trends, popular times)
- Waiting list for fully booked slots
- Recurring appointments
- Export appointments to CSV/PDF
Recent Updates ๐
v1.2.0 (Latest)
- โ Added usage tracking with real-time counter
- โ Implemented auto-refresh for time slots (5-second interval)
- โ Added date format normalization (YYYY-MM-DD)
- โ Enhanced validation for business hours
- โ Improved error messages for quota/timeout issues
- โ Added visual indicators for slot updates
v1.1.0
- โ Dual booking methods (Chat + Direct UI)
- โ Real-time slot synchronization
- โ Duplicate booking prevention
- โ Time slot validation (9 AM - 6 PM, full hours only)
v1.0.0
- โ Initial release
- โ AI-powered chat with Gemini
- โ Basic appointment booking
- โ Bilingual support (English/Hindi)
Contributing ๐ค
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
License ๐
This project is licensed under the MIT License.
Acknowledgments ๐
- Google Gemini AI for powering the chatbot
- Flask framework for backend
- Font Awesome for icons
- Pare for product information
project purpose only