gizburdt/talk
Talk
Send notifications to recipients
Installation
You can install the package via composer:
composer require gizburdt/talk
Usage
Discord
Create a webhook in your Discord channel settings. Return DiscordWebhookChannel::class from via() and add a toDiscord() method to your notification:
use Gizburdt\Talk\Discord\DiscordEmbed;
use Gizburdt\Talk\Discord\DiscordMessage;
use Gizburdt\Talk\Discord\DiscordWebhookChannel;
public function via(object $notifiable): array
{
return [DiscordWebhookChannel::class];
}
public function toDiscord(object $notifiable): DiscordMessage
{
return DiscordMessage::make('Deployment finished')
->username('Deploy bot')
->embed(fn (DiscordEmbed $embed) => $embed
->title('Production')
->color('#22c55e')
->field('Duration', '42s', inline: true));
}
Return the webhook URL from routeNotificationFor('discord') on your notifiable:
public function routeNotificationForDiscord(): string
{
return $this->discord_webhook_url;
}
On-demand notifications work too:
Notification::route('discord', $webhookUrl)->notify(new Deployed);
A failed request (for example an invalid payload) throws an Illuminate\Http\Client\RequestException.
Testing
composer test
Related Packages
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 0.3.0 | ^8.3 | ^12.0|| | MIT | |
| 0.2.0 | ^8.3 | ^12.0|| | MIT | |
| 0.1.0 | ^8.3 | ^12.0|| | MIT |