The AI Chatbot is a guided help system integrated into the quiz portion of the mobile application. It provides structured, curriculum-aligned explanations when a student needs additional support. It is not a free-form chatbot; instead, the user selects from predefined prompts, and the AI generates controlled, relevant responses.
The chatbot appears as a popup with a conversation-style interface. AI messages appear on the left, and user-selected prompts appear on the right. The popup includes conversation history, timestamps, optional sound effects, UI animations, and multilingual support.
- Provide clarification for quiz questions in a controlled format.
- Maintain alignment with existing curriculum content.
- Prevent off-topic or unrestricted AI interactions.
- Help students without requiring teacher intervention.
-
Prompt-based interaction
- No free text input.
- User selects from predefined follow-up prompts.
-
AI-driven responses
- Responses are generated using API models.
- Prompts include the detected topic of the question.
-
Conversation UI
- Chat-style layout:
- AI messages on the left
- User prompt selections on the right
- Scrollable message history
- Chat-style layout:
-
Multilingual Support
- English
- Russian
- Kazakh
-
Additional Enhancements
- Timestamps on messages
- Animated popup transitions
- Optional message sound effects
- Configurable chatbot personality (name, tone)
- Clean and consistent visual design
Key Files
-
main.dart
Application entry point; includes routing to quiz and chatbot screens. -
chat_popup.dart
UI for the chatbot popup. Handles:- conversation rendering
- prompt buttons
- language switching
- animations
- sound triggering
-
ai_service.dart
Handles communication with the AI model API. Responsible for:- building structured prompts
- sending requests
- parsing responses
-
sound_service.dart
Plays optional sound effects for messages. -
quiz_data.dart
Provides quiz content, including question text and topic metadata.
- User answers a quiz question.
- User taps the help/lightbulb button.
- Chatbot popup opens.
- Topic is determined based on the current quiz question.
- User selects a prompt:
- “Explain in simpler terms”
- “Give an example”
- “Explain further”
ai_servicebuilds a structured prompt and sends it to the API.- Response is returned and displayed as a left-aligned AI message.
- The selected prompt is shown as a right-aligned user message.
- Conversation history accumulates until the popup is closed.
- Flutter (latest stable recommended)
- Gemini or compatible model API key
- Internet connection for API calls
- Assets folder for sound effects:
GEMINI_API_KEY=KEY
GEMINI_MODEL=gemini-2.5-flash
GEMINI_BASE_URL=https://generativelanguage.googleapis.com/v1beta/models
- if there is an issue with flutter run, delete the build folder