PHPackages                             jpblu/telegram-error-notifier - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. jpblu/telegram-error-notifier

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

jpblu/telegram-error-notifier
=============================

A PHP library for sending alert messages to a Telegram bot. Compatible with Laravel.

v1.4.0(4mo ago)5128MITPHPPHP &gt;=7.4CI passing

Since Apr 12Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/jpblu/telegram-error-notifier)[ Packagist](https://packagist.org/packages/jpblu/telegram-error-notifier)[ RSS](/packages/jpblu-telegram-error-notifier/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (3)Versions (8)Used By (0)

[![Tests](https://github.com/jpblu/telegram-error-notifier/actions/workflows/tests.yml/badge.svg)](https://github.com/jpblu/telegram-error-notifier/actions/workflows/tests.yml)[![GitHub Release](https://camo.githubusercontent.com/482ade5aa3d4229e8f069e7a165ba79a6883c13511b8a4dd82abc189295850a3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6a70626c752f74656c656772616d2d6572726f722d6e6f746966696572)](https://camo.githubusercontent.com/482ade5aa3d4229e8f069e7a165ba79a6883c13511b8a4dd82abc189295850a3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6a70626c752f74656c656772616d2d6572726f722d6e6f746966696572)[![Static Badge](https://camo.githubusercontent.com/26a9c3ff4f26299c8d8a78a030741dc91155d40ba7eb933a9b5e1a1113ab1cb8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344253230382e312d626c7565)](https://camo.githubusercontent.com/26a9c3ff4f26299c8d8a78a030741dc91155d40ba7eb933a9b5e1a1113ab1cb8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344253230382e312d626c7565)[![Laravel Compatibility](https://camo.githubusercontent.com/5349516d61f9d5153899653802cff6a1525a4fbbec1ce4f10dab49b19170b8fa/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d382e78253230253743253230392e7825323025374325323031302e7825323025374325323031312e7825323025374325323031322e782d626c756576696f6c65743f6c6f676f3d6c61726176656c266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/5349516d61f9d5153899653802cff6a1525a4fbbec1ce4f10dab49b19170b8fa/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d382e78253230253743253230392e7825323025374325323031302e7825323025374325323031312e7825323025374325323031322e782d626c756576696f6c65743f6c6f676f3d6c61726176656c266c6f676f436f6c6f723d7768697465)[![License: MIT](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](LICENSE)

Telegram Error Notifier
=======================

[](#telegram-error-notifier)

A PHP library for sending alert messages to a Telegram bot. Compatible with Laravel.

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

[](#installation)

You can install the package using Composer:

```
composer require jpblu/telegram-error-notifier
```

Telegram Setup
--------------

[](#telegram-setup)

1. Create a [Telegram bot](https://t.me/BotFather).
2. Get the bot token.
3. Create a private or public channel.
4. Add your bot as an **admin** of the channel.
5. Get the channel ID (prefix with `@` if it's a public channel or use the numeric ID for private ones).

> **Note**: Refer to [Telegram Bot documentations](https://core.telegram.org/bots/api) for further instructions.

Usage (PHP projects)
--------------------

[](#usage-php-projects)

```
use TelegramNotifier\TelegramNotifier;

$notifier = new TelegramNotifier('TELEGRAM_BOT_TOKEN', 'TELEGRAM_CHAT_ID');
$response = $notifier->send('An error occurred in your service.');
```

Usage (Laravel project)
-----------------------

[](#usage-laravel-project)

This library automatically registers a Service Provider and Facade if used in a Laravel project.

### Configuration

[](#configuration)

1. Add environment variables to your `.env` file:

```
TELEGRAM_BOT_TOKEN=your-bot-token
TELEGRAM_CHAT_ID=your-chat-id
```

2. Add to `config/services.php`

```
'telegram_notifier' => [
    'bot_token' => env('TELEGRAM_BOT_TOKEN'),
    'chat_id' => env('TELEGRAM_CHAT_ID'),
],
```

### Examples

[](#examples)

#### Send an error message inside a `try/catch` block

[](#send-an-error-message-inside-a-trycatch-block)

```
use TelegramNotifier\TelegramNotifier;

public function store(Request $request)
{
    try {
        // Application logic
    } catch (\Throwable $e) {
        app(\TelegramNotifier::class)->send($e->getMessage());
        throw $e; // or handle the exception
    }
}

```

#### Notify errors inside a queued Job

[](#notify-errors-inside-a-queued-job)

```
use TelegramNotifier\TelegramNotifier;
use Illuminate\Contracts\Queue\ShouldQueue;

class ProcessUserJob implements ShouldQueue
{
    public function handle()
    {
        try {
            // Background processing logic
        } catch (\Throwable $e) {
            app(\TelegramNotifier::class)->send("Job failed: " . $e->getMessage());
            throw $e;
        }
    }
}

```

#### Catch all unhandled exceptions in the global Exception Handler

[](#catch-all-unhandled-exceptions-in-the-global-exception-handler)

Edit your `app/Exceptions/Handler.php` file:

```
use TelegramNotifier\TelegramNotifier;

public function report(Throwable $exception)
{
    parent::report($exception);

    if ($this->shouldReport($exception)) {
        app(\TelegramNotifier::class)->send($exception->getMessage());
    }
}

```

#### Manual notification

[](#manual-notification)

```
TelegramNotifier::send('User import completed successfully.');

```

#### Send a message from console

[](#send-a-message-from-console)

You can send messages directly from the console using the Artisan command:

```
php artisan telegram:send "Your message here"
```

Example with dynamic messages:

```
php artisan telegram:send "Database backup completed at $(date)"
```

Returned Values
---------------

[](#returned-values)

The `send()` method returns an **array** with the response from the Telegram API (or an error if applicable).

Example:

```
[
    'ok' => true,
    'result' => [
        'message_id' => 123,
        'chat' => [...],
        'text' => 'Your message'
    ]
]
```

### Laravel Compatibility

[](#laravel-compatibility)

This package has been tested and works with the following Laravel versions:

- Laravel 8.x
- Laravel 9.x (LTS)
- Laravel 10.x (LTS)
- Laravel 11.x
- Laravel 12.x

Laravel 5.5+ may also work, as this package uses automatic service provider registration via Composer.

### Acknowledgments

[](#acknowledgments)

- [GuzzleHTTP](https://github.com/guzzle/guzzle) for client connection
- [PHPUnit](https://github.com/sebastianbergmann/phpunit/) for testing suite

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance77

Regular maintenance activity

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Every ~46 days

Recently: every ~61 days

Total

7

Last Release

124d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/69c693a7535fb629926d3e917b7925fb2422217d35348bfb6c7a1ed4b53940fc?d=identicon)[jpblu](/maintainers/jpblu)

---

Top Contributors

[![jpblu](https://avatars.githubusercontent.com/u/91039357?v=4)](https://github.com/jpblu "jpblu (16 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jpblu-telegram-error-notifier/health.svg)

```
[![Health](https://phpackages.com/badges/jpblu-telegram-error-notifier/health.svg)](https://phpackages.com/packages/jpblu-telegram-error-notifier)
```

###  Alternatives

[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[laravel-notification-channels/microsoft-teams

A Laravel Notification Channel for Microsoft Teams

1603.0M7](/packages/laravel-notification-channels-microsoft-teams)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)[guanguans/notify

Push notification SDK(AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、PushMe、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、ZohoCliq、ZohoCliqWebHook、Zulip).

682104.9k7](/packages/guanguans-notify)[tzsk/sms

A robust and unified SMS gateway integration package for Laravel, supporting multiple providers.

320244.3k6](/packages/tzsk-sms)[pusher/pusher-push-notifications

562.5M9](/packages/pusher-pusher-push-notifications)

PHPackages © 2026

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