Slack Channel Integration for Filament Alerts Sender
Send your alerts to Slack through an incoming webhook, or through a bot token and chat.postMessage. The title, body,
image and action URL are rendered as a Block Kit message.
| Light | Dark |
|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
| Package version | Filament | Laravel | PHP |
|---|---|---|---|
| 5.x | 5.x | 12.x, 13.x | 8.2+ |
composer require tomatophp/filament-slack-driverafter install your package please run this command
php artisan filament-slack-driver:installfinally register the plugin on /app/Providers/Filament/AdminPanelProvider.php
->plugin(\TomatoPHP\FilamentSlackDriver\FilamentSlackDriverPlugin::make())open the Slack settings page from the settings hub and fill in either an incoming webhook, or a bot token with a default channel. The webhook and the bot token are write-only, they are never sent back to the browser, and leaving an input empty keeps the value that is already stored.
you can also set the values from your .env file, a saved setting always wins over the env value:
SLACK_WEBHOOK=https://hooks.slack.com/services/T000/B000/xxxx
SLACK_BOT_TOKEN=xoxb-your-bot-token
SLACK_CHANNEL=#general
SLACK_ACTIVE=truewhen nothing is configured, or when the driver is switched off, nothing is sent and nothing is logged.
to set up any model to get notifications you
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use TomatoPHP\FilamentSlackDriver\Traits\InteractsWithSlack;
class User extends Authenticatable
{
use HasFactory;
use Notifiable;
use InteractsWithSlack;
...the notification is run on queue, so you must run the queue worker to send the notifications
php artisan queue:workyou can use the filament native notification and we add some macro for you
use Filament\Notifications\Notification;
Notification::make('send')
->title('Test Notifications')
->body('This is a test notification')
->icon('heroicon-o-bell')
->color('success')
->actions([
\Filament\Notifications\Actions\Action::make('view')
->label('View')
->url('https://google.com')
->markAsRead()
])
->sendUse(auth()->user(), \TomatoPHP\FilamentSlackDriver\Services\SlackDriver::class, ['image' => 'https://via.placeholder.com/150']);to create a new template you can use template CRUD and make sure that the template key is unique because you will use it on every single notification.
to send a notification you must use our helper SendNotification::class like
use TomatoPHP\FilamentAlerts\Facades\FilamentAlerts;
FilamentAlerts::notify(User::first())
->template($template->id)
->title([
"find-text" => "change with this"
])
->body([
"find-text" => "change with this"
])
->drivers(\TomatoPHP\FilamentSlackDriver\Services\SlackDriver::class)
->data(['channel' => '#releases'])
->send();where $template is selected of the template by key or id, and title, body use to select and replace string on the template with custom data.
the channel data key overrides the default channel, it only applies when you send with a bot token.
it can be working with direct user methods like
$user->notifySlack(string $title, ?string $message = null, ?string $url = null, ?string $image = null, ?string $channel = null);you can publish config file by use this command
php artisan vendor:publish --tag="filament-slack-driver-config"you can publish languages file by use this command
php artisan vendor:publish --tag="filament-slack-driver-lang"if you like to run PEST testing just use this command
composer testif you like to fix the code style just use this command
composer formatif you like to check the code by PHPStan just use this command
composer analysePlease see CHANGELOG for more information on what has changed recently.
Please see SECURITY for more information about security.
The MIT License (MIT). Please see License File for more information.
Checkout our Awesome TomatoPHP






