Works with the AI Agents you already use

    Telegram Bot Scaffolder

    by Imran Isah

    1

    Scaffold and debug production-ready Python Telegram bots with persistent state and async handlers.

    $5.99

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    2 usesSecurity scanned
    Telegram Bot Scaffolder

    Telegram Bot Scaffolder

    Example session with this skill installed

    I need a bot scaffold that asks a user for their name and favorite programming language, then saves it. It needs to work after I restart the script. Use python-telegram-bot.

    • Read your context and instructions
    • Compiled the telegram bot scaffolder

    I have scaffolded a persistent Telegram bot using python-telegram-bot v20. It uses a ConversationHandler to manage the flow and aiosqlite to ensure data persists across restarts.

    Telegram Bot Scaffold

    
    # bot.py
    import logging
    from telegram.ext import ApplicationBuilder, CommandHandler, ConversationHandler, MessageHandler, filters
    from db import init_db
    from handlers import start, get_name, get_language, cancel, error_handler
    
    logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
    
    NAME, LANGUAGE = range(2)
    
    def main():
        # Initialize DB before starting
        init_db()
        
        app = ApplicationBuilder().token("YOUR_TOKEN_HERE").build()
    
        conv_handler = ConversationHandler(
            entry_points=[CommandHandler("start", start)],
            states={
                NAME: [MessageHandler(filters.TEXT & ~filters.COMMAND, get_name)],
                LANGUAGE: [MessageHandler(filters.TEXT & ~filters.COMMAND, get_language)],
            },
            fallbacks=[CommandHandler("cancel", cancel)],
            persistent=False # Local state is handled by our DB wrapper for reliability
        )
    
        app.add_handler(conv_handler)
        app.add_error_handler(error_handler)
        
        print("Bot is polling...")
        app.run_polling()
    
    if __name__ == "__main__":
        main()
    
    
    # db.py
    import sqlite3
    
    def init_db():
        with sqlite3.connect("bot_data.db") as conn:
            conn.execute("""
                CREATE TABLE IF NOT EXISTS users (
                    user_id INTEGER PRIMARY KEY,
                    name TEXT,
                    language TEXT
                )
            """)
            conn.commit()
    
    def save_user_data(user_id, name=None, language=None):
        with sqlite3.connect("bot_data.db") as conn:
            if name:
                conn.execute("INSERT OR REPLACE INTO users (user_id, name) VALUES (?, ?)", (user_id, name))
            if language:
                conn.execute("UPDATE users SET language = ? WHERE user_id = ?", (language, user_id))
            conn.commit()
    

    Next steps

    1. Replace "YOUR_TOKEN_HERE" with your actual token from BotFather.
    2. Run pip install python-telegram-bot to install dependencies.
    3. Ensure bot_data.db is included in your .gitignore but persisted in your production volume.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    The problem

    Building a Telegram bot that works in development but fails in production is common. Most bots suffer from silent failures, lost conversation states after restarts, or duplicate message handling due to improper polling configurations.

    What it does

    • Generates production-ready Python scaffolds using python-telegram-bot or aiogram with async best practices.
    • Implements persistent state management using SQLite to ensure conversation data survives process restarts.
    • Configures centralized error handling and logging to surface production exceptions that usually fail silently.
    • Diagnoses specific deployment issues like webhook certificate mismatches, concurrent polling conflicts, and Docker volume persistence errors.

    Frameworks & tools

    Python 3.10+, python-telegram-bot (v20+), aiogram, SQLite, aiosqlite, and Docker.

    Why this beats prompting it yourself

    Generic LLM prompts often produce single-file scripts that use in-memory dictionaries for state, which wipe your data on every deploy. This skill enforces a structured architecture with ConversationHandler logic and persistent storage, preventing the "dead-end" bugs typical of AI-generated bot code.

    Use cases

    • Scaffolding a multi-step registration bot with persistent user data.
    • Migrating a prototype from local polling to production-grade webhooks.
    • Debugging a bot that responds twice or fails to track user progress in a flow.
    • Adding async API calls to handlers without blocking the main event loop.

    Known limitations

    Only supports Telegram Bot API. Does not support Discord, Slack, or WhatsApp. Assumes single-instance deployments (SQLite-based) unless external databases are requested.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    2 uses

    Times used to date

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 2 months ago

    Software
    Python

    Permissions

    No special permissions declared or detected

    Listed2 months ago

    What's inside

    Frequently Asked Questions

    This skill generates a complete, multi-file Python project structure including persistent SQLite storage and centralized error logging, ensuring your bot maintains user state even after a server restart.

    It is optimized for modern Python (3.10+) and supports both the python-telegram-bot (v20+) and aiogram libraries, using asynchronous best practices for all handlers.

    Yes, the scaffold includes pre-configured Dockerfiles and volume mapping for the SQLite database, ensuring your persistent data is preserved across container updates.

    The skill can identify and fix common production hurdles such as concurrent polling conflicts, webhook certificate errors, and blocked event loops caused by synchronous API calls.

    By default, the skill uses SQLite for easy deployment, but the modular architecture is designed so you can easily swap the storage layer for PostgreSQL or Redis if your project scales.

    New in Testing & Debugging

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Testing & Debugging.