The Montfort ICSE AI Chatbot is a deeply integrated school assistant that goes beyond simple text answers. It serves as a central guide, capable of:
- Answering Queries: Using RAG (Retrieval-Augmented Generation) to find accurate answers from the school's knowledge base.
- Navigating the Campus: Intelligently detecting commands like "Show me the library" to take users directly into a 3D Virtual Tour.
- Self-Correction: Automatically fixing typos (e.g., "fee stracture") before processing queries to ensure high accuracy.
graph TD
%% Nodes
User(("👤 User"))
FE["💻 Frontend (Chatbot.js)"]
Backend["🚀 Node.js Backend"]
subgraph Intelligence Layer
Router{"🚦 Intent Router"}
SpellCheck["✨ AI Grammar Fix"]
VectorDB[("🗄️ Supabase Vector DB")]
end
subgraph Outcomes
Nav["🧭 Open 3D Panorama"]
Answer["💬 Text Response"]
end
%% Flow
User -->|Type: 'Go to Library'| FE
FE -->|POST /api/chat| Backend
Backend --> Router
%% Branch 1: Navigation
Router -- "Navigation Detected" --> Nav
Nav -.->|JSON Command| FE
FE -.->|Open Vista Tour| User
%% Branch 2: Q&A
Router -- "Info Query" --> SpellCheck
SpellCheck -->|Normalized Text| VectorDB
VectorDB -->|Semantic Search| Answer
Answer -.->|JSON Response| FE
FE -.->|Display Text| User
-
Frontend (
/frontend):- Built with Vanilla JS for maximum speed.
vista.js: Manages the 3D 360° environment.chat.js: Handles user input and displays responses.
-
Backend (
/backend):server.js: Express server running on Port 3000.aiIntentRouter.js: The traffic cop. It decides if a user wants to Chat or Travel.chatController.js: The main brain. It orchestrates the spell-check -> search -> respond workflow.aiService.js: Wraps Google Gemini for checking grammar and generating embeddings (text-embedding-004).
-
Database (Supabase):
- Stores Questions & Answers.
- Uses pgvector to perform "Semantic Search" (matching meaning, not just keywords).
The bot is aware of the virtual tour active in the background.
- User: "Take me to the auditorium"
- Bot: Detects destination -> commands 3D Player to rotate/load the specific scene instantly.
We don't let the AI "hallucinate" answers.
- Process: User query -> Vector Search in trusted School Database -> Return the exact matched answer.
- Safety: If the school hasn't published an answer, the bot politely says "I don't know," preventing misinformation.
- Input: "wht is fee for 11th std??"
- AI Fix: "What is the fee for 11th standard?"
- Result: High-accuracy database retrieval even with broken English.
- Node.js (v18+)
- Supabase Account (URL & Public Key)
- Google Gemini API Key
git clone <repo-url>
cd backend
npm installCreate a .env file in the backend/ folder:
PORT=3000
# Database Connection
SUPABASE_URL=your_supabase_url
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
# Intelligence
GEMINI_API_KEY=your_gemini_key
GEMINI_MODEL=gemini-pro# In the backend terminal
npm run devEnsure frontend/js/config.js matches your backend port:
window.ChatbotConfig = {
API_BASE_URL: "http://localhost:3000"
};Chatbot/
├── 📂 admin/ # Admin Dashboard (Manage Content)
├── 📂 backend/ # Node.js Server
│ ├── 📂 controllers/ # Logic (Chat, Router)
│ ├── 📂 services/ # Integrations (AI, Supabase)
│ └── server.js # Entry Point
├── 📂 frontend/ # Client-Side Code
│ ├── 📂 js/ # Logic (Vista, Chat, UI)
│ └── 📂 css/ # Styling
└── README.md # This file
The main endpoint for all interactions.
Request Body:
{
"question": "show me the library",
"panoNames": ["Library", "Office", "Ground"], // Available 3D Scenes
"projectNames": []
}Response (Navigation):
{
"success": true,
"intent": "pano",
"target": "Library",
"action": "pano"
}Response (Text Answer):
{
"answer": "The library is open from 8 AM to 4 PM.",
"confidence": 0.92,
"normalizedQuestion": "show me the library"
}