Open source // Python
ChatPack
A collection of tools and infrastructure for building interactive experiences in messaging bots.
01 // SectionWhat it is
ChatPack is a Python library of interactive UI components for Telegram bots built on Pyrogram. Each component — a confirmation, a menu, a form step — is awaited like a function call, so a multi-step conversation is written as sequential code instead of a set of callback handlers and stored state.
It is published on PyPI as chatpack-ui and requires Python 3.8+.
pip install chatpack-ui02 // SectionThe flow it replaces
Without ChatPack
state (DB) ──> handler ──> edit UI ──> next state (DB)
With ChatPack
data = await Form([Step1, Step2]).run()03 // SectionArchitecture
Every component extends a shared BaseField class and can be called in two ways:
ask(client, chat_id)returns the validated value together with the ids of the messages it sent, so aFormcan clean the conversation up afterwards.ask_value(client, chat_id)returns only the value, for one-off prompts inside existing handlers.
Inline buttons carry namespaced callback data — cp:<field key>:<action>[:<value>] — and each field ignores payloads that belong to another key, so stale buttons from an earlier step cannot interfere.
04 // SectionComponents
ConfirmDialog— yes/no confirmation before destructive actionsJoinChecker— blocks access until the user joins required channelsRatingStars— star rating on a single messageNestedMenu— multi-level menus built from nested dictionariesBroadcastSender— copies a message to a list of usersChunkSender— splits text that exceeds Telegram's 4,096-character limitBranchingForm— forms whose next step depends on earlier answersMultiSelectMenu— checkbox menu with minimum and maximum limitsPhotoCollector— collects a batch of photos within set limits
from chatpack import ConfirmDialog
dialog = ConfirmDialog("Are you sure you want to permanently delete your data?")
confirmed = await dialog.ask_value(client, message.chat.id, timeout=30)05 // SectionTesting
The test suite runs offline: real Pyrogram update objects drive the components while a fake client records every outgoing API call. It uses pytest, with flake8 for linting.
06 // SectionStatus
Released as v1.0.3 in June 2026; the September 2026 release (V1.0.4) added more components. Distributed under the MIT License.
- Language
- Python
- Stars
- 14
- Latest release
- V1.0.4 · 2026.09.17
- Created
- 2026.06.08
- Updated
- 2026.09.17