aiogram-input
Wait for the next Telegram message inside an aiogram handler — without an FSM for every short prompt.
Why
You ask for a phone number, a confirmation, or a one-time code. A full FSM for that is noise. You want:
send question → await reply → continue
Register once on the Dispatcher. Await input.wait(...). Get a Message, or None on timeout. FSM and other handlers still get unrelated updates.
Install
pip install -U aiogram-input
pip install -U "aiogram-input[redis]" # Redis storage
Python 3.10+, aiogram 3.
Setup
from aiogram import Dispatcher
from aiogram_input import MemoryInputStorage, RedisInputStorage, setup_input
from redis.asyncio import Redis
dp = Dispatcher()
# Local / single process
setup_input(dp, storage=MemoryInputStorage())
# Production: Redis markers + TTL (futures still resolve on the owning worker)
# redis = Redis.from_url("redis://localhost:6379/0")
# setup_input(dp, storage=RedisInputStorage(redis, ttl=300))
# If `input` already means something else in your handlers:
# setup_input(dp, data_key="aiogram_input")
InputWaiter is injected into handlers (DI, like FSMContext). Pick storage: Memory or Redis (InputStorage). Futures stay in-process; Redis holds wait markers. DI key is configurable (data_key, default "input").
Examples
DI — one setup, every router
Pain: waiter constructed on dp, again on admin_router, again in another file. State splits.
from aiogram import Router
from aiogram.filters import Command
from aiogram.types import Message
from aiogram_input import InputWaiter
admin = Router()
support = Router()
@admin.message(Command("ban"))
async def ban_user(message: Message, input: InputWaiter):
await message.answer("Send the user id to ban:")
reply = await input.wait(message.chat.id, timeout=60)
if reply is None:
return await message.answer("Timed out.")
await message.answer(f"Banned `{reply.text}`", parse_mode="Markdown")
@support.message(Command("ticket"))
async def open_ticket(message: Message, input: InputWaiter):
await message.answer("Describe the issue:")
reply = await input.wait(message.chat.id, timeout=120)
...
dp.include_router(admin)
dp.include_router(support)
Magic filters — wait for a sticker, not chat noise
Pain: you ask for a sticker pack preview. People spam text. In groups, someone else replies first.
from aiogram import F
from aiogram.filters import Command
from aiogram.types import Message
from aiogram_input import InputWaiter
@dp.message(Command("sticker_id"))
async def sticker_id(message: Message, input: InputWaiter):
await message.answer("Send a sticker — text will be ignored.")
sticker = await input.wait(
message.chat.id,
timeout=45,
filter=(
F.sticker
& (F.from_user.id == message.from_user.id)
),
)
if sticker is None:
return await message.answer("Timed out.")
await message.answer(
f"file_id:\n`{sticker.sticker.file_id}`",
parse_mode="Markdown",
)
Only a sticker from the same user resolves the wait. Texts, photos, and other users’ stickers keep flowing to the rest of your bot.
3.x → 4.x
InputManager is removed. Use setup_input(dp) + input.wait(...).
License
MIT
Metadata
Release files for aiogram-input 4.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aiogram_input-4.2.1.tar.gz | 14.7 kB | Without provenance | Details for aiogram_input-4.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aiogram_input-4.2.1-py3-none-any.whl | Python 3 | none | any | Details for aiogram_input-4.2.1-py3-none-any.whl |
Total release size: 26.9 kB
Release files / aiogram_input-4.2.1.tar.gz
| Download URL | aiogram_input-4.2.1.tar.gz |
|---|---|
| Size | 14.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9155c6ddcf97905e2c16e010af69cefe31e0c2dff5ecb9a5ab3cb53501f3b330
|
|
BLAKE2b-256 checksum How to use checksums |
4699745bc1cb3e8c60eac908dfe13988908b58630faaa0ecaa21b91a7117a556
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / aiogram_input-4.2.1-py3-none-any.whl
| Download URL | aiogram_input-4.2.1-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
376b230354b9d537f6e6446e4fbaa81447ca51d2a69e2b0bda306ccaf2fc7dfc
|
|
BLAKE2b-256 checksum How to use checksums |
82673509e8a23054f611b97ab93984e53691c7a11356c558031dfb2c2f850791
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for aiogram-input 4.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.