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

Python 3.10+, aiogram 3.

Setup

from aiogram import Dispatcher
from aiogram_input import MemoryInputStorage, setup_input

dp = Dispatcher()

# Local / single process
setup_input(dp, storage=MemoryInputStorage())

# Production (multi-worker): same API, Redis-backed storage
# setup_input(dp, storage=RedisInputStorage(redis))

# If `input` already means something else in your handlers:
# setup_input(dp, data_key="aiogram_input")

InputWaiter is injected into handlers (DI, like FSMContext). Storage is swappable via InputStorage (Memory today, Redis when you scale). The 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.1.0.tar.gz (10.9 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.1.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aiogram_input-4.1.0.tar.gz
  • Upload date:
  • Size: 10.9 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.1.0.tar.gz
Algorithm Hash digest
SHA256 0fa00e2237fca0e6749a88a4b3011453bb500b9be5d08b2adf8be1f1b7143ddd
MD5 ae89beeb97b9845ee1ee9c604a82317a
BLAKE2b-256 eb3dc4805993e287d80f5971e678d360b610b1111d97baa32ee26e7209bbbb40

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiogram_input-4.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.3 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4459fe302f2d43836dca507fa99f744fadb437d5ab48d24b53c0d8bff565014b
MD5 f614e20536659b085fadee935746a843
BLAKE2b-256 dfc6140645a8b59f5073fbcea62f137c73245d7d97715a7f88c76ef3fb5346db

See more details on using hashes here.

Release history Release notifications | RSS feed

4.2.1

2 files

4.2.0

2 files

This release

4.1.0 This release

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