DEV Community

xujfcn
xujfcn

Posted on

Deploy Your AI Telegram Bot in One Command (OpenClaw + CrazyRouter)

Deploy Your AI Telegram Bot in One Command (OpenClaw + CrazyRouter)

Setting up an AI-powered Telegram bot usually means juggling API keys from multiple providers, writing config files by hand, and debugging Docker setups. I built a one-click deploy script that handles everything — from installing Docker to generating configs to pairing your Telegram account.

5 minutes, one command, done.

What You Get

A Telegram bot running on your server powered by Claude Opus 4.6 (via CrazyRouter), supporting:

  • Private conversations with full context
  • Image recognition
  • File processing
  • Group chat with @mention replies

Terminal Deploy Process

Deploy Terminal

Telegram Bot First Conversation

Telegram Pairing

Prerequisites

1. CrazyRouter API Key

CrazyRouter is an AI API gateway — one key gives you access to 600+ models (GPT, Claude, Gemini, DeepSeek, Grok, etc.) without registering with each provider separately.

Sign up and grab your API key from the dashboard.

2. Telegram Bot Token

Message @botfather on Telegram, send /newbot, follow the prompts, get your token.

3. A Linux Server

  • Ubuntu/Debian recommended
  • Minimum: 1 vCPU, 1GB RAM
  • Needs outbound internet access

Deploy

git clone https://github.com/xujfcn/openclaw-deploy.git
cd openclaw-deploy
chmod +x deploy.sh
sudo ./deploy.sh
Enter fullscreen mode Exit fullscreen mode

The script will interactively ask for:

  1. Your CrazyRouter API Key
  2. Your Telegram Bot Token
  3. Runtime choice: Docker (recommended) or native Node.js

It then automatically:

  • Installs Docker if needed
  • Builds the openclaw-bot:latest image
  • Generates openclaw.json config
  • Starts the container
  • Optionally pairs your Telegram account

Pairing Your Telegram Account

OpenClaw uses a pairing system — the bot won't respond to anyone until you approve them.

  1. Send /start to your bot on Telegram
  2. Bot replies with a pairing code like QE8E59CF
  3. On your server:
docker exec openclaw-bot openclaw pairing approve telegram QE8E59CF
Enter fullscreen mode Exit fullscreen mode

Done. The bot starts responding.

Switching Models

CrazyRouter supports 600+ models. To switch, just change model.id in openclaw.json:

Model model.id
Claude Opus 4.6 claude-opus-4-6
GPT-5.2 gpt-5.2
GPT-4o gpt-4o
Gemini 3 Flash gemini-3-flash-preview
DeepSeek V3.2 deepseek-ai/DeepSeek-V3.2
Grok 4.1 grok-4.1

Then restart: docker restart openclaw-bot

Environment Variables for CI/CD

Skip interactive prompts with env vars:

export CRAZYROUTER_API_KEY="sk-xxxx"
export TELEGRAM_BOT_TOKEN="123456:ABC..."
export USE_DOCKER=1
sudo -E ./deploy.sh
Enter fullscreen mode Exit fullscreen mode

Troubleshooting

Bot not responding? Check if you've paired: docker logs openclaw-bot

401 error? Wrong CrazyRouter API key. Check your dashboard.

Docker build slow? The npm install -g openclaw@latest step takes a minute. Image is cached after first build.

Links


Star the repo if this helped!

Top comments (0)