loading…
Async, decorator-driven, deployable in an hour.
Build a Telegram bot that listens for URLs in your DM, fetches the page, sends a 3-line summary back via Claude. Async, uses decorators for message routing, and ships on Railway's free tier.
This is your first real AI product — one API you built, one AI API you called, one deploy. It's also the pattern behind 90% of AI startups you'll ever work at.
The AI reviewer grades your submission against this exact list.
Copy this into a new file. The ... placeholders are yours to fill.
"""
tl;dr bot — summarizes any URL you send.
Env vars:
TELEGRAM_TOKEN — from @BotFather
ANTHROPIC_API_KEY — from console.anthropic.com
Deploy:
Set env vars on Railway/Fly.io, then `python bot.py`.
"""
from __future__ import annotations
import os
import re
import httpx
from anthropic import Anthropic
from telegram import Update
from telegram.ext import (
Application,
CommandHandler,
ContextTypes,
MessageHandler,
filters,
)
URL_RE = re.compile(r"https?://[^\s]+")
anthropic = Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])
async def start(update: Update, _: ContextTypes.DEFAULT_TYPE) -> None:
await update.message.reply_text(
"Send me a URL and I'll send you a 3-line summary."
)
async def handle_message(update: Update, _: ContextTypes.DEFAULT_TYPE) -> None:
text = update.message.text or ""
match = URL_RE.search(text)
if not match:
await update.message.reply_text(
"Send me a URL and I'll summarize it. Nothing else works yet."
)
return
url = match.group(0)
# TODO: fetch page (respect content-type, timeout, redirects)
# TODO: extract main text (readability is nice, but text-only is fine)
# TODO: call anthropic.messages.create with a 3-line summary prompt
# TODO: reply with formatted summary + source URL
...
def main() -> None:
app = Application.builder().token(os.environ["TELEGRAM_TOKEN"]).build()
app.add_handler(CommandHandler("start", start))
app.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, handle_message))
app.run_polling()
if __name__ == "__main__":
main()
pip.Deploy first, get a Telegram bot handle (@yourbotname), and paste that + your GitHub repo URL below. The AI reviewer will check the code AND try to DM your live bot with a sample URL.