Download the PHP package chatflowphp/telegram without Composer
On this page you can find all versions of the php package chatflowphp/telegram. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download chatflowphp/telegram
More information about chatflowphp/telegram
Files in chatflowphp/telegram
Package telegram
Short Description Telegram adapter for the ChatFlow conversational runtime.
License MIT
Homepage https://github.com/chatflowphp/telegram
Informations about the package telegram
ChatFlow Telegram
chatflowphp/telegram is the Telegram adapter for the platform-neutral ChatFlow core.
It supports webhook and polling execution, commands, callback actions, smart render/edit-or-send behavior, media views, callback acknowledgements, Telegram file downloads and a typed Telegram layer for admin-style bots.
Full package documentation starts at docs/ai-index.md as compact context for AI-assisted bot implementation tasks.
Start Here
- Build your first bot: docs/getting-started.md
- Design a production bot: docs/development/index.md
- Browse API and runtime reference: docs/index.md
- AI implementation context: docs/ai-index.md
Quick Start
For a runnable version of this pattern, see examples/StarterBot.
Mapping
- Telegram messages become text events.
- Callback queries become action events.
- Chat id becomes
ConversationRef::getId()and is used as the session key. - Telegram message/callback metadata is stored in
MessageReffor adapter delivery. reply()sends a new message.render()edits where possible, otherwise deletes/sends.ack()answers callback queries and falls back to a message when text is provided.
Telegram-Specific Layer
Keep portable handler code on ChatFlow\Core\Context. Use ChatFlow\Telegram\TelegramContext only when the flow needs Telegram-only behavior:
TelegramContext is intentionally not a facade for the Telegram Bot API. It only adds ChatFlow-aware Telegram helpers such as forceReply(), Telegram message options and current update metadata. Use core ack() for callback acknowledgements.
For publishing flows that need Telegram message_id immediately, inject ChatFlow\Telegram\TelegramPublisher and call sendMessage(), sendMedia(), sendMediaGroup(), editText(), editCaption() or deleteMessage() directly. Publisher methods return typed delivery results with chat id, message ids, endpoint and raw response. For Telegram Bot API endpoints not covered by ChatFlow semantics, inject Telegram\Bot\Api and use the SDK directly.
TelegramView and TelegramMessageOptions attach Telegram Bot API options to a neutral View via metadata:
Long callback payloads are stored automatically behind short cf:<token> callback data. Inbound callback queries are decoded back to the original action id and payload.
Inbound Telegram attachments are normalized for photos, documents, videos, animations, audio, voice, stickers and video notes. Telegram file_id, file_unique_id, captions, media group id, dimensions, duration, mime type and size are preserved in attachment metadata.
Media groups are collected by the adapter before core handling. The default collector waits briefly, aggregates updates with the same media_group_id, and emits one inbound event with ordered attachments.
TelegramScreenManager provides best-effort cleanup for command screens by tracking publisher delivery results and deleting previous message groups.
Operational Notes
The default file-backed callback payload store keeps long callback payloads for 7 days and removes expired tokens opportunistically. The default media group store keeps pending album parts for 5 minutes and also cleans stale groups opportunistically.
Telegram render() is intentionally best-effort: the adapter tries to edit the current message, then falls back to delete/send or send-only when Telegram rejects the edit. These fallbacks are logged through the Bot logger but do not fail the flow unless final delivery also fails.
StarterBot is the minimal runnable onboarding example. MiniShop is the advanced Telegram-specific example with commands, inline callback buttons, smart edit-or-send rendering, media replies, scenes, validation and sessions.
Observability
Pass runtimeObserver to the Bot constructor to receive core lifecycle events such as route matches, queued effects and delivery failures.
The MiniShop polling example enables JSONL runtime logs by default:
Set CHATFLOW_RUNTIME_LOG=/path/to/runtime.jsonl to override the log path.
Documentation
First Bot
- Getting Started
- Examples
- Testing
Production Workflow
- Telegram Bot Development Kit
- Bot Development Process
- Bot Spec Template
- Spec Review Checklist
- Implementation Blueprint Template
- Acceptance Testing Guide
- AI Development Workflow
API Reference
- Commands
- Callbacks
- Rendering
- Telegram Context
- Scenes And Dialogs
- Media And Files
- Webhook And Polling
- AI Index
License
This project is released under the MIT License. See LICENSE for details.