A lightweight, rule-based console chatbot built with C#. This project demonstrates basic programming concepts including input handling, conditional logic, and modular code organization.
- Simple command-line interface
- Case-insensitive command recognition
- Greeting responses for "hi" and "hello"
- Exit command to terminate the program
- Null/empty input handling
- Basic error handling with try-catch
SRA/
├── SRA.EntryPoint.cs - Entry point, exception handling
├── SRA.Core.cs - Main chat logic and loop control
└── SRA.InputHandle.cs - Response messages handler
- .NET SDK (version 6.0 or later)
- Any C# compatible IDE (Visual Studio, VS Code, Rider, or command line)
git clone https://github.com/dryfish09/SmallRuleAI.git
cd SmallRuleAI/src
dotnet restore
dotnet builddotnet runWelcome! Type 'exit' to exit program
You: hi
AI: Hi there! What's up!
You: hello
AI: Hi there! What's up!
You: how are you?
AI: Sorry, I don't know about that
You:
AI: Oops! Please talk anything!
You: exit
(Program ends)
| Command | Response |
|---|---|
hi, hello |
Greeting message |
exit |
Exit the program |
| (empty input) | Null input handler |
| anything else | Default fallback response |
- Program.Main() - Initializes the program and handles unexpected exceptions
- Core.Logic() - Runs the main chat loop:
- Reads user input
- Normalizes text (lowercase + trim)
- Checks for keywords using conditional statements
- Calls appropriate response methods
- Response class - Contains static methods for different reply types
// Core logic snippet
string input = Console.ReadLine()?.ToLower().Trim() ?? "";
if(string.IsNullOrWhiteSpace(input))
{
Response.HandleNull();
}
else if(input.Contains("hi") || input.Contains("hello"))
{
Response.Greet();
}
else if(input == "exit")
{
run = false;
}- Add more keywords and responses
- Implement random response variations
- Add conversation history tracking
- Integrate with real AI APIs (OpenAI, etc.)
- Add configuration file for custom responses
- Implement natural language processing
- Save chat logs to file
Feel free to fork this project and add more features! This is a great starting point for learning C# and OOP concepts.
MIT License - feel free to use, modify, and distribute.
Dry Fish
Note: This is a rule-based chatbot, not an AI/ML model. It responds based on keyword matching only.