Skip to content
Back to skills

Telegram Bot Creation

ASecurity

Create deploy and manage Telegram bots with python library

  • 2 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 10, 2026
ai-agentspythonbashdockergitapi

Works with

  • api

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned September 10, 2026

npx -y skills add LoopyLuci/Skills --skill telegram-bot-creation --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Telegram Bot Creation?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Telegram Bot Creation
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/loopyluci-telegram-bot-creation/badge)](https://www.skillsdirectory.com/skills/loopyluci-telegram-bot-creation)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: telegram-bot-creation
description: "Create deploy and manage Telegram bots with python library"
---

# Telegram Bot Creation

Full lifecycle for creating and running Telegram bots using `python-telegram-bot` v20+.

## 1. Create the Bot

1. Open Telegram, search for **@BotFather**
2. Send `/newbot`
3. Choose a display name (e.g. `My File Bot`)
4. Choose a username ending in `bot` (e.g. `MyFileTransferBot`)
5. Save the **token** — it looks like `7234567890:AAHdqTcvCH1vGWJxfSeOfS...`

## 2. Bot Token Safety

**NEVER** commit the token to git. Use environment variables:

```python
import os
TOKEN = os.environ["TELEGRAM_BOT_TOKEN"]
```

Or a `.env` file (never committed):
```
TELEGRAM_BOT_TOKEN=7234567890:AAHdqTcv...
```

## 3. Minimal Bot (python-telegram-bot v20+)

```python
import asyncio
from telegram import Update
from telegram.ext import Application, CommandHandler, MessageHandler, filters

TOKEN = "YOUR_TOKEN_HERE"

async def start(update: Update, context):
    await update.message.reply_text("Hello! I am active.")

async def echo(update: Update, context):
    await update.message.reply_text(update.message.text)

def main():
    app = Application.builder().token(TOKEN).build()
    app.add_handler(CommandHandler("start", start))
    app.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, echo))
    app.run_polling(allowed_updates=Update.ALL_TYPES)

if __name__ == "__main__":
    main()
```

## 4. Key Bot Features

| Feature | How | Class |
|---------|-----|-------|
| Commands | `/command` handler | `CommandHandler("cmd", fn)` |
| Text messages | Any text | `MessageHandler(filters.TEXT, fn)` |
| Inline keyboards | Buttons under messages | `InlineKeyboardButton` |
| Reply keyboards | Persistent bottom menu | `ReplyKeyboardMarkup` |
| File download | Get files from messages | `message.document.get_file()` |
| File upload | Send any file | `message.reply_document(file)` |

## 5. File Operations

```python
# Receive a file
async def handle_file(update: Update, context):
    file = await update.message.document.get_file()
    await file.download_to_drive("received_file.pdf")
    await update.message.reply_text("File received!")

# Send a file
await update.message.reply_document(
    document=open("report.pdf", "rb"),
    filename="Monthly_Report.pdf",
    caption="Here is your report"
)
```

## 6. Deployment

```bash
# Install deps
pip install python-telegram-bot

# Run (polling mode — simple, no webhook needed)
python bot.py

# Or use systemd / Docker for production
```

## 7. Common Pitfalls

- **Token exposed** — revoke immediately: BotFather → /mybots → select bot → API Token → Revoke
- **Handler order matters** — add `CommandHandler` before `MessageHandler` or commands get caught as text
- **Conversations** — use `ConversationHandler` for multi-step flows
- **Rate limits** — Telegram enforces ~30 messages/second per chat

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…