DEV Community

Kai Thorne
Kai Thorne

Posted on

How to Build a Telegram Bot in 10 Minutes With Python (No Framework Needed)

Telegram bots are incredibly useful — but most tutorials overcomplicate them. You don't need a framework, a database, or a server. Here's how to build a working Telegram bot in 10 minutes using nothing but Python's standard library.

Step 1: Create Your Bot on Telegram

  1. Open Telegram and search for @botfather
  2. Send /newbot and follow the prompts
  3. Save the API token you receive

That's it. You now have a bot. The hard part is over.

Step 2: The Minimal Bot (10 Lines)

import requests
import time

TOKEN="your_token_here"
URL = f"https://api.telegram.org/bot{TOKEN}"

def get_updates(offset=None):
    params = {"timeout": 30, "offset": offset}
    return requests.get(f"{URL}/getUpdates", params=params).json()

def send_message(chat_id, text):
    requests.post(f"{URL}/sendMessage", json={"chat_id": chat_id, "text": text})

offset = None
while True:
    updates = get_updates(offset)
    for update in updates.get("result", []):
        offset = update["update_id"] + 1
        msg = update.get("message", {})
        chat_id = msg.get("chat", {}).get("id")
        text = msg.get("text", "")
        if text == "/start":
            send_message(chat_id, "Hello! I'm alive. Send me any message.")
        elif text:
            send_message(chat_id, f"You said: {text}")
    time.sleep(1)
Enter fullscreen mode Exit fullscreen mode

Run it. Open Telegram, find your bot, and send /start. It responds. That's all you need for a basic bot.

Step 3: Deploy It for Free

Platform Free Tier Notes
PythonAnywhere Always-free 100s cron, 512MB disk
Render 750h/month Web service with auto-restart
Railway $5 credit 500h/month free
Your own VPS $6/month Full control

I use a $6/month VPS that runs 7 bots simultaneously with zero issues.

What Else Can You Build?

Once you have the basic structure, you can extend it to build echo bots, command bots, quiz bots, reminder bots, poll bots, and more. Each one is a single file — no frameworks, no dependencies.

Want All 10 Bot Templates?

I've packaged 10 ready-to-run Telegram bot templates into a single ZIP file with complete Python source code, setup guide, and deployment instructions:

👉 Telegram Bot Starter Kit — Build a Bot in 10 Minutes

$4.99 — one payment, forever. Each bot is a single file, zero dependencies, MIT License. Instant digital download.

Other tools I use daily:


Questions? Drop a comment. I read every one.

Top comments (0)