eighteen73 / laravel-google-chat
Google Chat Notification Channel for Laravel (fka. Hangouts Chat)
Requires
- php: ^8.2
- guzzlehttp/guzzle: ^7.0
- illuminate/notifications: ^12.0 || ^13.0
- illuminate/support: ^12.0 || ^13.0
- league/commonmark: ^2.8
Requires (Dev)
- laravel/pint: ^1.30
- orchestra/testbench: ^10.0 || ^11.0
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^11.5.3
README
This package makes it easy to send Google Chat notifications (simple text, formatted messages, and rich cards) using webhooks or REST API service accounts in Laravel 12.x and 13.x.
Maintained by eighteen73.
Key Features
- Rich Cards v2 Engine: Full support for interactive Google Chat Cards v2 with headers, sections,
DecoratedText,ButtonList,Divider, andColumns. - Pluggable Transports: Send notifications via lightweight space Incoming Webhooks or Google Cloud Service Accounts.
- Message Updates & Patching: Update previously posted card messages dynamically using the Service Account transport.
- Thread Management: Reply directly into existing threads using thread keys or message resource names.
- Fluent Builder Closures: Clean
$message->card(fn (Card $c) => ...)and$card->section(fn (Section $s) => ...)closures.
Documentation
Full developer documentation, configuration guides, card layout examples, and API references are available on our documentation site:
Requirements
- PHP
^8.2 - Laravel
^12.0or^13.0
Installation
Require the package via Composer:
composer require eighteen73/laravel-google-chat
Publish the configuration file:
php artisan vendor:publish --tag=google-chat-config
Quick Examples
Simple Text Notification
public function toGoogleChat(object $notifiable): GoogleChatMessage { return GoogleChatMessage::create() ->bold('Invoice Paid!') ->line('Payment of £450.00 was received successfully.') ->to('sales'); }
Rich Card v2 Notification
use NotificationChannels\GoogleChat\Card; use NotificationChannels\GoogleChat\Enums\Icon; use NotificationChannels\GoogleChat\Enums\ImageType; use NotificationChannels\GoogleChat\Section; public function toGoogleChat(object $notifiable): GoogleChatMessage { return GoogleChatMessage::create() ->to('alerts') ->card(function (Card $card) { $card->header('Server Alert', 'web-prod-01', ImageType::CIRCLE) ->section(function (Section $section) { $section->decoratedText('CPU Utilisation', '94%', Icon::WARNING) ->divider() ->buttonList(function ($buttons) { $buttons->button('Open Dashboard', 'https://example.com/monitoring'); }); }); }); }
For advanced features like updating sent messages, Service Account setup, custom space aliases, threading, and local test overrides, please refer to the full documentation.
Development & Testing
# Run PHPUnit tests composer test # Run static analysis composer analyse # Check code formatting composer lint # Automatically format code composer format
The test suite contains 50 unit tests covering all Cards v2 components, payload serialization, and HTTP transports:
composer test
Security
If you discover any security related issues, please email us or use the issue tracker.
Credits
- Originally created by Frank Dixon and the Laravel Notification Channels community.
- Maintained by eighteen73.
- All Contributors
License
The MIT License (MIT). Please see LICENSE.md for more information.