coding

Rust Telegram Bot Framework in 10MB Binary

Femtobot is a Rust-based Telegram bot framework that delivers conversational memory, tool execution, and API integration in a compact 10MB binary, replacing

What It Is

Femtobot is a Telegram bot framework written in Rust that compresses the entire runtime into a 10MB binary. The project emerged from frustration with Python-based chatbot frameworks that claim to be “lightweight” while requiring 350MB or more of dependencies. Instead of accepting this bloat as inevitable, developer Enzo Frasca rebuilt the core concept in Rust, producing a standalone executable that handles conversational memory, tool execution, and Telegram API integration without external dependencies.

The framework uses SQLite for persistent memory storage and integrates with rig-core to provide shell commands, filesystem operations, and web requests as callable tools. Installation requires a single cargo install femtobot command, and launching a bot takes one line with a Telegram token. The binary starts nearly instantaneously compared to Python environments that need to load interpreters, virtual environments, and dozens of packages before handling the first message.

Why It Matters

Resource-constrained deployments have become an afterthought in modern development. Cloud providers make it easy to throw more RAM at problems, and developers often optimize for development speed rather than runtime efficiency. This creates a gap for hobbyists running bots on old Raspberry Pi units, students using free-tier VPS instances with 512MB RAM, or teams managing dozens of small services where disk space accumulates quickly.

Femtobot demonstrates that chatbot frameworks don’t inherently require hundreds of megabytes. The 35x size reduction from 350MB to 10MB means fitting more services on the same hardware, faster deployments over slow connections, and simpler backup strategies. For edge computing scenarios or IoT devices with limited storage, this difference determines whether a project is feasible at all.

The project also highlights Rust’s growing role in infrastructure tooling. While Python dominates AI and chatbot development due to library ecosystems, Rust offers compilation to self-contained binaries with no runtime dependencies. Teams can ship a single file that works across Linux distributions without worrying about Python versions, pip conflicts, or missing system libraries.

Getting Started

Installing femtobot requires Rust’s cargo package manager. Developers who don’t have Rust installed can get it from https://rustup.rs, which provides a one-line installer for most platforms.

After installation completes, obtain a Telegram bot token by messaging @BotFather on Telegram and following the bot creation prompts. Launch femtobot with:

The bot immediately connects to Telegram and responds to messages. It maintains conversation context through SQLite, storing message history locally in a database file. The rig-core integration enables tool usage - bots can execute shell commands, read files, or make HTTP requests when responding to user queries.

For production deployments, the binary can be copied to any Linux server without additional setup. No virtual environments, no dependency installation, no Python version management. The entire deployment process reduces to copying one file and running it with the appropriate token.

Context

Python frameworks like python-telegram-bot, aiogram, and Rasa dominate the Telegram bot ecosystem. These tools offer mature APIs, extensive documentation, and rich plugin ecosystems. Python’s accessibility makes prototyping fast, and libraries like LangChain provide sophisticated agent capabilities that femtobot doesn’t attempt to match.

The tradeoff is runtime overhead. Python interpreters consume memory, virtual environments duplicate packages across projects, and startup times increase with dependency counts. For complex bots requiring advanced NLP, computer vision, or integration with Python-specific ML models, this overhead is justified. Femtobot targets the opposite use case - simple conversational bots where resource efficiency matters more than ecosystem breadth.

The author acknowledges the code “isn’t perfect Rust” and was built quickly with AI assistance. This suggests potential rough edges in error handling, API design, or idiomatic Rust patterns. Production users should review the source at https://github.com/enzofrasca/femtobot before deploying to critical systems.

Alternatives in the efficiency-focused space include Go-based frameworks like telebot, which also compile to standalone binaries. Rust’s memory safety guarantees and zero-cost abstractions make it particularly attractive for long-running services, though Go’s simpler learning curve may appeal to teams without Rust experience.