Teloxide's dialogue state is a Rust enum you can persist yourself
🤖 An elegant Telegram bots framework for Rust
At a glance
- What is it?
- Teloxide is a Rust framework for Telegram bots whose architecture is one pattern: message handling is a chain of responsibility, and that pattern lives in its own repository as a separate crate. Everything else follows from it, including dialogues that are Rust enums, commands that are enums parsed by a derive macro, and dialogue storage you replace with one line. The setup instructions pin a toolchain version and a dependency version in two different places.
- Who is it for?
- Teloxide fits a Rust developer who wants the type system to carry part of the bot's logic, since dialogue states and commands are both enumerations and the derive macros generate the parsing and the help text from the same declaration. It does not fit someone who wants dialogue state hidden behind dynamic values, because the state machine is the point and it is expressed in types.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 71 days ago.
- What is it written in?
- Mainly Rust, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 25, 2026, and from our analysis. They are not legal advice.
Star history
- teloxide/teloxide4,278 ★ · +36
| Repository | 2026-09-23 | 2026-11-25 |
|---|---|---|
| teloxide/teloxide | 4.2k | 4.3k |
36 Stars in the last 63 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
The architecture is a pattern, and the pattern is another crate
The first thing in the highlights list is the design, and it is stated as a dependency rather than a principle.
The framework is built on a separate library called dptree, which implements a functional chain-of-responsibility pattern. That pattern is what lets you express pipelines of message processing in a declarative and extensible style, and the page frames it as the reason the framework is declarative rather than as an implementation detail.
Having it in its own repository matters for two reasons. The pipeline semantics can be used, argued about and versioned without the bot API changing, and a contributor who wants to change how messages are routed is not touching the Telegram code at all.
The root of the repository agrees with that framing: there is a guide for getting started with the pipeline library, written for use with this framework specifically.
Everything else on the page is an application of the same idea, so a reader who does not understand the pattern will find the rest of the API harder to follow than the feature list suggests.
Dialogue state is an enum, and storage is one line
A dialogue in this framework is described by an enumeration, where each variant is one possible state, plus handler functions that move the dialogue from one state to another. Together those form a finite state machine.
The example the page shows asks three questions in order and then sends the answers back, with variants that accumulate what has been collected so far: after the name comes a variant holding the name, and after the age one holding both.
That is the whole modelling idea. The compiler can tell you when a handler forgets to produce a state, and the states are a type rather than a string in a map.
Storage is deliberately not part of it. The page stresses that the subsystem is agnostic about how and where dialogues are stored, and that replacing one line is enough to get persistence. Two implementations ship out of the box, Redis and Sqlite, and the example itself uses in-memory storage, which is the right choice for a bot that can lose its state between restarts without consequence.
Commands are an enum, parsed the way a command line parses arguments
The fourth highlight is strongly typed commands, and the comparison the page draws is the interesting part.
You declare commands as a Rust enumeration, derive the framework's trait on it, and the framework parses them automatically. The page puts that in the same family as defining JSON structures for a serializer and defining command line arguments with a derive macro for an argument parser.
The example bot accepts three commands: a username with one argument, a username and an age with two, and a help command with none.
The declarations carry their own metadata. The enumeration sets a naming rule so command names are lowercased, and a description used as the help text. Each variant has its own description, and the two-argument variant declares how its text is split.
The consequence is that parsing, help text and type checking all come from one declaration, which is why the page can claim the commands are strongly typed without asking you to keep three things in sync.
Two transports, a configurable client and a custom API server
The second highlight is a list, and three entries in it are about deployment rather than about the bot API.
You can use long polling or webhooks. You can configure the underlying HTTPS client. You can set a custom URL for a Telegram API server, and you can do a graceful shutdown.
The custom server address is the one to understand. It is what lets a bot talk to a self-hosted Telegram Bot API server rather than the public one, which matters when you run your own infrastructure, need a local endpoint for development, or want to point several bots at one gateway.
Graceful shutdown is the other that pays off quietly. A bot process that is killed mid-update can leave a user's dialogue half-answered, and a framework that lets you drain in-flight work before exiting turns that from a bug into a non-event.
The rest of the list is the standard currency of a bot framework: long polling for simplicity, webhooks for scale, and a client you can point at your own HTTP stack.
The setup pins a compiler version and a dependency version twice
The environment setup is five steps and the fourth one is about keeping your compiler current, because the framework currently requires a compiler of at least version 1.85. The page gives both the stable and the nightly variants of the update and override commands.
The fifth step creates a new crate and asks you to add four dependencies:
[dependencies]
teloxide = { version = "0.17.0", features = ["macros"] }
log = "0.4"
pretty_env_logger = "0.5"
tokio = { version = "1.39", features = ["rt-multi-thread", "macros"] }The framework's own version appears there, while the compiler requirement of 1.85 appears separately in step four.
The other thing in that step is a note about unreleased functionality: if you need something that exists on master but has not shipped, the page shows the dependency line that points at the repository instead. That is an escape hatch with a cost, since you are now tracking a moving branch.
Before the dependencies come the smaller steps: install Rust, create a bot with the Botfather bot to get a token in a specific shape, and put that token in an environment variable, with the page showing the three shell variants for setting it.
A workspace of crates with templated release tags
The repository is a workspace rather than a single crate, and the manifest is short enough to read in full.
Every crate in a directory is a member, and the resolver version is pinned. Then one shared package section holds the values that apply to all of them: the minimum supported Rust version, which is stated with a comment saying what it means, the edition, the licence and the two URLs.
That shared block is why the compiler requirement in the setup instructions cannot drift per crate.
The release metadata is the other thing worth noticing. Two templates are defined: one for the tag message, which interpolates the crate name and the version, and one for the tag name, which prefixes the version with a v. Since a release tags many crates in one repository, the tag name has to be made unique per crate, and that is what the prefix slot is for.
The root also carries a migration guide, a release procedure, a code style document, a pinned toolchain file, a formatter configuration, a contributor mail map, a triage bot configuration and a development container definition.
Testing and the tutorial links live elsewhere
Two sections point outward, and both are honest about who owns what.
The page names a community crate for testing bots written with the framework, links its repository, and links a set of testing examples inside it. So the testing crate the page points to is a community project rather than part of the framework.
The tutorials are a guide for the pipeline library, plus a two-part blog post by a named author about migrating a personal finance bot from Python to Rust, and both parts of it are linked through an archive service rather than to the original site.
Those archived links point to web.archive.org copies rather than the original site.
On versions, three releases are on record from 2025, with the newest in July, while the last push on the default branch is dated 2026-09-15. That gap is exactly the situation the note about pulling the repository for unreleased functionality exists to cover.
Editorial conclusion
Teloxide fits a Rust developer who wants the type system to carry part of the bot's logic, since dialogue states and commands are both enumerations and the derive macros generate the parsing and the help text from the same declaration. It does not fit someone who wants dialogue state hidden behind dynamic values, because the state machine is the point and it is expressed in types. Before adopting, check four things. Which transport you will run on, since long polling and webhooks are both supported and they are different deployment shapes. Where you will keep dialogue state, since the shipped implementations are in-memory, Redis and Sqlite and the switch is a single line. Which version you depend on, because the page documents both the current release and pulling the repository for unreleased functionality, and the newest tagged release is from July 2025 while the branch has moved on. And how much of the pipeline you want to hand-write, because the design goal is that you describe the routing declaratively rather than calling the API directly.
Frequently asked questions
What is teloxide?
A Rust framework for building Telegram bots, described as full-featured and handling the difficult parts so you can focus on your business logic. Its design is declarative, built on a separate chain-of-responsibility pipeline library called dptree, and it supports both long polling and webhooks, a configurable HTTPS client, a custom API server URL and graceful shutdown.
How do I set up teloxide?
Install Rust, create a bot with the Botfather bot to get a token, and put the token in the TELOXIDE_TOKEN environment variable. Keep the compiler at version 1.85 or newer, create a new crate, and add teloxide with the macros feature plus a logging crate and an async runtime. The page also documents pointing the dependency at the repository when you need functionality from master that has not been released.
How does teloxide store dialogue state?
A dialogue is described by an enumeration whose variants are the possible states, with handler functions moving between them and forming a finite state machine. Storage is agnostic and replaceable by changing one line; Redis and Sqlite implementations ship with the framework, and the example uses in-memory storage.
How are bot commands defined in teloxide?
As a Rust enumeration with a derive macro, so the framework parses them automatically. Attributes on the enumeration and its variants set the naming rule and the descriptions, and a variant with more than one argument can declare how the text is split, in the same style as a command line argument parser.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/teloxide-teloxide)Star history chart for your README
[](https://hysenlabs.com/projects/teloxide-teloxide)Was this useful?