A Telegram bot powered by Claude gives you a personal AI assistant accessible from your phone. In this tutorial you'll build one from scratch — handling messages, keeping conversation history, and deploying it.
Prerequisites
Python 3.10+
Anthropic API key
Telegram account
Step 1: Create a Telegram Bot
Open Telegram, search for @botfather
Send /newbot and follow the prompts
Copy the bot token (looks like 7123456789:AAF... )
Step 2: Install Dependencies
pip install python-telegram-bot anthropic
Enter fullscreen mode
Exit fullscreen mode
Step 3: Basic Echo Bot
from telegram import Update from telegram.ext import Application , MessageHandler , filters , ContextTypes
BOT_TOKEN = " YOUR_TELEGRAM_BOT_TOKEN "
async def handle_message ( update : Update , context : ContextTypes . DEFAULT_TYPE ): text = update . message . text await update . message . reply_text ( f " You said: { text } " )
app = Application . builder (). token ( BOT_TOKEN ). build () app . add_handler ( MessageHandler ( filters .…