Copy the example environment file and fill in your credentials:
cp .env.example .env
Required variables:
.env
# Telegram bot token (required)BOT_TOKEN=your_bot_token_here# Telegram API credentials (required for telegram-bot-api service)TELEGRAM_API_ID=your_api_idTELEGRAM_API_HASH=your_api_hash# Telegram server endpoint (keep default for local Bot API)TG_SERVER=http://telegram-bot-api:8081# Database configuration (optional, uses compose defaults if not set)POSTGRES_USER=postgresPOSTGRES_PASSWORD=postgresPOSTGRES_DB=ttbot-dbDB_URL=postgresql+asyncpg://postgres:postgres@db/ttbot-db
The TG_SERVER must be set to http://telegram-bot-api:8081 to use the local Bot API server. This is the service name defined in the compose file.
Faster uploads - Direct connection without going through Telegram servers
No rate limits - Process more requests without hitting API limits
Better file handling - Improved support for large files
By default, the local Bot API listens on port 8081 inside the Docker network and isn’t exposed to your host. If you need to access it from your host for debugging, add a port mapping:
telegram-bot-api: # ... other config ports: - "8081:8081"
# Start all services (foreground)docker compose up# Start all services (background)docker compose up -d
If you start only the tt-bot service without telegram-bot-api, ensure TG_SERVER points to a reachable endpoint (either also start telegram-bot-api or set TG_SERVER=https://api.telegram.org).
# Tail logs from all servicesdocker compose logs -f# Logs from specific servicedocker compose logs -f tt-bot# Last 100 lines from all servicesdocker compose logs --tail=100
# Rebuild images after code changesdocker compose build# Rebuild and restartdocker compose up --build -d# Pull latest images and restartdocker compose pulldocker compose up -d