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.
2 KiB
SET_USER Keyword
The SET_USER keyword defines the active user context for the current bot session.
It associates all subsequent actions, memory entries, and responses with a specific user identity.
Syntax
SET_USER "user-id"
Parameters
"user-id"— A unique identifier (UUID or username) representing the user.
This value is used to link session data, memory, and logs to the correct user record.
Description
SET_USER updates the bot’s internal session to reflect the specified user identity.
This is typically used after authentication or when switching between users in multi-user environments.
Once set, all commands such as SET_CONTEXT, SET_BOT_MEMORY, and FIND operate within the scope of that user.
If the user ID does not exist in the database, the system automatically creates a new user record.
The command ensures that the session token and memory cache are properly synchronized.
Example
' Set the active user for the session
SET_USER "john_doe"
' Store personalized memory
SET_BOT_MEMORY "preferred_language" "English"
' Retrieve user-specific data
FIND "recent orders"
Implementation Notes
- Implemented in Rust under
src/session/mod.rsandsrc/org/mod.rs. - The keyword interacts with the session manager to update the active user ID.
- It ensures that all subsequent operations are scoped to the correct user context.
- If Redis or database caching is enabled, the user ID is stored for persistence across sessions.
Related Keywords
SET_CONTEXT— Defines the operational context for the session.SET_BOT_MEMORY— Stores persistent data for the bot or user.GET_BOT_MEMORY— Retrieves stored memory entries.
Summary
SET_USER is essential for maintaining user-specific state and personalization in GeneralBots.
It ensures that each session operates independently and securely under the correct user identity.