How to Build a Telegram Bot with Claude AI: The Complete Guide

Telegram has over 900 million users. Claude is the most capable AI assistant available. Put them together and you get something powerful: an AI-powered bot that lives where your users already are.
At Holylabs, we've built and deployed multiple production Telegram bots powered by AI — from eSIM sales bots to VPN distribution to content automation. Here's everything we've learned about building intelligent Telegram bots with Claude.
Why Telegram + Claude?
Most chatbot frameworks give you decision trees and keyword matching. Claude gives you actual intelligence. The difference matters:
| Traditional Bot | Claude-Powered Bot |
|---|---|
| Fixed menu options | Natural language understanding |
| Keyword matching | Context-aware responses |
| Breaks on unexpected input | Handles any question gracefully |
| Manual content updates | Generates content on the fly |
| Single language | Multilingual out of the box |
Architecture Overview
The stack is straightforward:
- Telegram Bot API — receives messages from users via webhooks
- Node.js backend — processes messages, manages state, handles business logic
- Claude API (Anthropic) — generates intelligent responses, processes requests
- Database (Supabase/PostgreSQL) — stores users, orders, conversation history
- Telegram Mini Apps — rich web UIs launched directly inside Telegram
The key insight: Claude doesn't replace your bot logic — it enhances it. Your bot still handles payments, order creation, and navigation. Claude handles understanding what the user wants and generating the right response.
Claude's Tool Use: The Game Changer
The feature that makes this architecture work is Claude's tool use capability. Instead of just generating text, Claude can call functions in your backend:
// Define tools Claude can use
const tools = [
{
name: "search_esim_plans",
description: "Search available eSIM plans by country",
input_schema: {
type: "object",
properties: {
country: { type: "string", description: "Country name or code" }
}
}
},
{
name: "create_order",
description: "Create a new eSIM order for the user",
input_schema: {
type: "object",
properties: {
plan_id: { type: "string" },
email: { type: "string" }
}
}
}
];
When a user sends "I need internet in Japan for 2 weeks", Claude understands the intent, calls search_esim_plans with the right parameters, and presents the results naturally — no rigid menu navigation required.
Real Production Examples
eSIM Sales Bot
Our Telegram bot sells eSIM data plans to travelers. The flow:
- User sends a country name or taps a button
- Bot shows available plans with pricing
- User selects a plan
- Bot launches a Telegram Mini App for checkout
- Payment processed, eSIM delivered via email + Telegram
Claude handles the conversational layer — understanding "I'm going to Thailand next week and need data" and routing it to the right plans. The Mini App handles the visual checkout experience.
Content Channel Automation
We run Telegram channels that auto-publish AI-generated content daily. Claude writes original articles based on trending topics, and the bot posts them with proper formatting, images, and hashtags. No human review needed — Claude's output quality is consistent enough for automated publishing.
VPN Distribution Bot
Our VPN bot handles promo code distribution, user onboarding, and support — all through natural conversation. Users don't need to memorize commands or navigate menus. They just describe what they need.
Telegram Mini Apps: The Secret Weapon
Telegram Mini Apps are web applications that run inside Telegram. They give you the full power of a web app (forms, payments, complex UIs) without making users leave the chat.
The best pattern we've found:
- Bot handles conversation — greeting, questions, support, navigation
- Mini App handles transactions — checkout, forms, dashboards, settings
This hybrid approach gives users the convenience of chat for simple interactions and a proper UI for complex ones.
Key Lessons from Production
After running Claude-powered Telegram bots in production for months, here's what we've learned:
1. Keep Claude focused. Don't ask Claude to handle everything. Use it for natural language understanding and content generation. Keep payment processing, order creation, and state management in your own code.
2. Cache aggressively. Claude API calls cost money and take time. Cache responses for common questions. Use a knowledge base for FAQs instead of hitting the API every time.
3. Set clear system prompts. Tell Claude exactly what your bot does, what it should and shouldn't say, and what tone to use. A well-crafted system prompt is the difference between a helpful assistant and a confused one.
4. Handle failures gracefully. API calls fail. When Claude is unavailable, fall back to simple button-based navigation. Users should never see an error — just a slightly less intelligent interaction.
5. Multilingual by default. Claude speaks every language fluently. Detect the user's language from their Telegram settings and respond accordingly. We serve users in Russian, English, Hebrew, and more — all from the same bot, zero translation files.
Cost Optimization
Running Claude in production isn't free. Here's how we keep costs manageable:
| Strategy | Impact |
|---|---|
| Use Claude Haiku for simple routing | 10x cheaper than Opus |
| Cache common Q&A pairs | Eliminates 60-70% of API calls |
| Limit conversation history to 10 messages | Reduces token count per request |
| Use buttons for structured choices | No AI call needed for menu navigation |
| Batch content generation | Generate multiple posts in one API call |
Getting Started
The barrier to entry is lower than you think:
- Create a bot via @BotFather on Telegram
- Set up a Node.js server with the
node-telegram-bot-apipackage - Get an API key from Anthropic's Console
- Connect them — route incoming messages through Claude, send responses back
- Deploy on any VPS ($5-10/month is enough to start)
You can have a working prototype in an afternoon. Production-ready in a week.
What's Next
We're seeing Telegram bots evolve from simple command handlers into full business applications. With Claude's tool use, Mini Apps for rich UIs, and Telegram's massive user base, this stack is becoming a serious alternative to traditional mobile apps — especially for markets where Telegram is the dominant platform.
At Holylabs, we build white-label Telegram bots and Mini Apps for businesses. If you need an AI-powered bot for your product, get in touch.