NIWA (Artificial Responsive Intelligence Assistant) is a Java-based AI chatbot with a modern Swing GUI. It uses rule-based Natural Language Processing (NLP) through regex pattern matching to understand user input and generate contextual responses.
| Feature | Description |
|---|---|
| 💬 Conversation | Greetings, farewells, small talk |
| 🕐 Real-time Clock | Tells the current time |
| 📅 Date Awareness | Tells today's date |
| 🧮 Math Solver | Evaluates arithmetic: +, -, *, / |
| 😄 Jokes | 8+ built-in programmer jokes |
| ☕ Java Q&A | Answers questions about Java/OOP |
| ❓ Help Menu | Lists all capabilities |
| 🗑️ Clear Chat | Clears the conversation with confirmation |
| ✍️ Typing Indicator | Simulates NIWA "thinking" |
CodeAlpha_AIChatbot/
├── src/
│ └── com/codealpha/chatbot/
│ ├── Main.java ← Entry point
│ ├── model/
│ │ └── Message.java ← Message data model
│ ├── engine/
│ │ └── ChatEngine.java ← NLP brain (intent matching)
│ └── gui/
│ └── ChatbotGUI.java ← Swing GUI (chat window)
├── out/ ← Compiled .class files (auto-generated)
├── run.bat ← Windows run script
├── run.sh ← Linux/Mac run script
└── README.md
- Java 11+ — Core language
- Java Swing — GUI framework (JFrame, JPanel, JLabel, JScrollPane)
- Java Regex —
java.util.regexfor NLP pattern matching - Java Time API —
java.timefor live clock & date - OOP Principles — Encapsulation, inner classes, separation of concerns
- JDK 11 or higher installed
javacandjavaavailable in your PATH
run.batchmod +x run.sh
./run.sh# 1. Compile
javac -d out -sourcepath src src/com/codealpha/chatbot/Main.java src/com/codealpha/chatbot/model/Message.java src/com/codealpha/chatbot/engine/ChatEngine.java src/com/codealpha/chatbot/gui/ChatbotGUI.java
# 2. Run
java -cp out com.codealpha.chatbot.Main- User types a message and presses Enter or clicks Send.
ChatEngine.getResponse(input)is called.- The engine first checks if input is a math expression (regex:
\d+ op \d+). - If not math, the input is matched against 14+ intent categories, each with multiple regex patterns.
- A random response is selected from the matched intent's response pool.
- Special markers (
__TIME__,__DATE__) are resolved dynamically. - If nothing matches, a fallback response is returned.
User: hello
NIWA: Hey! Great to see you. How can I help?
User: what time is it
NIWA: The current time is: 10:35 AM 🕐
User: 25 * 4
NIWA: 🧮 25 * 4 = 100
User: tell me a joke
NIWA: Why do programmers prefer dark mode?
Because light attracts bugs! 🐛
User: who made you
NIWA: I was created as part of the CodeAlpha Java Internship program! 🎓
- Name: [NIHA HAWAS]
- Institution: [SZABIST ISLAMABAD]
- Internship: CodeAlpha — Java Programming
- GitHub: [https://github.com/nihahawas]
- Linkedin: [https://www.linkedin.com/in/nihahawas45]
This project was built for educational purposes as part of the CodeAlpha Java Internship Program.