πŸ“šBook Signing at KubeCon EU 2026Meet us at Booking.com HQ (Mon 18:30-21:00) & vCluster booth #521 (Tue 24 Mar, 12:30-1:30pm) β€” free book giveaway!RSVP Booking.com Event
Deployments beginner ⏱ 15 minutes K8s 1.28+

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.

By Luca Berton β€’ β€’ πŸ“– 5 min read

πŸ’‘ Quick Answer: Message @BotFather on Telegram β†’ /newbot β†’ get your token. Deploy OpenClaw with the token as TELEGRAM_BOT_TOKEN env var and channels.telegram.enabled: true in 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-config

Step 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 group

Issue 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-telegram

Best Practices

  1. Single replica only β€” Telegram doesn’t support multiple polling connections
  2. Disable privacy mode β€” Required for group message visibility
  3. Use requireMention in groups β€” Prevents responding to every message
  4. Set bot commands β€” Use /setcommands in BotFather for a clean UX
  5. 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
#openclaw #telegram #bot #ai-agent #chatbot #deployment
Luca Berton
Written by Luca Berton

Principal Solutions Architect specializing in Kubernetes, AI/GPU infrastructure, and cloud-native platforms. Author of Kubernetes Recipes and creator of CopyPasteLearn courses.

Kubernetes Recipes book cover

Want More Kubernetes Recipes?

This recipe is from Kubernetes Recipes, our 750-page practical guide with hundreds of production-ready patterns.

Luca Berton Ansible Pilot Ansible by Example Open Empower K8s Recipes Terraform Pilot CopyPasteLearn ProteinLens