Download the PHP package koot-labs/telegram-bot-dialogs without Composer
On this page you can find all versions of the php package koot-labs/telegram-bot-dialogs. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download koot-labs/telegram-bot-dialogs
More information about koot-labs/telegram-bot-dialogs
Files in koot-labs/telegram-bot-dialogs
Package telegram-bot-dialogs
Short Description Telegram Bot API PHP SDK extension that allows to implement dialogs in bots
License MIT
Homepage https://github.com/koot-labs/telegram-bot-dialogs
Informations about the package telegram-bot-dialogs
Dialogs Plugin for Telegram Bot API PHP SDK
A powerful extension for Telegram Bot API PHP SDK v3.1+ that enables dialog-based interactions in your Telegram bots.
Table of Contents
- About
- Features
- Installation
- Laravel Integration
- Framework-agnostic Usage
- Basic Usage
- Creating a Dialog
- Setting up Commands
- Controller Setup
- Advanced Usage
- Dialog Class API
- DialogManager API
- Testing
- Contributing
- License
- Roadmap
About
This package is a maintained fork of the original Telegram Bot Dialogs package, updated to support Telegram Bot API PHP SDK v3, PHP 8+, and modern Laravel features. Our focus is on stability, developer experience, and code readability.
Why This Fork?
The Original package is not maintained anymore and does not support Telegram Bot API PHP SDK v3. The goal of the fork is to maintain the package compatible with the latest Telegram Bot API PHP SDK, PHP 8+ and Laravel features, focus on stability, better DX and readability.
Features
- Framework-agnostic design with enhanced Laravel support
- Dialog-based conversation flow management
- State persistence between messages
- Flexible step navigation
- Support for multiple active dialogs
Scope of the package
Any bot app basically listens to Updates from Telegram API (using your webhook endpoint or by pulling these updates on any trigger, like cron) and sends messages back.
This package helps to implement a dialog mode for your bot: for a given Update, check whether the Update belongs to an already activated Dialog and if there is, run the next step of the Dialog.
This package doesn't solve the task to activate Dialogs for a given Update—you need to implement this logic in your app. Different apps may have different strategies to activate Dialogs (e.g. by commands, by message content, by message type, by user_id, etc.). The package provides an API to activate Dialogs and run the next step for the active Dialog.
Installation
Install via Composer:
Laravel Integration
-
The package automatically registers
\KootLabs\TelegramBotDialogs\Laravel\DialogsServiceProvider
- Publish the configuration:
This creates config/telegramdialogs.php
with these environment variables:
TELEGRAM_DIALOGS_CACHE_DRIVER
(default:database
)TELEGRAM_DIALOGS_CACHE_PREFIX
(default:tg_dialog_
)
Framework-agnostic Usage
For non-Laravel applications, see our framework-agnostic guide.
Basic Usage
1. Creating a Dialog
Create a dialog class extending Dialog
:
2. Setup Webhook Handler
In this example, the Dialog is activated by a command. You can also activate dialogs based on other triggers (like an Update/Message type, or a work inside a Message).
2.1. Setting up a Telegram Command
Create a command to activate your dialog (Laravel example):
2.2. Webhook Handler Setup
Handle webhook updates in your controller:
Advanced Usage
Dialog Class API
DialogManager API
The DialogManager
handles:
- Dialog instance persistence
- Step execution
- Dialog activation and switching
Laravel users can use the Dialogs
facade:
Contributing
Contributions are welcome! Please see our Contributing Guide for details.
Testing
Run the test suite:
License
This package is open-sourced software licensed under the MIT license.
Roadmap
Tasks planned for v1.0:
- [x] Add documentation and examples
- [x] Support for channel bots
- [x] Improve test coverage
- [x] Improve developer experience
- [ ] Reach message type validation
- [ ] Reach API to validate message types and content
Backward Compatibility Promise
We follow Semver 2.0. Breaking changes are only introduced in major versions.
Note:
- Classes marked
@experimental
or@internal
are not covered by BC promise - Return value consistency is not guaranteed, only data types
- Argument names (for PHP 8.0+ named arguments) are not part of BC promise
All versions of telegram-bot-dialogs with dependencies
illuminate/collections Version ^8.0 || ^9.0 || ^10.0 || ^11.0
illuminate/support Version ^8.0 || ^9.0 || ^10.0 || ^11.0
irazasyed/telegram-bot-sdk Version ^3.1
predis/predis Version ^1.0 || ^2.0
psr/simple-cache Version ^3.0