botserver/docs/src/chapter-01
Rodrigo Rodriguez (Pragmatismo) 191ff1a7d8 docs: expand session management and add authentication section
Enhanced Chapter 1 documentation with detailed session architecture, storage layers, and API endpoints. Added new Part XI on authentication and security to SUMMARY.md, introducing chapters on user and bot authentication, password security, and API endpoints. Improves clarity and coverage of system interaction and security concepts.
2025-11-03 20:42:38 -03:00
..
first-conversation.md docs: expand session management and add authentication section 2025-11-03 20:42:38 -03:00
installation.md refactor: remove unused dev-start script and clean up code formatting in mod.rs 2025-10-26 21:47:20 -03:00
README.md docs: expand session management and add authentication section 2025-11-03 20:42:38 -03:00
sessions.md Revise documentation in Chapter 01 to improve clarity and structure, including updates to the installation instructions and session management overview. 2025-10-25 15:59:06 -03:00

Run and Talk

TALK "Welcome! How can I help you today?"
HEAR user_input

Start the server: cargo run --release

Installation

# Clone the repository
git clone https://github.com/GeneralBots/BotServer.git
cd BotServer

# Build the project
cargo build --release

# Run the server
cargo run --release

First Conversation

TALK "Hello! I'm your GeneralBots assistant."
HEAR user_input
IF user_input CONTAINS "weather" THEN
    TALK "Sure, let me check the weather for you."
    CALL GET_WEATHER
ELSE
    TALK "I can help with many tasks, just ask!"
ENDIF

Understanding Sessions

Each conversation is represented by a BotSession that persists across multiple interactions. The session manages:

  • User identity (authenticated or anonymous)
  • Conversation history (full message transcript)
  • Context state (variables, knowledge base references, active tools)
  • Interaction metrics (message counts, timing)

Storage Architecture

Sessions use a multi-layer persistence model:

  1. PostgreSQL - Primary storage for all session data
  2. Redis - Caching layer for active session state
  3. In-memory - Hot session data for performance

Key API Endpoints

  • POST /api/sessions - Create new session
  • GET /api/sessions - List user sessions
  • POST /api/sessions/{id}/start - Activate session
  • GET /api/sessions/{id} - Get conversation history

Advanced Features

  • Context compaction - Reduces memory usage for long conversations
  • Interaction counting - Tracks message frequency
  • Multi-device sync - Shared state across clients