Skip to content

Configuration Reference

Complete reference for all tg-note configuration options.


Configuration Files

tg-note uses two configuration files:

  1. .env - Sensitive credentials (not committed to git)
  2. config.yaml - Main configuration (can be committed)

Priority: Environment Variables > .env file > config.yaml


Knowledge Base Settings

KB_PATH

Path to knowledge base directory.

  • Type: str
  • Default: ./knowledge_base
  • Example: ./my-notes or /path/to/kb

KB_GIT_ENABLED

Enable Git integration for knowledge base.

  • Type: bool
  • Default: true
  • Description: If enabled, changes are committed to git

KB_GIT_AUTO_PUSH

Automatically push commits to remote repository.

  • Type: bool
  • Default: true
  • Requires: KB_GIT_ENABLED=true

KB_GIT_REMOTE

Git remote name.

  • Type: str
  • Default: origin

KB_GIT_BRANCH

Git branch name.

  • Type: str
  • Default: main

KB_TOPICS_ONLY

Restrict agents to work only in topics/ folder.

  • Type: bool
  • Default: true
  • Description: Prevents agents from modifying meta files like index.md, README.md in KB root
  • When true: Agents can only access KB_PATH/topics/
  • When false: Agents have full access to entire KB directory

Agent Settings

AGENT_TYPE

Type of AI agent to use.

  • Type: str
  • Default: stub
  • Options: stub, autonomous, qwen_code_cli
  • Description:
  • stub - Simple testing agent (no API needed)
  • autonomous - Python-based agent with OpenAI-compatible API
  • qwen_code_cli - Advanced agent using Qwen Code CLI

AGENT_MODEL

Model name for the agent.

  • Type: str
  • Default: qwen-max
  • Examples: gpt-4, gpt-3.5-turbo, qwen-max, claude-3-sonnet

AGENT_TIMEOUT

Maximum time (in seconds) for agent operations.

  • Type: int
  • Default: 300
  • Range: 60 to 600

Enable web search capability for agents.

  • Type: bool
  • Default: true

AGENT_ENABLE_GIT

Enable Git operations for agents.

  • Type: bool
  • Default: true

AGENT_ENABLE_GITHUB

Enable GitHub integration for agents.

  • Type: bool
  • Default: true

AGENT_ENABLE_SHELL

Enable shell command execution for agents.

  • Type: bool
  • Default: false
  • Warning: Security risk if enabled

AGENT_ENABLE_FILE_MANAGEMENT

Enable file create/edit/delete operations.

  • Type: bool
  • Default: true

AGENT_ENABLE_FOLDER_MANAGEMENT

Enable folder create/delete/move operations.

  • Type: bool
  • Default: true

Processing Settings

MESSAGE_GROUP_TIMEOUT

Time (in seconds) to wait for related messages before processing.

  • Type: int
  • Default: 30
  • Description: Bot groups consecutive messages within this timeout

PROCESSED_LOG_PATH

Path to processed messages log file.

  • Type: str
  • Default: ./data/processed.json

Logging Settings

LOG_LEVEL

Logging level.

  • Type: str
  • Default: INFO
  • Options: DEBUG, INFO, WARNING, ERROR, CRITICAL

LOG_FILE

Path to log file.

  • Type: str
  • Default: ./logs/bot.log

Security Settings

ALLOWED_USER_IDS

Comma-separated list of allowed Telegram user IDs.

  • Type: str
  • Default: "" (empty = all users allowed)
  • Example: "123456789,987654321"

Environment Variables (.env)

Required

TELEGRAM_BOT_TOKEN=your_bot_token_here

Optional API Keys

# OpenAI (for autonomous agent)
OPENAI_API_KEY=sk-...
OPENAI_BASE_URL=https://api.openai.com/v1  # Optional, for custom endpoints

# Qwen
QWEN_API_KEY=your_qwen_key

# Anthropic
ANTHROPIC_API_KEY=sk-ant-...

# GitHub
GITHUB_TOKEN=ghp_...

Example Configuration

Minimal Setup (Stub Agent)

# config.yaml
KB_PATH: ./knowledge_base
KB_GIT_ENABLED: true
KB_GIT_AUTO_PUSH: false
AGENT_TYPE: "stub"
LOG_LEVEL: INFO
# .env
TELEGRAM_BOT_TOKEN=your_token

Production Setup (Qwen Code CLI)

# config.yaml
KB_PATH: /data/knowledge_base
KB_GIT_ENABLED: true
KB_GIT_AUTO_PUSH: true
KB_GIT_REMOTE: origin
KB_GIT_BRANCH: main
KB_TOPICS_ONLY: true

AGENT_TYPE: "qwen_code_cli"
AGENT_TIMEOUT: 300
AGENT_ENABLE_WEB_SEARCH: true
AGENT_ENABLE_GIT: true
AGENT_ENABLE_GITHUB: true
AGENT_ENABLE_SHELL: false
AGENT_ENABLE_FILE_MANAGEMENT: true
AGENT_ENABLE_FOLDER_MANAGEMENT: true

MESSAGE_GROUP_TIMEOUT: 30
LOG_LEVEL: INFO
LOG_FILE: /var/log/tg-note/bot.log

ALLOWED_USER_IDS: "123456789"
# .env
TELEGRAM_BOT_TOKEN=your_production_token
GITHUB_TOKEN=ghp_your_github_token

Development Setup (Autonomous Agent)

# config.yaml
KB_PATH: ./test_kb
KB_GIT_ENABLED: true
KB_GIT_AUTO_PUSH: false
KB_TOPICS_ONLY: false

AGENT_TYPE: "autonomous"
AGENT_MODEL: "gpt-3.5-turbo"
AGENT_TIMEOUT: 200
AGENT_ENABLE_WEB_SEARCH: true
AGENT_ENABLE_FILE_MANAGEMENT: true

MESSAGE_GROUP_TIMEOUT: 10
LOG_LEVEL: DEBUG
# .env
TELEGRAM_BOT_TOKEN=your_dev_token
OPENAI_API_KEY=sk-...

See Also