Skip to main content

aiogram-input

PyPI Test

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 (multi-worker): Redis-backed wait markers
# 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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiogram_input-4.2.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiogram_input-4.2.0-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file aiogram_input-4.2.0.tar.gz.

File metadata

  • Download URL: aiogram_input-4.2.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for aiogram_input-4.2.0.tar.gz
Algorithm Hash digest
SHA256 d605850b46ec1da5bef500db376f065bdd06b417ea1c61aa953356504a7ded5c
MD5 4f78e0e1aa396679f5ddca482abc0fc4
BLAKE2b-256 dece013204b7e9f51b12c657faf77dddfd2b13e3111a83688c40f0dff9a0dcf4

See more details on using hashes here.

File details

Details for the file aiogram_input-4.2.0-py3-none-any.whl.

File metadata

  • Download URL: aiogram_input-4.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for aiogram_input-4.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76916a3c5d448046122adcddd7c7d75166a6c9a8c6008f22f6d41839178c069a
MD5 f6150b6be3c2446e57daf7ae247a6936
BLAKE2b-256 029983e7a958cefa961d810646b561e680d45d2586bd0b721de4031e4bc6a488

See more details on using hashes here.

Release history Release notifications | RSS feed

4.2.1

2 files

This release

4.2.0 This release

2 files

4.1.0

2 files

4.0.0

2 files

3.1.1

2 files

3.1.0

2 files

2.0.1

2 files

2.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page