Search by

vegas / messenger-notification

devourersouls

Unified Telegram and MAX notification channels for Laravel with direct and relay transports

Package info

github.com/vegas-dev/vegas-messenger-notification

pkg:composer/vegas/messenger-notification

Statistics

Installs: 48

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.1.0 2026-11-22 09:37 UTC

This package is auto-updated.

Last update: 2026-11-22 09:39:22 UTC


README

Unified Telegram and MAX notification channels for Laravel. Each channel can independently send directly, use an external relay, or be disabled.

The package contains no relay endpoint, bot token, chat ID, or project secret. All values are configured by the consuming application.

Installation

composer require vegas/messenger-notification
php artisan vendor:publish --tag=messenger-config

Configuration

Direct Telegram and relay MAX:

TELEGRAM_NOTIFICATION_DRIVER=direct
TELEGRAM_BOT_TOKEN=
TELEGRAM_CHANNEL_DEFAULT_ID=
TELEGRAM_PROXY=

MAX_NOTIFICATION_DRIVER=vegas-services

VEGAS_SERVICES_URL=
VEGAS_SERVICES_PROJECT=
VEGAS_SERVICES_SIGNING_KEY=

Supported drivers are direct, vegas-services, and off. An empty driver also disables the channel and is the default. If VEGAS_SERVICES_SIGNING_KEY is empty, a stable signing key is derived from the application's APP_KEY.

Laravel notifications

use Vegas\MessengerNotification\Channels\MaxChannel;
use Vegas\MessengerNotification\Channels\TelegramChannel;
use Vegas\MessengerNotification\Messages\MessengerMessage;

public function via($notifiable)
{
    return [TelegramChannel::class, MaxChannel::class];
}

public function toMessenger($notifiable)
{
    return MessengerMessage::create('*New order*')
        ->idempotencyKey('order-created:' . $notifiable->id)
        ->button('Open', route('orders.show', $notifiable));
}

Link previews

Each notification can override link previews for both Telegram and MAX:

return MessengerMessage::create($text)
    ->linkPreview(false); // true allows previews; null restores the channel default

Set channels.max.link_preview or channels.telegram.link_preview in config/messenger.php to true, false, or null. The message setting takes priority over the channel default. A null default preserves the messenger's standard behavior. Existing notifications keep their behavior until a setting is supplied.

Direct transports map the choice to each messenger API. The relay sends the resolved boolean as message.disable_link_preview; an omitted field preserves the relay's existing behavior. Vegas Services must support this field before clients enable it. Telegram document captions do not support link preview options. MAX applies this option to new messages, not edits; previews already present in an existing message are not removed by an edit.

Documents

use Vegas\MessengerNotification\Messages\MessengerMessage;
use Vegas\MessengerNotification\MessengerNotifier;

app(MessengerNotifier::class)->send(
    MessengerMessage::create('Competitor prices changed.')
        ->idempotencyKey('competitor-prices:' . hash_file('sha256', $path))
        ->document($path, 'prices.xls', 'application/vnd.ms-excel')
);

Diagnostics

php artisan messenger:signing-key
php artisan messenger:test all
php artisan messenger:test telegram
php artisan messenger:test max

Relay contract

Relay requests are sent to VEGAS_SERVICES_URL/api/v1/notifications as signed JSON. The HMAC-SHA256 signature covers the timestamp, project slug, and exact request body. Document contents are included as Base64 and should be limited by the relay server.