Worked example · Python, Flask and SQLite
Student Enquiry Chatbot source code
An offline rule-based chatbot that answers student enquiries for the Computer Science department at the university. Students type questions without logging in. The system cleans the text, removes stop words, scores every stored answer by how many of its keywords appear, and returns the best answer with its score. A score below 0.4 shows an 'I don't know' message with suggested questions. Students can mark a matched answer helpful or not, and staff see the helpful and not helpful counts on the enquiry log. Staff manage the official answers, categories and keywords, and read the enquiry log and most-asked counts. Lecturers read the FAQ list only. The system does not learn by itself, does not call an online service, and does not use a large language model.
A real system made by the same builder you would use. Yours is built for your own topic and answers, so its screens and tables will differ. This example is not a source-code download.
The problem it solves
Students often struggle to find accurate information about admission, registration, fees, timetables, results, staff contacts and departmental rules. A local chatbot that works without internet gives instant answers from department-approved content.
Project topic: Development of an AI Chatbot for Answering Student Enquiries in a University Department
Who uses it
admin
Department staff member who manages answers, categories and keywords, and views enquiry logs.
- Login
- Add, edit and delete answers
- Add, edit and delete categories
- Manage keywords
- View enquiry logs
lecturer
Lecturer who can only view the list of frequently asked questions.
- Login
- Read FAQs
student
Student or any anonymous visitor who can ask questions and read answers without logging in.
- Ask questions
- Read answers
- See suggested questions when no good match
What it does
Ask a question
Public page where a student types a question. The system cleans the text, matches it against stored answers using keyword scoring, and shows the best answer with its score. Under a matched answer the student can click Yes or No for 'Was this answer helpful?', and the choice is saved. If no score reaches 0.4, it shows an 'I don't know' message with up to three suggested questions. Every question is logged.
Manage answers and categories
Staff only. One screen to list, add, edit and delete answers and categories. Each answer has a category, question title, answer text and keywords. The answer form sits beside the answer list, with a second form for categories.
Enquiry log and most asked
Staff only. One screen showing every question asked, the matched answer title, score and time, plus a count of the most asked questions and the helpful and not helpful answer counts on the same page.
Frequently asked questions
Read-only paginated list of all answers, ordered by category. Lecturers can only open this page.
Login
Standard login screen with hashed passwords and CSRF protection. Assigns the correct role to the session.
Screenshots
Screenshots of the running system, taken by our checks. The records are sample data and are labelled so on each page.




Database tables
- usersStores staff and lecturer logins with hashed passwords.id, username, password_hash, full_name, role, created_at
- categoriesOrganises answers into seven fixed topics.id, name, description
- answersOfficial answers written by staff, with keywords used for matching.id, category_id, title, answer_text, keywords, created_at, updated_at
- enquiriesLogs every question typed by a student, with the matched answer and score.id, question, answer_id, score, asked_at, helpful
Technology
- Python. Standard for the course and works fully offline.
- Flask. Lightweight and easy to explain.
- Jinja. Renders HTML pages with variables and loops.
- SQLite. File based, no server, and included with Python.
- Bootstrap. Works offline and looks clear on a laptop and projector.
- Chart.js. Draws simple bar charts without an internet connection.
- Werkzeug. Secure storage of staff logins.
- Flask-WTF CSRFProtect. Prevents cross-site request forgery.
How to run it: running a Python project on Windows. Not sure which language to pick? Python or PHP.
How it was tested
28 of 28 tests passed, 23 of them automated. The system was also installed from scratch and every screen was opened as the right kind of user before it was accepted.
What it does not do
- The matcher compares whole keywords only, so it does not understand meaning, word endings or spelling mistakes. The word 'requirement' does not match the keyword 'requirements'.
- The 0.4 threshold is a demonstration value chosen for this build and is not calibrated.
- A question with no matching keyword gets no evidence at all, so the chatbot says it does not know rather than guessing. This is intended.
- Every answer must be written and maintained by a person. The system never writes or learns an answer by itself.
- The system is a teaching demonstration, not official university advice. All sample answers are fictional.
- Only plain text answers are supported. There are no images and no rich formatting.
- There is no spelling correction, no stemming and no synonyms list, so a student must use some of the stored keywords.
- The log stores the question text only, so nothing links a question to a named student.
- Feedback is offered only when the chatbot matched an answer. A no-match response has no answer to rate, and the helpful column stays null for that enquiry.
- The system does not connect to the internet, does not send email, does not take payments, does not register students for courses and does not replace the official university portal.
- The offline browser checks in check-report.json ran in a Linux sandbox. Windows was not tested here, so a student must confirm run.bat on Windows before the defence.
Chapters 3 and 4 from this system
With the MonoEd FYP Generator, signed in with the same Google account, press “Use my working system” when you write Chapter 3 or 4. Its real users, 4 database tables, screenshots and 28 test results go into the chapters, laid out under your supervisor's headings. Nothing is invented: anything the system cannot show, such as a user test, is left for you to fill in.
Want a student enquiry chatbot for your own school or business case?
Get a system built for your topic, with a guide, defence questions and screenshots. Plan it free, then ₦13,500 only if you want it built. View pricing.
Start with this topic