# Guide to Creating Your Own Chatbot

This guide will help you create a simple, extensible chatbot with support for rules, synonyms, and automatic responses.

---

## Configuration Structure

The chatbot configuration typically includes three main components:

### 1. Synonymizer (`synonymizer`)
- Provides expanded phrase recognition through synonyms.
- Format: an object where the key is a word or phrase, and the value is an array of synonyms.

**Example:**
```json
"synonymizer": {
  "hello": ["hi", "greetings"]
}
```

---

### 2. Rules (`rules`)
- Define the bot's responses to specific conditions.
- Each response is a key-value pair, where the key is the reply text, and the value is an array of conditions.
- All conditions within a single rule must be met (AND logic).

**Format:**
```json
"rules": {
  "Bot reply": [["contains", "keyword"], ["contains", "another word"]]
}
```

**Example:**
```json
"rules": {
  "Hello! How can I assist?": [["contains", "hello"]]
}
```

---

### 3. Default Response (`default`)
- Text that the bot returns if no rules are matched.

```json
"default": "Sorry, I didn't understand the question. Could you rephrase?"
```

---

## Example Configuration

```json
{
  "synonymizer": {
    "hello": ["hi", "greetings"],
    "fact": ["facts"],
    "cow": ["cows", "cows in"]
  },
  "rules": {
    "Hello! How can I assist?": [["contains", "hello"]],
    "Cows are very interesting animals! They produce milk and are important for agriculture.": [["contains", "cow"], ["contains", "fact"]]
  },
  "default": "Sorry, I didn't understand the question. Could you rephrase?"
}
```

---

## Creating Your Own Bot

### Steps:

1. **Define a list of keywords and synonyms** in the `synonymizer`.
2. **Create rules in `rules`**, linking responses with conditions.
3. **Set up the default response** for unrecognized inputs.
4. **Implement a parser** that:
   - Receives user input.
   - Expands it using the synonymizer.
   - Checks the rule conditions.
   - Returns the matching response or the default.

---

## Tips

- Use the synonymizer to enhance phrase recognition.
- Add new rules as needed.
- Handle complex scenarios with a combination of conditions.

---

## Summary

Building your own chatbot involves configuring rules, expanding the synonym dictionary, and processing user input. Use a simple structure and gradually add new scenarios.