diff --git a/README.md b/README.md
index 116d022a..e76855a6 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,17 @@
-# General Bots
+# General Bots Documentation (BotBook)
+
+**Version:** 6.2.0
+**Purpose:** Comprehensive documentation for General Bots (mdBook format)

-**Enterprise-Grade LLM Orchestrator & AI Automation Platform**
+---
-A strongly-typed, self-hosted conversational platform focused on convention over configuration and code-less approaches.
+## Overview
+
+BotBook is the official documentation repository for General Bots, built using [mdBook](https://rust-lang.github.io/mdBook/). It provides comprehensive guides, API references, tutorials, and architectural documentation for the entire General Bots platform - an enterprise-grade LLM orchestrator and AI automation platform.
+
+For the latest live documentation, visit **[docs.pragmatismo.com.br](https://docs.pragmatismo.com.br)**.
---
@@ -14,7 +21,7 @@ A strongly-typed, self-hosted conversational platform focused on convention over
---
-## π¦ Repositories
+## π¦ General Bots Repositories
| Repository | Description | Status |
|------------|-------------|--------|
@@ -33,6 +40,7 @@ A strongly-typed, self-hosted conversational platform focused on convention over
- **Rust** (latest stable) - [Install from rustup.rs](https://rustup.rs/)
- **Git** - [Download from git-scm.com](https://git-scm.com/downloads)
+- **mdBook** - `cargo install mdbook`
### Run the Server
@@ -63,6 +71,20 @@ cd botapp
cargo tauri dev
```
+### Build Documentation
+
+```bash
+# Clone botbook
+git clone https://github.com/GeneralBots/botbook
+cd botbook
+
+# Build documentation
+mdbook build
+
+# Serve locally with hot reload
+mdbook serve --open
+```
+
---
## β¨ Key Features
@@ -100,6 +122,182 @@ CLEAR TOOLS ' Remove all tools from session
---
+## π Documentation Structure
+
+```
+botbook/
+βββ book.toml # mdBook configuration
+βββ src/
+β βββ SUMMARY.md # Table of contents
+β βββ README.md # Introduction
+β βββ 01-introduction/ # Quick Start
+β βββ 02-templates/ # Package System
+β βββ 03-knowledge-base/ # Knowledge Base
+β βββ 04-gbui/ # UI Interface
+β βββ 06-gbdialog/ # BASIC Dialogs
+β βββ 08-config/ # Configuration
+β βββ 10-rest/ # REST API
+β βββ 12-auth/ # Authentication
+β βββ assets/ # Images, diagrams
+βββ i18n/ # Translations
+βββ book/ # Generated output
+```
+
+---
+
+## π Documentation Writing Guidelines
+
+### β
Keyword Naming Rules - MANDATORY
+
+**Keywords NEVER use underscores. Always use spaces.**
+
+| Write This | NOT This |
+|------------|----------|
+| `SEND MAIL` | `SEND_MAIL` |
+| `GENERATE PDF` | `GENERATE_PDF` |
+| `MERGE PDF` | `MERGE_PDF` |
+| `DELETE` | `DELETE_HTTP` |
+| `SET HEADER` | `SET_HEADER` |
+| `FOR EACH` | `FOR_EACH` |
+
+#### Correct Syntax Examples
+```basic
+SEND MAIL to, subject, body, attachments
+GENERATE PDF template, data, output
+MERGE PDF files, output
+DELETE "url"
+ON ERROR RESUME NEXT
+SET BOT MEMORY key, value
+KB STATISTICS
+```
+
+#### β NEVER Use Underscores
+```basic
+SEND_MAIL ' WRONG!
+GENERATE_PDF ' WRONG!
+DELETE_HTTP ' WRONG!
+```
+
+---
+
+### π¨ Official Icons - MANDATORY
+
+**NEVER generate icons with LLM. Use official SVG icons from `botui/ui/suite/assets/icons/`**
+
+#### Usage in Documentation
+```markdown
+
+
+
+
+
+```
+
+#### Required Icons
+```
+ui/suite/assets/icons/
+βββ gb-logo.svg # Main GB logo
+βββ gb-bot.svg # Bot/assistant
+βββ gb-analytics.svg # Analytics
+βββ gb-calendar.svg # Calendar
+βββ gb-chat.svg # Chat
+βββ gb-drive.svg # File storage
+βββ gb-mail.svg # Email
+βββ gb-meet.svg # Video meetings
+βββ gb-tasks.svg # Task management
+βββ ...
+```
+
+All icons use `stroke="currentColor"` for CSS theming.
+
+---
+
+### π« NO ASCII Diagramrams - MANDATORY
+
+**NEVER use ASCII art diagrams. ALL diagrams must be SVG.**
+
+#### β Prohibited ASCII Patterns
+```
+βββββββββββ βββββββββ +-------+
+β Box β β Box β | Box |
+βββββββββββ βββββββββ +-------+
+```
+
+#### β
What to Use Instead
+
+| Instead of... | Use... |
+|---------------|--------|
+| ASCII box diagrams | SVG diagrams in `assets/` |
+| ASCII flow charts | SVG with arrows and boxes |
+| ASCII directory trees | Markdown tables |
+
+---
+
+### π¨ SVG Diagram Guidelines
+
+All SVGs must support light/dark modes:
+
+```xml
+
+```
+
+---
+
+### π¬ Conversation Examples
+
+Use WhatsApp-style HTML format for bot interactions:
+
+```html
+
π Contact Details
βββββββββββββββββ
π€ Name: Maria Santos
-π§ Email: maria.santos@company.com
+π§ Email: santos@company.com
π± Phone: +55 11 98765-4321
π’ Company: Tech Solutions Ltd
π·οΈ Tags: lead
@@ -139,7 +139,7 @@ Add these settings to your `config.csv`:π Found 3 contacts at "Tech Solutions":
-1. Maria Santos - maria.santos@company.com
+1. Maria Santos - santos@company.com
π± +55 11 98765-4321 | π·οΈ lead
2. JoΓ£o Silva - joao.silva@techsolutions.com
@@ -300,4 +300,4 @@ Use the `POST` and `GET` keywords to sync contacts with Salesforce, HubSpot, or .wa-bubble p{margin:0 0 4px 0;line-height:1.4;color:#303030} .wa-bubble p:last-child{margin-bottom:0} .wa-time{font-size:11px;color:#8696a0;text-align:right;margin-top:4px} - \ No newline at end of file + diff --git a/src/06-gbdialog/keyword-synchronize.md b/src/06-gbdialog/keyword-synchronize.md index a2b4dae5..a267fdc9 100644 --- a/src/06-gbdialog/keyword-synchronize.md +++ b/src/06-gbdialog/keyword-synchronize.md @@ -51,12 +51,12 @@ pageVariable = "pagina" limitVariable = "limite" SEND EMAIL admin, "Syncing categories..." -SYNCHRONIZE /categorias/receitas-despesas, maria.CategoriaReceita, Id, pageVariable, limitVariable +SYNCHRONIZE /categorias/receitas-despesas, CategoriaReceita, Id, pageVariable, limitVariable SEND EMAIL admin, REPORT RESET REPORT ' Sync payment methods -SYNCHRONIZE /formas-pagamentos, maria.FormaDePagamento, Id, pageVariable, limitVariable +SYNCHRONIZE /formas-pagamentos, FormaDePagamento, Id, pageVariable, limitVariable SEND EMAIL admin, REPORT RESET REPORT ``` @@ -69,7 +69,7 @@ Until `SYNCHRONIZE` is implemented, use this pattern: ' Manual sync equivalent pageVariable = "pagina" limitVariable = "limite" -tableName = "maria.CategoriaReceita" +tableName = "CategoriaReceita" endpoint = "/categorias/receitas-despesas" page = 1 @@ -112,7 +112,7 @@ TALK "Synced " + totalSynced + " records to " + tableName When implemented, `SYNCHRONIZE` should: 1. Use the global `host`, `limit`, `pages` variables from config -2. Support connection prefixes (e.g., `maria.TableName`) +2. Support connection prefixes (e.g., `TableName`) 3. Handle API errors gracefully with retry logic 4. Update the `REPORT` variable with sync statistics 5. Support both REST JSON responses and paginated arrays @@ -120,4 +120,4 @@ When implemented, `SYNCHRONIZE` should: ## See Also - [Script Execution Flow](./script-execution-flow.md) - How config variables are injected -- [Data Operations](./keywords-data.md) - Data manipulation keywords \ No newline at end of file +- [Data Operations](./keywords-data.md) - Data manipulation keywords diff --git a/src/06-gbdialog/keyword-table.md b/src/06-gbdialog/keyword-table.md index 9844dfd8..13693415 100644 --- a/src/06-gbdialog/keyword-table.md +++ b/src/06-gbdialog/keyword-table.md @@ -5,7 +5,7 @@ The `TABLE` keyword defines database tables directly in your `.bas` files. Table ## Syntax ```basic -TABLE TableName ON connection +TABLE TableName FieldName dataType[(length[,precision])] [key] [references OtherTable] ... END TABLE @@ -70,7 +70,7 @@ conn-maria-Driver,mariadb ### Basic Table Definition ```basic -TABLE Contacts ON maria +TABLE Contacts Id number key Nome string(150) Email string(255) @@ -82,7 +82,7 @@ END TABLE ### Table with Multiple Field Types ```basic -TABLE Produtos ON maria +TABLE Produtos Id number key Nome string(150) Sku string(20) @@ -98,7 +98,7 @@ END TABLE ### Table with Foreign Key References ```basic -TABLE Pedidos ON maria +TABLE Pedidos Id number key Numero integer Data date @@ -108,7 +108,7 @@ TABLE Pedidos ON maria Vendedor_id number END TABLE -TABLE PedidosItem ON maria +TABLE PedidosItem Id number key Pedido_id number Produto_id number @@ -122,7 +122,7 @@ END TABLE ```basic ' Contact management tables -TABLE Contatos ON maria +TABLE Contatos Id number key Nome string(150) Codigo string(50) @@ -142,7 +142,7 @@ TABLE Contatos ON maria END TABLE ' Payment methods -TABLE FormaDePagamento ON maria +TABLE FormaDePagamento Id number key Descricao string(255) TipoPagamento integer @@ -153,7 +153,7 @@ TABLE FormaDePagamento ON maria END TABLE ' Accounts receivable -TABLE ContasAReceber ON maria +TABLE ContasAReceber Id number key Situacao integer Vencimento date diff --git a/src/06-gbdialog/keyword-use-website.md b/src/06-gbdialog/keyword-use-website.md index 1e9fe80f..daf1e3f0 100644 --- a/src/06-gbdialog/keyword-use-website.md +++ b/src/06-gbdialog/keyword-use-website.md @@ -2,60 +2,96 @@ **Syntax** -``` +```basic USE WEBSITE "https://example.com" + +USE WEBSITE "https://example.com" REFRESH "1d" ``` **Parameters** - `"url"` β A valid HTTP or HTTPS URL pointing to a website that should be made available in the conversation context. +- `"refresh"` β (Optional) How often to recrawl the website. Supports: `"1d"` (1 day), `"1w"` (1 week), `"1m"` (1 month), `"1y"` (1 year). Defaults to `"1m"`. **Description** `USE WEBSITE` operates in two distinct modes: -1. **Preprocessing Mode** (Script Compilation): When found in a BASIC script during compilation, it registers the website for background crawling. The crawler service will fetch, extract, and index the website's content into a vector database collection. This ensures the website content is ready before any conversation starts. +1. **Preprocessing Mode** (Script Compilation): When found in a BASIC script during compilation, it registers the website for background crawling. The crawler service will fetch, extract, and index the website's content into a vector database collection. The crawl happens immediately on first compile, then recurs based on the REFRESH interval. 2. **Runtime Mode** (Conversation Execution): During a conversation, `USE WEBSITE` associates an already-crawled website collection with the current session, making it available for queries via `FIND` or `LLM` calls. This behaves similarly to `USE KB` - it's a session-scoped association. -If a website hasn't been registered during preprocessing, the runtime execution will fail with an appropriate error message. +If a website hasn't been registered during preprocessing, the runtime execution will auto-register it for crawling. -**Example** +**Refresh Interval Behavior** + +- **Smart Interval Selection**: If the same URL is registered multiple times with different REFRESH intervals, the **shortest interval** is always used +- **Default**: If no REFRESH is specified, defaults to `"1m"` (1 month) +- **Formats Supported**: + - `"1d"` = 1 day + - `"1w"` = 1 week + - `"1m"` = 1 month (default) + - `"1y"` = 1 year + - Custom: `"3d"`, `"2w"`, `"6m"`, etc. + +**Examples** + +Basic usage with default 1-month refresh: +```basic +USE WEBSITE "https://docs.example.com" +``` + +High-frequency website (daily refresh): +```basic +USE WEBSITE "https://news.example.com" REFRESH "1d" +``` + +Stable documentation (monthly refresh): +```basic +USE WEBSITE "https://api.example.com/docs" REFRESH "1m" +``` + +Multiple registrations - shortest interval wins: +```basic +USE WEBSITE "https://example.com" REFRESH "1w" +USE WEBSITE "https://example.com" REFRESH "1d" +' Final refresh interval: 1d (shortest) +``` + +**Runtime Example** ```basic -' In script preprocessing, this registers the website for crawling -USE WEBSITE "https://docs.example.com" - -' During conversation, this makes the crawled content available -USE WEBSITE "https://docs.example.com" -FIND "deployment procedures" -TALK "I found information about deployment procedures in the documentation." +USE WEBSITE "https://company.com/policies" REFRESH "1w" +question = HEAR "What would you like to know about our policies?" +FIND question +answer = LLM "Based on the search results, provide a clear answer" +TALK answer ``` **Preprocessing Behavior** When the script is compiled: - The URL is validated -- The website is registered in the `website_crawls` table -- The crawler service picks it up and indexes the content +- The website is registered in the `website_crawls` table with the specified refresh policy +- The crawler service immediately starts crawling the website +- Subsequent crawls are scheduled based on the REFRESH interval - Status can be: pending (0), crawled (1), or failed (2) **Runtime Behavior** When executed in a conversation: -- Checks if the website has been crawled +- Checks if the website has been registered and crawled +- If not registered, auto-registers with default 1-month refresh - Associates the website collection with the current session - Makes the content searchable via `FIND` and available to `LLM` -**With LLM Integration** +**Database Schema** -```basic -USE WEBSITE "https://company.com/policies" -question = HEAR "What would you like to know about our policies?" -FIND question -answer = LLM "Based on the search results, provide a clear answer" -TALK answer -``` +The `website_crawls` table stores: +- `refresh_policy` - User-configured refresh interval (e.g., "1d", "1w", "1m") +- `expires_policy` - Internal representation in days +- `next_crawl` - Timestamp for next scheduled crawl +- `crawl_status` - 0=pending, 1=success, 2=processing, 3=error **Related Keywords** diff --git a/src/06-gbdialog/templates/auth.md b/src/06-gbdialog/templates/auth.md index d5e45bce..5c0f47c0 100644 --- a/src/06-gbdialog/templates/auth.md +++ b/src/06-gbdialog/templates/auth.md @@ -105,7 +105,7 @@ These conversations show how the authentication template works in real-world sce @@ -430,4 +430,4 @@ END SWITCH .wa-header-info{flex:1} .wa-header-name{font-weight:600;font-size:16px} .wa-header-status{font-size:12px;opacity:.8} - \ No newline at end of file + diff --git a/src/06-gbdialog/templates/employees.md b/src/06-gbdialog/templates/employees.md index 0dd43359..c826e0c6 100644 --- a/src/06-gbdialog/templates/employees.md +++ b/src/06-gbdialog/templates/employees.md @@ -237,7 +237,7 @@ These conversations show how the HR Employees template works in real-world scenaβ Employee Added Successfully!
π Employee ID: EMP-2025-0147
-π§ Email: maria.santos@company.com
+π§ Email: santos@company.com
π Extension: 4587
π§ Welcome email sent to Maria
@@ -692,4 +692,4 @@ The employee management system includes several security features: .wa-header-info{flex:1} .wa-header-name{font-weight:600;font-size:16px} .wa-header-status{font-size:12px;opacity:.8} - \ No newline at end of file + diff --git a/src/06-gbdialog/templates/enrollment.md b/src/06-gbdialog/templates/enrollment.md index ceafc8ee..fcc3e930 100644 --- a/src/06-gbdialog/templates/enrollment.md +++ b/src/06-gbdialog/templates/enrollment.md @@ -139,7 +139,7 @@ These conversations show how the enrollment template works in real-world scenari @@ -177,7 +177,7 @@ These conversations show how the enrollment template works in real-world scenariPlease confirm your details:
Name: Maria Santos Silva
Birth Date: 15/03/1990
-Email: maria.santos@email.com
+Email: santos@email.com
Personal ID: 12345678901
Address: Rua das Palmeiras, 456 - SΓ£o Paulo, SP