I self-host an AI companion bot on Telegram (t.me/adola2048_bot) using a pattern that might interest this community.
The architecture:
- Gateway receives Telegram webhooks and routes to user containers
- Per-user containers each run an AI agent stack (OpenClaw) with isolated memory
- Workspace persistence via Docker bind mounts at /data/users/{userId}/workspace/
- Container lifecycle managed by the gateway: created on first message, stopped after 30min idle, restarted in ~3s
- Heartbeat gateway-driven proactive check-ins (15min interval)
- Scheduling via SCHEDULES.json polled every 30s by gateway
All running on a single e2-medium GCP instance ($35/month). Currently serving 7 users.
The key insight: stopped Docker containers use zero resources. Only the gateway, postgres, and caddy run constantly. User containers spin up on demand and spin down when idle.
Stack: Node.js gateway, PostgreSQL for routing, Caddy for TLS, per-user OpenClaw containers, Gemini 2.5 Flash.
Anyone else self-hosting AI agents with per-user isolation? Curious about alternative approaches.
You must log in or register to comment.

