nanobot/MULTI_BOT_CONFIG_MANAGEMENT.md
tanyar09 4f50cfac3c Add multi-bot Docker setup and improve MCP/tool reliability
Document and add multi-bot Docker workflows with env layering scripts, and update agent/tool configuration handling to make MCP/email/calendar behavior more robust for day-to-day operations.

Made-with: Cursor
2026-03-27 13:06:24 -04:00

5.1 KiB

Managing Multiple Bot Configs Efficiently

Yes, with Docker you'll need to manage multiple config files, but here are strategies to make it easier:

The Challenge

When you have 3 bots, you have 3 config files:

  • ~/.nanobot-user1/config.json
  • ~/.nanobot-user2/config.json
  • ~/.nanobot-user3/config.json

If you need to change something like:

  • API key (shared across all bots)
  • Model settings (might be shared)
  • Tool configurations (might be shared)

You'd normally need to edit all 3 files.

Solution 1: Use Environment Variables for Shared Settings

Nanobot supports environment variables! You can set shared settings via environment variables in Docker.

Update docker-compose.multi.yml

services:
  nanobot-user1:
    # ... existing config ...
    environment:
      # Shared settings - set once, applies to all
      NANOBOT_PROVIDERS__OPENROUTER__API_KEY: "sk-or-v1-xxx"
      NANOBOT_AGENTS__DEFAULTS__MODEL: "anthropic/claude-opus-4-5"
      NANOBOT_AGENTS__DEFAULTS__TEMPERATURE: "0.7"
      # Bot-specific settings still in config.json
    volumes:
      - ~/.nanobot-user1:/root/.nanobot

  nanobot-user2:
    # ... same environment variables ...
    environment:
      NANOBOT_PROVIDERS__OPENROUTER__API_KEY: "sk-or-v1-xxx"
      NANOBOT_AGENTS__DEFAULTS__MODEL: "anthropic/claude-opus-4-5"
      NANOBOT_AGENTS__DEFAULTS__TEMPERATURE: "0.7"
    volumes:
      - ~/.nanobot-user2:/root/.nanobot

Better yet, use a shared .env file:

Create .env.shared:

# Shared settings for all bots
NANOBOT_PROVIDERS__OPENROUTER__API_KEY=sk-or-v1-xxx
NANOBOT_AGENTS__DEFAULTS__MODEL=anthropic/claude-opus-4-5
NANOBOT_AGENTS__DEFAULTS__TEMPERATURE=0.7
NANOBOT_AGENTS__DEFAULTS__MAX_TOKENS=8192

Update docker-compose.multi.yml:

services:
  nanobot-user1:
    env_file:
      - .env.shared  # Load shared settings
    volumes:
      - ~/.nanobot-user1:/root/.nanobot
    # ... rest of config ...

  nanobot-user2:
    env_file:
      - .env.shared  # Same shared settings
    volumes:
      - ~/.nanobot-user2:/root/.nanobot
    # ... rest of config ...

Now you only update .env.shared for shared settings!

Solution 2: Minimal Configs + Environment Variables

Keep only bot-specific settings in config files:

~/.nanobot-user1/config.json (minimal):

{
  "channels": {
    "telegram": {
      "enabled": true,
      "token": "BOT_TOKEN_1",
      "allowFrom": ["USER_ID_1"]
    }
  }
}

~/.nanobot-user2/config.json (minimal):

{
  "channels": {
    "telegram": {
      "enabled": true,
      "token": "BOT_TOKEN_2",
      "allowFrom": ["USER_ID_2"]
    }
  }
}

Everything else comes from .env.shared!

Solution 3: Use the Update Script

I've created update-multi-configs.sh to batch-update configs:

# Update API key in all configs
./update-multi-configs.sh update-api-key openrouter "sk-or-v1-new-key"

# Update model in all configs
./update-multi-configs.sh update-model "anthropic/claude-opus-4-5"

# Update any setting
./update-multi-configs.sh update-setting "agents.defaults.temperature" "0.8"

Requires jq to be installed:

sudo apt install jq  # Linux
brew install jq       # macOS

Solution 4: Base Config Template

Create a template and only override what's different:

~/.nanobot-base/config.json (template):

{
  "providers": {
    "openrouter": {
      "apiKey": "sk-or-v1-xxx"
    }
  },
  "agents": {
    "defaults": {
      "model": "anthropic/claude-opus-4-5",
      "temperature": 0.7
    }
  },
  "channels": {
    "telegram": {
      "enabled": true,
      "token": "REPLACE_WITH_BOT_TOKEN",
      "allowFrom": ["REPLACE_WITH_USER_ID"]
    }
  }
}

Then create bot-specific configs by copying and modifying:

cp ~/.nanobot-base/config.json ~/.nanobot-user1/config.json
# Edit only the telegram token and user ID

cp ~/.nanobot-base/config.json ~/.nanobot-user2/config.json
# Edit only the telegram token and user ID

Use Solution 1 (Environment Variables) - it's the cleanest:

  1. Create .env.shared with all shared settings
  2. Keep minimal configs with only bot-specific settings (Telegram tokens/user IDs)
  3. Update .env.shared when you need to change shared settings
  4. Restart containers to apply changes

This way:

  • Shared settings: Update once in .env.shared
  • Bot-specific settings: Only in each config.json
  • Easy to manage and maintain

Example: Complete Setup

.env.shared:

NANOBOT_PROVIDERS__OPENROUTER__API_KEY=sk-or-v1-xxx
NANOBOT_AGENTS__DEFAULTS__MODEL=anthropic/claude-opus-4-5
NANOBOT_AGENTS__DEFAULTS__TEMPERATURE=0.7
NANOBOT_AGENTS__DEFAULTS__MAX_TOKENS=8192

~/.nanobot-user1/config.json:

{
  "channels": {
    "telegram": {
      "enabled": true,
      "token": "1234567890:ABC...",
      "allowFrom": ["123456789"]
    }
  }
}

docker-compose.multi.yml:

services:
  nanobot-user1:
    env_file:
      - .env.shared
    volumes:
      - ~/.nanobot-user1:/root/.nanobot
    # ... rest ...

Now when you need to change the API key or model, just edit .env.shared and restart!