aiogram — asynchronous Python framework for the Telegram Bot API

A modern, fully asynchronous framework for the Telegram Bot API, built on asyncio and aiohttp. Typed end to end, with routers, magic filters, a finite-state machine and middlewares that keep your bot code small and testable.

Package manager
pip install -U aiogramuv add aiogram

Python 3.10+ · MIT license · Installation guide

  • Latest aiogram version on PyPI
  • Supported Python versions
  • GitHub stars
  • License: MIT

Quick start

An echo bot in about 30 lines. Set BOT_TOKEN and run it with Python 3.10 or newer.

bot.py
import asyncio
import logging
from os import getenv

from aiogram import Bot, Dispatcher
from aiogram.filters import CommandStart
from aiogram.types import Message

dp = Dispatcher()


@dp.message(CommandStart())
async def start(message: Message) -> None:
    await message.answer(f"Hello, {message.from_user.full_name}!")


@dp.message()
async def echo(message: Message) -> None:
    try:
        await message.send_copy(chat_id=message.chat.id)
    except TypeError:
        await message.answer("Nice try!")


async def main() -> None:
    bot = Bot(token=getenv("BOT_TOKEN"))
    await dp.start_polling(bot)


if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO)
    asyncio.run(main())