Deploy an OpenClaw Telegram Bot on Kubernetes
Run OpenClaw as a Telegram bot on Kubernetes with BotFather setup, webhook configuration, inline commands, and persistent conversation history.
π‘ Quick Answer: Message
@BotFatheron Telegram β/newbotβ get your token. Deploy OpenClaw with the token asTELEGRAM_BOT_TOKENenv var andchannels.telegram.enabled: truein config. The bot responds to DMs immediately and mentions in groups.Key concept: OpenClaw connects to Telegram via the Bot API using long polling (no webhook/ingress needed). The bot works in DMs and groups where itβs added.
Gotcha: Add the bot to a group and grant it βRead All Group Messagesβ permission via BotFather (
/setprivacyβ Disable) for it to see messages beyond direct mentions.
The Problem
- Telegram bots require handling Bot API updates, webhook setup, and message parsing
- Maintaining conversation context per user across sessions is complex
- Group chat bots need careful mention/command handling to avoid noise
The Solution
OpenClaw handles all Telegram Bot API integration, session management, and message routing automatically.
Step 1: Create the Bot via BotFather
1. Open Telegram β search @BotFather
2. Send /newbot
3. Choose a name: "My K8s Assistant"
4. Choose a username: my_k8s_bot
5. Copy the token: 123456789:ABCdefGHIjklMNOpqrsTUVwxyz
6. Send /setprivacy β @my_k8s_bot β Disable (to read group messages)Step 2: Deploy
# openclaw-telegram.yaml
apiVersion: v1
kind: Secret
metadata:
name: openclaw-telegram-secrets
namespace: openclaw
type: Opaque
stringData:
ANTHROPIC_API_KEY: "sk-ant-your-key"
TELEGRAM_BOT_TOKEN: "123456789:ABCdefGHIjklMNOpqrsTUVwxyz"
---
apiVersion: v1
kind: ConfigMap
metadata:
name: openclaw-telegram-config
namespace: openclaw
data:
openclaw.json: |
{
"gateway": { "port": 18789 },
"channels": {
"telegram": {
"enabled": true
}
},
"messages": {
"groupChat": {
"requireMention": true
}
}
}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: openclaw-telegram
namespace: openclaw
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: openclaw-telegram
template:
metadata:
labels:
app: openclaw-telegram
spec:
containers:
- name: openclaw
image: node:22-slim
command: ["sh", "-c", "npm i -g openclaw@latest && openclaw gateway"]
envFrom:
- secretRef:
name: openclaw-telegram-secrets
volumeMounts:
- name: state
mountPath: /home/node/.openclaw
- name: config
mountPath: /home/node/.openclaw/openclaw.json
subPath: openclaw.json
resources:
requests:
cpu: 250m
memory: 512Mi
volumes:
- name: state
persistentVolumeClaim:
claimName: openclaw-telegram-state
- name: config
configMap:
name: openclaw-telegram-configStep 3: Test the Bot
# Check pod is running
kubectl get pods -n openclaw -l app=openclaw-telegram
# View logs to confirm Telegram connection
kubectl logs -n openclaw deploy/openclaw-telegram | grep -i telegram
# Send a DM to your bot on Telegram β it should respond!Common Issues
Issue 1: Bot doesnβt see group messages
# BotFather privacy mode is enabled by default
# Solution: /setprivacy β select your bot β Disable
# Then remove and re-add the bot to the groupIssue 2: Duplicate responses
# Ensure only ONE replica is running
# Two pods = two long-polling connections = duplicate responses
kubectl get pods -n openclaw -l app=openclaw-telegramBest Practices
- Single replica only β Telegram doesnβt support multiple polling connections
- Disable privacy mode β Required for group message visibility
- Use requireMention in groups β Prevents responding to every message
- Set bot commands β Use
/setcommandsin BotFather for a clean UX - Persist state β PVC keeps conversation history across pod restarts
Key Takeaways
- No webhook needed β OpenClaw uses long polling, so no ingress required
- BotFather setup takes 2 minutes, then OpenClaw handles everything
- Single replica is mandatory β Telegram rejects duplicate polling connections
- Group chats require privacy mode disabled and mention-based routing

Recommended
Kubernetes Recipes β The Complete Book100+ production-ready patterns with detailed explanations, best practices, and copy-paste YAML. Everything in one place.
Get the Book βLearn by Doing
CopyPasteLearn β Hands-on Cloud & DevOps CoursesMaster Kubernetes, Ansible, Terraform, and MLOps with interactive, copy-paste-run lessons. Start free.
Browse Courses βπ Deepen Your Skills β Hands-on Courses
Courses by CopyPasteLearn.com β Learn IT by Doing
