A Flask web application that answers common Islamia University of Bahawalpur (IUB) student questions. It searches a local FAQ database first and uses Google Gemini only when no suitable FAQ answer is found.
Built for the InventaCore AI Business Automation Challenge 2026 — Track 1: Customer Operations.
University helpdesk staff repeatedly answer the same routine student questions (fees, library hours, portal issues, hostel services, etc.) manually. This is slow, repetitive, and inconsistent across different staff members. This project automates that first layer of response.
- Searches 25 built-in FAQs covering fees, admissions, academics, campus, portal, transport, and hostel services.
- Uses Gemini AI as a fallback for questions that do not match an FAQ.
- Validates empty, oversized, and blocked questions before processing them.
- Saves recent questions, answers, source, status, and timestamps in SQLite.
- Provides a
/historypage showing the latest 20 interactions.
- Python 3.10 or newer
- A Google Gemini API key
Install the Python packages:
python -m pip install -r requirements.txt- Copy
.env.exampleto.envin the project root. - Add your Gemini API key:
GEMINI_API_KEY=your_api_key_hereDo not commit .env or share the API key.
From the project folder, run:
python app.pyThen open http://127.0.0.1:5000 in a browser.
- A student submits a question on the home page.
- The app validates the question (maximum 300 characters).
faq_search.pycompares its keywords with saved FAQs using Jaccard similarity.- A confident match is returned from the database.
- Otherwise,
ai_fallback.pyasks the Geminigemini-2.5-flashmodel. - The result is saved to
helpdesk.dband can be viewed athttp://127.0.0.1:5000/history.
In a live test of 10 varied student questions:
- 4 (40%) were answered instantly from the FAQ database in under 1 second, at zero AI cost.
- 6 (60%) required an AI-generated response for questions outside the stored FAQ set.
- Every response returned successfully; error handling was separately verified by simulating an invalid API key, which was caught cleanly, shown as a safe message to the user, and logged as a failed interaction instead of crashing the app.
- As more FAQs are added over time, the share of instant, free, database-answered queries is expected to increase, further reducing AI cost and response time.
.
|-- app.py # Flask routes and request handling
|-- ai_fallback.py # Gemini AI fallback
|-- faq_search.py # FAQ matching logic
|-- database.py # SQLite setup, seed data, and interaction logging
|-- helpdesk.db # Local SQLite database
|-- templates/ # Home and history HTML templates
|-- static/style.css # Application styling
`-- .env # Local Gemini API key (not committed)
python database.py # Creates tables and seeds FAQs if needed
python faq_search.py # Runs FAQ search examples
python ai_fallback.py # Tests the Gemini connection- FAQ matching uses keyword/word-overlap similarity (Jaccard), not deep semantic understanding — some rephrased questions (e.g. "wifi not working" vs. the stored "internet/Wi-Fi issues" FAQ) may not match and will go to AI instead. This is the intended fallback behavior, not a failure.
- Currently runs on Flask's built-in development server; not hardened for production traffic.
- FAQ database is limited to 25 sample questions for demonstration purposes.
- The app initializes its database automatically when
app.pystarts. - If Gemini is unavailable or the key is invalid, the app shows a safe helpdesk message and records the failed request.
- Use production configuration rather than Flask debug mode before deploying publicly.
Musfirah Ather — 6th-semester AI student, The Islamia University of Bahawalpur