Install
openclaw skills install tg-cs-agentDeploy and manage a Telegram customer service bot powered by Claude + RAG. Use when setting up a new CS bot, adding knowledge base docs, managing the bot lifecycle (start/stop/restart), or troubleshooting bot issues. Triggers on "customer service bot", "CS bot", "客服机器人", "telegram bot", "knowledge base".
openclaw skills install tg-cs-agentRAG-powered Telegram customer service bot using Claude + Telethon + ChromaDB.
tgctl-telethon login or manual auth)mkdir -p ~/tg-cs-bot && cd ~/tg-cs-bot
cp -r <skill_dir>/scripts/*.py .
pip install anthropic chromadb sentence-transformers python-dotenv telethon
Create .env:
ANTHROPIC_API_KEY=<key>
ANTHROPIC_BASE_URL=https://api.anthropic.com
TELEGRAM_API_ID=<id>
TELEGRAM_API_HASH=<hash>
TELEGRAM_PROFILE=default
MODEL=claude-sonnet-4-20250514
KNOWLEDGE_DIR=docs
MAX_HISTORY=20
HANDOFF_CHAT_ID=<admin_telegram_id_or_username>
Put markdown files in docs/ directory. The bot splits by ## headers and vectorizes with paraphrase-multilingual-MiniLM-L12-v2 for multilingual support.
python3 -c "
from telethon import TelegramClient
import asyncio
async def login():
c = TelegramClient('~/.tgctl-telethon/default/session', API_ID, 'API_HASH')
await c.start()
print('Logged in:', (await c.get_me()).first_name)
asyncio.run(login())
"
python3 main.py
python3 main.py (or use the start.sh script).md files in docs/, restart bot/clear/humanEdit config.py → __post_init__ → self.system_prompt to change:
In knowledge.py, change model_name for different language support:
paraphrase-multilingual-MiniLM-L12-v2 — multilingual (recommended)all-MiniLM-L6-v2 — English only, fastershibing624/text2vec-base-chinese — Chinese optimizedThe bot adds [HANDOFF] to responses when it can't help. This triggers:
HANDOFF_CHAT_ID with user infotg-cs-bot/
├── main.py # Entry point, message routing
├── config.py # Config + system prompt
├── agent.py # Claude RAG agent
├── knowledge.py # ChromaDB knowledge base
├── telegram_client.py # Telethon wrapper
├── .env # Secrets (not committed)
├── docs/ # Knowledge base markdown files
│ ├── platform.md
│ ├── faq.md
│ └── ...
└── requirements.txt
session.session-journal, rebuild session with sqlite dump/restore[READY] Listening for messages... in logs, verify Telegram connection