PHPackages                             sakoora0x/laravel-telegram-bot - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. sakoora0x/laravel-telegram-bot

ActiveLibrary[API Development](/categories/api)

sakoora0x/laravel-telegram-bot
==============================

This is my package laravel-telegram-bot

010PHP

Since Oct 24Pushed 6mo agoCompare

[ Source](https://github.com/sakoora0x/laravel-telegram-bot)[ Packagist](https://packagist.org/packages/sakoora0x/laravel-telegram-bot)[ RSS](/packages/sakoora0x-laravel-telegram-bot/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Telegram Bot
====================

[](#laravel-telegram-bot)

[![Latest Version on Packagist](https://camo.githubusercontent.com/911ddf588795a076a12d9940de4c49e313bc36cc5396f310d516dab86db60085/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73616b6f6f726130782f6c61726176656c2d74656c656772616d2d626f742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sakoora0x/laravel-telegram-bot)[![GitHub Tests Action Status](https://camo.githubusercontent.com/ce5b42557d658bea193aaea0c931509edd47759ff7a30cf2217f577c5dfee36f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73616b6f6f726130782f6c61726176656c2d74656c656772616d2d626f742f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/sakoora0x/laravel-telegram-bot/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/737ddc6320927c8958da6366526cd8ec7e51cad64220c35dae14f83f33c94924/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73616b6f6f726130782f6c61726176656c2d74656c656772616d2d626f742f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/sakoora0x/laravel-telegram-bot/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/092894360d33f37bf451102463b7c320f155df31de659787adc549f1552cb740/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73616b6f6f726130782f6c61726176656c2d74656c656772616d2d626f742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sakoora0x/laravel-telegram-bot)

This package for Laravel 11+ allows you to easily create interactive Telegram bots, using Laravel routing, and using Blade templates to conduct a dialogue with the user.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require sakoora0x/laravel-telegram-bot
```

```
php artisan telegram:install
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="telegram-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="telegram-config"
```

Optionally, you can publish the views using:

```
php artisan vendor:publish --tag="telegram-views"
```

### Configuration for Laravel Sail

[](#configuration-for-laravel-sail)

Optionally, if you use Sail for local development, you need to add PHP parameter `PHP_CLI_SERVER_WORKERS="10"` in file `supervisord.conf`:

```
[program:php]
command=%(ENV_SUPERVISOR_PHP_COMMAND)s
user=%(ENV_SUPERVISOR_PHP_USER)s
environment=LARAVEL_SAIL="1",PHP_CLI_SERVER_WORKERS="10"
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
```

### Authentication Setup

[](#authentication-setup)

You can use Laravel Auth, edit file `config/auth.php` and edit section `guards`:

```
'guards' => [
    'web' => [...],
    'telegram' => [
        'driver' => 'telegram',
        'provider' => 'users',
    ]
],
```

After this you can use middleware `auth:telegram` in your routes.

### Scheduled Tasks

[](#scheduled-tasks)

If you want to work with automatic dialog truncation, you must run command `php artisan telegram:truncate` every minute using Schedule.

### Live Pages Setup

[](#live-pages-setup)

You can configure "live pages" (auto-refreshing pages). In the `bootstrap/app.php` file, add an alias to the `withMiddleware` section:

```
->withMiddleware(function (Middleware $middleware) {
    $middleware->alias([
        'telegram.live' => \sakoora0x\Telegram\Middleware\LiveMiddleware::class,
    ]);
})
```

Then connect the middleware to the desired route:

```
Route::telegram('/', [\App\Telegram\Controllers\MyController::class, 'index'])
    ->middleware(['telegram.live:30']);
```

The argument is the frequency in seconds for how often to update the page.

And add to the `routes/console.php` file:

```
Schedule::command('telegram:live')
    ->runInBackground()
    ->everyMinute();
```

Usage
-----

[](#usage)

### Create New Telegram Bot

[](#create-new-telegram-bot)

```
php artisan telegram:new-bot
```

### Set Webhook for Bot

[](#set-webhook-for-bot)

```
php artisan telegram:set-webhook
```

### Unset Webhook for Bot

[](#unset-webhook-for-bot)

```
php artisan telegram:unset-webhook
```

### Manual Polling (on localhost) for Bot

[](#manual-polling-on-localhost-for-bot)

```
php artisan telegram:polling [BOT_ID]
```

Features
--------

[](#features)

### Inline Keyboard

[](#inline-keyboard)

If you want to create a button to change the current URI query params, use this template:

```

        Change query param

```

If you want to send POST data, you must use this template:

```

        Send field value

```

If the POST data is long, you can encrypt it using this template:

```

        Encoded send data

```

If you want to make a redirect to another page from a button, use this template:

```

        Redirect to /

```

### Edit Form

[](#edit-form)

Create a form class for data editing:

```
class MyForm extends \sakoora0x\Telegram\EditForm\BaseForm
{
    public function rules(): array
    {
        return [
            'name' => ['required', 'string', 'min:5', 'max:255'],
            'phone' => ['required', 'string', 'min:10', 'max:15'],
        ];
    }

    public function titles(): array
    {
        return [
            'name' => 'Your name',
            'phone' => 'Your phone number'
        ];
    }
}
```

Use the form in your controller:

```
class MyController
{
    public function edit(MyForm $form): mixed
    {
        $form->setDefault([
            'name' => 'Default name',
            'phone' => '1234567890',
        ]);

        if ($form->validate()) {
            // $form->get();
        }

        return view('...', compact('form'));
    }

    public function create(MyForm $form): mixed
    {
        if ($form->isCreate()->validate()) {
            // $form->get();
        }

        return view('...', compact('form'));
    }
}
```

Display the form in your Blade template:

```

            Please, enter your First Name:

```

Testing
-------

[](#testing)

The package includes comprehensive tests covering all core functionality.

```
composer test
```

**Test Results:**

- ✅ 88 passing tests
- ⏭️ 1 skipped
- 138 assertions
- Duration: ~2.4 seconds

See [TESTING.md](TESTING.md) for detailed testing documentation.

Future Ideas
------------

[](#future-ideas)

1. Add `query-history=false` parameter to Inline Button so that the current URL is not saved in referer, preventing form reset on back navigation.
2. Enable users to upload photos/videos/documents and parse captions in messages.
3. Add phone number sharing button in Reply Button and receive results in TelegramRequest.
4. Read results from forwarded contacts in TelegramRequest.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

- [MollSoft](https://github.com/mollsoft)
- [sakoora0x](https://github.com/sakoora0x)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance46

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 95.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/4a57bfb0b7a98c2728ab3b8e2d9e41a18bd0f9d47fccefbd3ebc6d1293801f94?d=identicon)[sakoora0x](/maintainers/sakoora0x)

---

Top Contributors

[![mollsoft](https://avatars.githubusercontent.com/u/151442118?v=4)](https://github.com/mollsoft "mollsoft (114 commits)")[![sakoora0x](https://avatars.githubusercontent.com/u/239889939?v=4)](https://github.com/sakoora0x "sakoora0x (3 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

### Embed Badge

![Health badge](/badges/sakoora0x-laravel-telegram-bot/health.svg)

```
[![Health](https://phpackages.com/badges/sakoora0x-laravel-telegram-bot/health.svg)](https://phpackages.com/packages/sakoora0x-laravel-telegram-bot)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
