This project was developed as part of my DecodeLabs Artificial Intelligence Industrial Training.
The goal of the project is to build a simple rule-based chatbot in Python that responds to predefined user inputs using deterministic logic. The chatbot does not use machine learning or a large language model. Instead, it follows explicit rules so that each recognized input produces a predictable response.
The project focuses on the foundations of conversational logic and control flow.
The chatbot can:
- Accept user input
- Normalize text using lowercase conversion and whitespace removal
- Respond to predefined greetings and questions
- Recognize exit commands
- Return a fallback response for unknown input
- Continue running until the user chooses to end the conversation
The chatbot follows a simple input-process-output flow:
- The user enters a message.
- The input is cleaned using
lower()andstrip(). - The program checks whether the input is an exit command.
- Known inputs are matched with predefined responses.
- Unknown inputs receive a fallback response.
- The chatbot continues running inside a
whileloop until the user exits.
- Python control flow
- Conditional logic
whileloops- Dictionaries
- Dictionary
.get()lookup - Input normalization
- Functions
- Fallback handling
- Deterministic response logic
You can try messages such as:
hellohihow are youwhat is your namewhat can you dohelpthanksbyeexitquit
.
├── chatbot.py
├── chatbot-demo.png
├── README.md
└── .gitignore
Make sure Python is installed on your computer.
Run the chatbot with:
python chatbot.pyIf needed, use:
python3 chatbot.pyThe chatbot will continue accepting input until you enter an exit command such as bye, exit, quit, or goodbye.
Completed and tested successfully.
Shayan Akbar
Developed as part of the DecodeLabs Artificial Intelligence Industrial Training Program.