generalbots/docs/src/chapter-02/gbdialog.md
Rodrigo Rodriguez (Pragmatismo) 892d20440e Add comprehensive documentation for GeneralBots, including keyword references, templates, and user guides
- Created detailed markdown files for keywords such as HEAR, TALK, and SET_USER.
- Added examples and usage notes for each keyword to enhance user understanding.
- Developed templates for common tasks like enrollment and authentication.
- Structured documentation into chapters covering various aspects of the GeneralBots platform, including gbapp, gbkb, and gbtheme.
- Introduced a glossary for key terms and concepts related to GeneralBots.
- Implemented a user-friendly table of contents for easy navigation.
2025-10-25 14:50:14 -03:00

1.6 KiB

.gbdialog Dialogs

The .gbdialog package contains BASIC scripts that define conversation flows, tool integrations, and bot behavior.

What is .gbdialog?

.gbdialog files are written in a specialized BASIC dialect that controls:

  • Conversation flow and logic
  • Tool calls and integrations
  • User input processing
  • Context management
  • Response generation

Basic Structure

A typical .gbdialog script contains:

REM This is a comment
TALK "Hello! How can I help you today?"

HEAR user_input

IF user_input = "help" THEN
    TALK "I can help you with various tasks..."
ELSE
    LLM user_input
END IF

Key Components

1. Control Flow

  • IF/THEN/ELSE/END IF for conditional logic
  • FOR EACH/IN/NEXT for loops
  • EXIT FOR to break loops

2. User Interaction

  • HEAR variable to get user input
  • TALK message to send responses
  • WAIT seconds to pause execution

3. Data Manipulation

  • SET variable = value for assignment
  • GET url to fetch external data
  • FIND table, filter to query databases

4. AI Integration

  • LLM prompt for AI-generated responses
  • ADD_TOOL tool_name to enable functionality
  • SET_KB collection to use knowledge bases

Script Execution

Dialog scripts run in a sandboxed environment with:

  • Access to session context and variables
  • Ability to call external tools and APIs
  • Integration with knowledge bases
  • LLM generation capabilities

Error Handling

The system provides built-in error handling:

  • Syntax errors are caught during compilation
  • Runtime errors log details but don't crash the bot
  • Timeouts prevent infinite loops
  • Resource limits prevent abuse