Laravel Google Chat Alerts
Published on by Paul Redmond
Laravel Google Chat Alerts is a package by Guy Warner to send a message to Google chat quickly. Inspired by Spatie's Laravel Slack Alerts Package, this package does the same for Google Chat:
use GuyWarner\GoogleChatAlerts\Facades\GoogleChatAlert; GoogleChatAlert::message( "You have a new subscriber to the {$newsletter->name} newsletter!");
With the above code, you can send a message quickly without the overhead of the (excellent) Laravel notifications system. This package sends alerts as a job to prevent your app from failing in case Google chat is down.
Like the Spatie package for Slack, this package supports multiple channels and the ability to select which channel to which to send an alert:
// in config/google-chat-alerts.php 'webhook_urls' => [ 'default' => 'https://chat.googleapis.com/v1/spaces/XXXX', 'sales' => 'https://chat.googleapis.com/v1/spaces/YYYYYY',], GoogleChatAlert::to('sales') ->message("You have a new subscriber to the {$newsletter->name} newsletter!");
Additional features include using markdown and the ability to mention all users in a channel:
GoogleChatAlert::message("New support ticket. <users/all>");
Check out this fantastic package on GitHub at guywarner/laravel-google-chat-alerts, which includes documentation, installation, and usage instructions.