generalbots/docs/src/chapter-05/real-basic-examples.md

3.1 KiB
Raw Blame History

Real BASIC Keyword Examples in GeneralBots

This section provides authentic examples of BASIC commands implemented in the GeneralBots system.
All examples are derived directly from the source code under src/basic/keywords/.


Website Knowledge Base

ADD_WEBSITE

Registers and indexes a website into the bots knowledge base.

ADD_WEBSITE "https://example.com"

Description:
Crawls the specified website, extracts text content, and stores it in a Qdrant vector database for semantic search.
If the web_automation feature is disabled, the command validates the URL format only.


Knowledge Base Management

SET_KB

Sets the active knowledge base for the current user session.

SET_KB "marketing_data"

Description:
Links the bots context to a specific KB collection, enabling focused queries and responses.

USE_KB

Adds a new knowledge base collection.

USE_KB "customer_feedback"

Description:
Creates a new KB collection in Qdrant and prepares it for document indexing.


Communication

HEAR_TALK

Handles conversational input and output between the bot and user.

HEAR_TALK "Hello, bot!"

Description:
Triggers the bots response pipeline, processing user input and generating replies using the active LLM model.

PRINT

Outputs text or variable content to the console or chat.

PRINT "Task completed successfully."

Description:
Displays messages or results during script execution.


Context and Tools

SET_CONTEXT

Defines the current operational context for the bot.

SET_CONTEXT "sales_mode"

Description:
Switches the bots internal logic to a specific context, affecting how commands are interpreted.

USE_TOOL

Registers a new tool for automation.

USE_TOOL "email_sender"

Description:
Adds a tool to the bots environment, enabling extended functionality such as sending emails or processing files.

REMOVE_TOOL

Removes a previously registered tool.

REMOVE_TOOL "email_sender"

Description:
Unregisters a tool from the bots active environment.


Scheduling and User Management

SET_SCHEDULE

Defines a scheduled task for automation.

SET_SCHEDULE "daily_report"

Description:
Creates a recurring automation trigger based on time or event conditions.

SET_USER

Sets the active user context.

SET_USER "john_doe"

Description:
Associates the current session with a specific user identity.


Utility Commands

WAIT

Pauses execution for a specified duration.

WAIT 5

Description:
Delays script execution for 5 seconds.

FIND

Searches for data or keywords within the current context.

FIND "project_status"

Description:
Queries the bots memory or KB for matching entries.


Summary

All examples above are real commands implemented in the GeneralBots source code.
They demonstrate how BASIC syntax integrates with Rust-based logic to perform automation, data management, and conversational tasks.