teloxide is a Rust framework for Telegram bots via the bots API. It covers dispatching, commands, dialogues, webhooks, and long polling.
Overview
teloxide is a framework for building Telegram bots in Rust against the Telegram Bot API. It handles infrastructure around updates and requests so application code can focus on bot logic. The bots API is supported; client APIs for end-user Telegram clients are out of scope.
Message handling builds on dptree, a functional chain-of-responsibility style pipeline for declarative update routing. Handlers can filter update and message kinds, with filter helpers that inject typed parameters into async handler functions. A Dispatcher coordinates the bot and schema execution.
Bot commands can be defined as enums and parsed automatically. A dialogues subsystem models multi-step conversations as state machines with pluggable storage; Redis and SQLite backends are mentioned, with serializers such as CBOR or Bincode. Both long polling and webhook listeners are supported, with optional axum-based webhook integration and TLS via native-tls or rustls.
Optional cargo features add throttling, caching, tracing adaptors, graceful Ctrl+C shutdown, and storage backends. Examples cover dice replies, commands, dialogues, purchases with callbacks, and WebApp patterns contributed by the community.
Key features
- dptree update dispatch pipelines
- Long polling and webhooks
- Typed bot command enums
- Multi-step dialogue FSM
- Redis and SQLite dialogue storage
- Update and message filter helpers
- Optional axum webhook integration
- Bots API request and type coverage
Use cases
- Custom Telegram chat bots
- Command-driven bot interactions
- Stateful user dialogues
- Webhook-deployed bot services
- Dice and mini-game style replies