Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Database Tables

This section documents all database tables in General Bots, their structures, and purposes.

Core Tables

organizations

Stores organization/tenant information for multi-tenant deployments.

ColumnTypeDescription
org_idUUIDPrimary key
nameTEXTOrganization name
slugTEXTURL-friendly identifier
created_atTIMESTAMPTZCreation timestamp

bots

Bot instances and their basic configuration.

ColumnTypeDescription
idUUIDPrimary key
nameTEXTBot name
org_idUUIDForeign key to organizations
created_atTIMESTAMPTZCreation timestamp
updated_atTIMESTAMPTZLast update timestamp

bot_configuration

Stores bot-specific configuration parameters from config.csv.

ColumnTypeDescription
idUUIDPrimary key
bot_idUUIDForeign key to bots
keyTEXTConfiguration key
valueTEXTConfiguration value
created_atTIMESTAMPTZCreation timestamp
updated_atTIMESTAMPTZLast update timestamp

bot_memories

Persistent key-value storage for bots (used by GET BOT MEMORY/SET BOT MEMORY).

ColumnTypeDescription
idUUIDPrimary key
bot_idUUIDForeign key to bots
keyTEXTMemory key
valueTEXTMemory value
created_atTIMESTAMPTZCreation timestamp
updated_atTIMESTAMPTZLast update timestamp

User Management Tables

users

User accounts with authentication credentials.

ColumnTypeDescription
idUUIDPrimary key
usernameTEXTUnique username
emailTEXTEmail address
password_hashTEXTArgon2 hashed password
activeBOOLEANAccount status
created_atTIMESTAMPTZRegistration timestamp
updated_atTIMESTAMPTZLast update timestamp

user_sessions

Active user sessions for authentication and state management.

ColumnTypeDescription
idUUIDPrimary key
user_idUUIDForeign key to users
bot_idUUIDForeign key to bots
session_tokenTEXTUnique session identifier
expires_atTIMESTAMPTZSession expiration
created_atTIMESTAMPTZSession start
updated_atTIMESTAMPTZLast activity

user_login_tokens

Authentication tokens for login flows.

ColumnTypeDescription
idUUIDPrimary key
user_idUUIDForeign key to users
tokenTEXTLogin token
expires_atTIMESTAMPTZToken expiration
usedBOOLEANWhether token was used
created_atTIMESTAMPTZToken creation

user_preferences

User-specific settings and preferences.

ColumnTypeDescription
idUUIDPrimary key
user_idUUIDForeign key to users
preferencesJSONBPreferences data
created_atTIMESTAMPTZCreation timestamp
updated_atTIMESTAMPTZLast update

Conversation Tables

message_history

Complete conversation history between users and bots.

ColumnTypeDescription
idUUIDPrimary key
session_idUUIDForeign key to user_sessions
user_idUUIDForeign key to users
bot_idUUIDForeign key to bots
messageTEXTMessage content
senderTEXT‘user’ or ‘bot’
created_atTIMESTAMPTZMessage timestamp

clicks

Tracks user interactions with UI elements.

ColumnTypeDescription
idUUIDPrimary key
session_idUUIDForeign key to user_sessions
element_idTEXTUI element identifier
timestampTIMESTAMPTZClick timestamp

system_automations

Scheduled tasks and automation rules.

ColumnTypeDescription
idUUIDPrimary key
bot_idUUIDForeign key to bots
nameTEXTAutomation name
scheduleTEXTCron expression
scriptTEXTBASIC script to execute
activeBOOLEANWhether automation is active
created_atTIMESTAMPTZCreation timestamp
updated_atTIMESTAMPTZLast update

Knowledge Base Tables

kb_collections

Knowledge base collection definitions.

ColumnTypeDescription
idTEXTPrimary key (collection name)
bot_idUUIDForeign key to bots
nameTEXTCollection display name
descriptionTEXTCollection description
metadataJSONBAdditional metadata
created_atTIMESTAMPTZCreation timestamp
updated_atTIMESTAMPTZLast update

kb_documents

Documents stored in knowledge base collections.

ColumnTypeDescription
idTEXTPrimary key (document ID)
collection_idTEXTForeign key to kb_collections
bot_idUUIDForeign key to bots
nameTEXTDocument name
contentTEXTDocument content
metadataJSONBDocument metadata
embedding_idTEXTVector embedding reference
indexedBOOLEANWhether document is indexed
created_atTIMESTAMPTZUpload timestamp
updated_atTIMESTAMPTZLast update

user_kb_associations

Links user sessions to available knowledge bases.

ColumnTypeDescription
idTEXTPrimary key
session_idUUIDForeign key to user_sessions
collection_idTEXTForeign key to kb_collections
created_atTIMESTAMPTZAssociation timestamp

Tool Tables

basic_tools

BASIC script tool definitions.

ColumnTypeDescription
idTEXTPrimary key (tool name)
bot_idUUIDForeign key to bots
nameTEXTTool display name
descriptionTEXTTool description
parametersJSONBParameter definitions
scriptTEXTBASIC script implementation
metadataJSONBAdditional metadata
created_atTIMESTAMPTZCreation timestamp
updated_atTIMESTAMPTZLast update

session_tool_associations

Links sessions to available tools.

ColumnTypeDescription
idTEXTPrimary key
session_idUUIDForeign key to user_sessions
tool_idTEXTForeign key to basic_tools
created_atTIMESTAMPTZAssociation timestamp

Email Integration Tables

user_email_accounts

Email accounts configured for users.

ColumnTypeDescription
idUUIDPrimary key
user_idUUIDForeign key to users
email_addressTEXTEmail address
imap_serverTEXTIMAP server address
imap_portINTEGERIMAP port
smtp_serverTEXTSMTP server address
smtp_portINTEGERSMTP port
encrypted_passwordTEXTEncrypted email password
activeBOOLEANAccount status
created_atTIMESTAMPTZConfiguration timestamp
updated_atTIMESTAMPTZLast update

email_drafts

Draft emails created by users or bots.

ColumnTypeDescription
idUUIDPrimary key
user_idUUIDForeign key to users
account_idUUIDForeign key to user_email_accounts
to_addressesTEXT[]Recipient addresses
cc_addressesTEXT[]CC addresses
bcc_addressesTEXT[]BCC addresses
subjectTEXTEmail subject
bodyTEXTEmail body
attachmentsJSONBAttachment metadata
created_atTIMESTAMPTZDraft creation
updated_atTIMESTAMPTZLast edit

email_folders

Email folder organization.

ColumnTypeDescription
idUUIDPrimary key
account_idUUIDForeign key to user_email_accounts
nameTEXTFolder name
pathTEXTIMAP folder path
parent_idUUIDParent folder ID
message_countINTEGERNumber of messages
unread_countINTEGERUnread messages
created_atTIMESTAMPTZFolder creation
updated_atTIMESTAMPTZLast sync

Indexes

Primary Indexes

  • All id columns have primary key indexes
  • All foreign key columns have indexes for joins

Performance Indexes

  • user_sessions.session_token - for session lookup
  • message_history.created_at - for time-based queries
  • kb_documents.collection_id - for collection queries
  • bot_memories(bot_id, key) - composite for memory lookup

Full-Text Search Indexes

  • kb_documents.content - for document search (when enabled)
  • message_history.message - for conversation search (when enabled)