Career & Courses Academy — Rule-Based Chatbot System is a complete, production-ready, database-driven conversational assistant built entirely on Core PHP 8, MySQL, HTML5, CSS3, and Vanilla JavaScript. It is designed to help educational institutions automate their admission enquiry process by guiding prospective students through a personalised decision-tree conversation — without writing a single line of code to change the flow.
Unlike static FAQ widgets or third-party SaaS chatbots, this system puts complete control in the administrator's hands. Every question, option, branching rule, lead field, colour, and message is stored in MySQL and managed through a modern admin panel. The administrator creates questions visually — Question → Options → Next Question — and the chatbot instantly follows the new flow. No PHP file, HTML template, or JavaScript file needs editing to change the conversation.
The system follows a clean, modular three-layer architecture: a floating front-end chatbot embedded on any website via a single JS/CSS snippet, a JSON-based backend API built with PDO and prepared statements, and a full-featured admin control panel secured by PHP sessions, CSRF tokens, and password_hash() authentication.
How the Flow Engine Works
The most important design decision is that the browser is never trusted. When a visitor selects an option, JavaScript sends only the option_id to the server. The PHP backend then:
Validates the conversation and the current question.
Confirms the option actually belongs to that question.
Saves the user message and answer to MySQL.
Reads next_question_id from the database — never from the browser.
Saves the bot's next message.
Returns the next question as JSON.
This guarantees the flow cannot be tampered with — no user can send next_question_id = 25 and jump to an arbitrary step.
Question Types Supported
The admin can configure nine different question types: Single Choice (buttons), Multiple Choice (checkboxes), Dropdown, Yes/No (large buttons), Text, Indian Mobile (validated server-side against ^[6-9]\d{9}$), Email, Number, and Date picker.
Visitor Experience
The front end offers a premium, WhatsApp-style chat experience — a floating circular launcher (with custom branding), a smooth 400×650 window (near-fullscreen on mobile), animated typing indicator, timestamped message bubbles, date separators, and smooth AJAX transitions with no page reloads. Conversations are stored with a unique UUID (e.g. CC-20260916-000125) and automatically resume after a page refresh from the last unanswered question.
Admin Capabilities
The admin panel includes a professional dashboard with six stat cards and four Chart.js visualisations (daily conversations, completion rate, course interest, lead funnel), full question CRUD with a visual flow builder, an editable conversation transcript viewer, lead management with status pipeline, reporting with date-range filters, CSV export, and a settings page for colours, messages, auto-open behaviour, and admin password.
Timezone Compliance
Every timestamp is enforced in Asia/Kolkata (IST) — both in PHP (date_default_timezone_set) and at the MySQL session level (SET time_zone = '+05:30'), so NOW() and date() always agree.
Security
The system implements PDO prepared statements on every query, htmlspecialchars() output escaping, CSRF tokens on all admin POSTs, bcrypt password hashing, hardened sessions (HttpOnly, SameSite=Lax, ID rotation, 2-hour idle timeout), IP-based rate limiting on all chatbot endpoints, and login throttling.
In short, it is a professional, secure, and fully configurable admission assistant that any non-technical administrator can fully reshape in minutes — a genuine production tool, not a demo.