Logo Beartropy Alert System

Alert System

Configuration
Configure global behavior and alert channels.

Publish Configuration

Publish the configuration file to config/alert-system.php:

1php artisan vendor:publish --tag=alert-system-config

General Options

The configuration file allows you to define:

  • Blade layout: The layout file to extend for the admin UI.
  • Routes: Customize the prefix (admin/alerts) and middlewares (web, auth), or disable them entirely (publish_routes).
  • Environments: Which APP_ENV values are allowed to actually send alerts.
  • Global cooldown: Minimum seconds between duplicate alerts to prevent spam (can be overridden per alert).
  • History & Logging: Enable/disable database storage (`db-history`) and additional file logging.

1return [
2 'layout' => 'layouts.app', // Blade layout for Livewire UI
3 'route_prefix' => 'admin/alerts', // URL prefix for admin UI
4 'route_middlewares' => ['web', 'auth'], // Middleware for admin UI
5 'publish_routes' => true, // Whether to automatically load package routes
6 
7 'envs' => ['production', 'staging'], // Allowed environments to send alerts
8 'cooldown' => 60, // Global cooldown in seconds
9 'db-history' => true, // Save logs to database
10 
11 'logging' => [ // Log to file (storage/logs/...)
12 'enabled' => true,
13 'channel' => 'daily',
14 'level' => 'info',
15 ],
16 
17 // ...
18];
Channel Configuration
Telegram Setup

1. Create a Bot

  1. Open Telegram and search for @BotFather.
  2. Send the command /newbot.
  3. Follow the instructions to name your bot.
  4. Once created, BotFather will give you a Token (e.g., 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11).

2. Configure Token

Add the token to your .env file (TELEGRAM_BOT_TOKEN=...) and configure it in config/alert-system.php.

1// config/alert-system.php
2 
3'telegram' => [
4 'bots' => [
5 'default_bot' => [
6 'token' => env('TELEGRAM_BOT_TOKEN'),
7 'proxy' => env('TELEGRAM_PROXY', null), // Optional
8 'verify' => true,
9 ],
10 // You can add multiple bots here
11 ],
12 'default' => 'default_bot',
13],

3. Get Chat ID

To send alerts to a specific user or group, you need their Chat ID.

  • Start a chat with your new bot.
  • Visit https://api.telegram.org/bot<YourBOTToken>/getUpdates in your browser.
  • Look for the "chat": {"id": ...} field in the JSON response.
  • Use this ID when adding a recipient in the Admin UI.

Discord Setup

1. Create Webhook

  1. Open Discord and go to the Server Settings > Integrations.
  2. Click Webhooks and then New Webhook.
  3. Select the channel where you want alerts to appear.
  4. Copy the Webhook URL.

2. Configure Webhook

Add the URL to your .env file.

1// config/alert-system.php
2 
3'discord' => [
4 'bots' => [
5 'default_bot' => [
6 'webhook' => env('DISCORD_WEBHOOK_URL'),
7 'proxy' => env('DISCORD_PROXY', null), // Optional
8 'verify' => true,
9 ],
10 ],
11 'default' => 'default_bot',
12],