Skip to content

About

๐Ÿค– A beginner-friendly rule-based Python chatbot built to practice Python fundamentals.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– Rubi โ€” Rule-Based Python ChatBot

A beginner-friendly rule-based chatbot built with Python to practice functions, dictionaries, loops, conditions, user input, and the datetime module.


๐ŸŒŸ Project Overview

Rubi is a simple command-line chatbot that interacts with the user using predefined rules and responses.

The chatbot can:

  • ๐Ÿ‘‹ Greet the user based on the current time
  • ๐Ÿง‘ Ask for and use the user's name
  • ๐Ÿ’ฌ Respond to predefined questions
  • ๐Ÿง  Match keywords from user input
  • ๐Ÿ”„ Continue the conversation using a loop
  • ๐Ÿ‘‹ Exit when the user types bye

This project was created as part of my journey to strengthen my Python fundamentals through hands-on projects.


โœจ Features

Feature Description
๐Ÿ• Time-based Greeting Morning, afternoon, evening, and night greetings
๐Ÿ‘ค User Name Takes the user's name at startup
๐Ÿ’ฌ Rule-Based Responses Uses predefined chatbot responses
๐Ÿ”Ž Keyword Matching Finds matching keywords in user questions
๐Ÿ” Continuous Chat Uses while loop for conversation
๐Ÿšช Exit Command Type bye to exit
๐Ÿ“š Dictionary Memory Stores chatbot questions and responses

๐Ÿ› ๏ธ Technologies Used

  • Python 3
  • datetime module
  • Python Dictionaries
  • Functions
  • if / elif / else
  • for loop
  • while loop
  • String methods
  • User input

๐Ÿง  How Rubi Works

The chatbot follows a simple rule-based flow:

             ๐Ÿ‘ค User
                โ”‚
                โ–ผ
        Enter Name / Question
                โ”‚
                โ–ผ
       Convert Input to Lowercase
                โ”‚
                โ–ผ
       Check Dictionary Keywords
                โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ”‚                โ”‚
      Match            No Match
        โ”‚                โ”‚
        โ–ผ                โ–ผ
  Return Response    Default Response
        โ”‚                โ”‚
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                โ–ผ
        Continue Conversation
                โ”‚
                โ–ผ
           Type "bye"
                โ”‚
                โ–ผ
             ๐Ÿ‘‹ Exit

๐Ÿ“ Project Structure

rule-based-python-chatbot/
โ”‚
โ”œโ”€โ”€ rubi_chatbot.py
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ screenshots/
    โ”œโ”€โ”€ chatbot-start.png
    โ””โ”€โ”€ chatbot-conversation.png

๐Ÿš€ Getting Started

1๏ธโƒฃ Clone the Repository

git clone https://github.com/Annu1528/Rubi---Rule-Based-Python-ChatBot

2๏ธโƒฃ Open the Project

cd rule-based-python-chatbot

3๏ธโƒฃ Run the Chatbot

python rubi_chatbot.py

๐Ÿ’ป Example Conversation

Swagat hai! Enter your name: Anushka

Good Afternoon! Anushka

Namaste! Welcome to Rubi, Your Rule Based ChatBot
You can ask me basic questions. Type 'bye' to exit from the bot

Please ask your question: hello

Bot Response: Hi welcome. How can I help you?

Please ask your question: how are you

Bot Response: I am very fine, ThankYou

Please ask your question: motivate me

Bot Response: Keep going. Every bug of your project makes you a better developer.

Please ask your question: bye

Bot Response: Bye! Have a great day!

๐Ÿ“ธ image

๐Ÿงฉ Core Code Logic

Rubi stores its responses inside a Python dictionary:

responses = {
    "hello": "Hi welcome. How can I help you?",
    "how are you": "I am very fine, ThankYou",
    "who are you?": "I am a smart AI ChatBot",
    "motivate me": "Keep going. Every bug of your project makes you a better developer",
    "happy": "Great to hear that!"
}

The chatbot then checks whether a keyword exists inside the user's question:

for eachKey in responses:
    if eachKey in UserQuestion:
        return responses[eachKey]

This makes Rubi a rule-based chatbot rather than a machine-learning chatbot.


๐Ÿ“š Python Concepts Practiced

This project helped me practice:

Variables

name = input(...)
presentHour = datetime.datetime.now().hour

Conditions

if 5 <= presentHour < 12:
    ...
elif 12 <= presentHour < 17:
    ...
else:
    ...

Functions

def getResponseOfBot(UserQuestion):
    ...

Dictionaries

responses = {
    "hello": "...",
    "happy": "..."
}

Loops

while True:
    ...

and:

for eachKey in responses:
    ...

String Methods

UserQuestion.lower()

๐ŸŽฏ Learning Goals

The main goal of this project was not to build a complex AI system.

The goal was to understand how basic Python concepts can work together to build a small, functional application.

Through this project, I practiced:

  • Writing reusable functions
  • Working with dictionaries
  • Handling user input
  • Using loops
  • Applying conditional logic
  • Using Python modules
  • Debugging syntax and logic errors
  • Structuring a small Python project

๐Ÿ”ฎ Future Improvements

Planned improvements for Rubi:

  • Add more conversation rules
  • Add help command
  • Add current date and time responses
  • Add calculator functionality
  • Improve keyword matching
  • Add better error handling
  • Store conversation history
  • Add a simple GUI
  • Eventually experiment with an actual AI/API-based chatbot

๐Ÿ› Debugging Lessons

During development, I encountered and fixed issues related to:

  • Case-sensitive variable names
  • Dictionary access syntax
  • Loop control using break
  • Ordering of conditions
  • Handling user input
  • Running the correct Python file

These debugging experiences were an important part of building the project.


๐Ÿ‘ฉโ€๐Ÿ’ป Author

Anushka

Learning Python through practical projects and gradually building towards Cloud, DevOps, and automation.


โญ Support

If you found this project useful, consider giving the repository a โญ.

More Python projects coming soon! ๐Ÿš€


๐Ÿ“Œ Project Status

Status: ๐ŸŸข Completed โ€” Version 1.0

Type: Beginner Python Project

Category: Rule-Based Chatbot

About

๐Ÿค– A beginner-friendly rule-based Python chatbot built to practice Python fundamentals.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages