A simple rule-based chatbot built in Python, created as part of the CodeAlpha Python Programming Internship (Task 4).
This program simulates a basic conversation using keyword matching. The user types a message, and the chatbot replies based on predefined rules β no AI or external libraries required.
- Responds to greetings, "how are you", name questions, and thanks
- Case-insensitive and forgiving input matching (e.g. "Hello!" and "hello" both work)
- Multiple exit keywords:
bye,goodbye,exit,quit - Handles empty input gracefully
- Improved version includes varied, randomized responses for a more natural feel
- Functions
if-elif-elseconditional logicwhileloops- Input/output handling
- Lists and the
inoperator random.choice()for response variety (improved version)
- Python 3.7 or higher (no external libraries needed)
- Clone this repository:
git clone https://github.com/<your-username>/CodeAlpha_BasicChatbot.git cd CodeAlpha_BasicChatbot
- Run the script:
Or run the improved version:
python chatbot.py
python chatbot_improved.py
- Type a message and press Enter. Try:
hellohow are youwhat is your namethanksbye(to end the conversation)
Chatbot: Hello! I'm your CodeAlpha chatbot.
Chatbot: Type 'bye' anytime to end our conversation.
You: hello
Chatbot: Hi! How can I help you today?
You: how are you
Chatbot: I'm fine, thanks! How about you?
You: bye
Chatbot: Goodbye! Have a great day.
CodeAlpha_BasicChatbot/
βββ chatbot.py # Basic version (matches PDF requirements exactly)
βββ chatbot_improved.py # Enhanced version with varied responses
βββ README.md # Project documentation
This project was built for the CodeAlpha Python Programming Internship.
- Website: www.codealpha.tech