Google Chat Notification Channel
This package provides a modern, fluent Google Chat notification channel for Laravel 12.x and 13.x to send simple text notifications, formatted markdown messages, and interactive rich cards.
Core Features
- Simple & Formatted Text: Fluent formatting for bold, italic, strikethrough, monospace, hyperlinks, user mentions, and
@allroom alerts, plus GitHub-Flavoured Markdown conversion. - Rich Card Engine: Full support for interactive Google Chat cards with headers, sections,
DecoratedText,ButtonList,Divider,Columns, andCardActionoverflow menus. - Strict PHP 8.2 Backed Enums: Type-safety using
ButtonType,Icon,ImageType,MessageReplyOption, andSelectionTypeenums. - Pluggable Transports: Built-in
WebhookTransport(powered by Laravel'sHttpfacade for seamlessHttp::fake()testing) andServiceAccountTransportfor OAuth REST authentication. - Message Updates & Threading: Update existing sent card messages via
PATCHand manage thread replies effortlessly. - Fluent Builder Closures: Intuitive
$message->card(fn (Card $c) => ...)and$card->section(fn (Section $s) => ...)builder closures.
Requirements
- PHP:
^8.2or^8.3/^8.4/^8.5 - Laravel:
^12.0or^13.0
Installation
Install the package via Composer:
bash
composer require eighteen73/laravel-google-chatPublish the configuration file to your project:
bash
php artisan vendor:publish --tag=google-chat-configThis creates config/google-chat.php in your application.
Quick Start Example
Add GoogleChatChannel::class to your notification's via() method:
php
namespace App\Notifications;
use Illuminate\Notifications\Notification;
use NotificationChannels\GoogleChat\GoogleChatChannel;
use NotificationChannels\GoogleChat\GoogleChatMessage;
class ServerAlertNotification extends Notification
{
public function via(object $notifiable): array
{
return [
GoogleChatChannel::class,
];
}
public function toGoogleChat(object $notifiable): GoogleChatMessage
{
return GoogleChatMessage::create()
->text('Server alert: High CPU utilisation detected!')
->bold('Host:')
->line('web-prod-01');
}
}Documentation Sitemap
Explore detailed practical guides for every aspect of the package:
- Configuration & Transports: Set up default space aliases, webhook URLs, test space overrides, and Service Account REST drivers.
- Service Account Setup: Step-by-step guide to setting up Google Cloud Service Accounts, Chat Apps, and JSON key files.
- Simple Messages: Format text with fluent helpers, convert GitHub or GitLab Markdown, and mention users.
- Card Messages: Build Cards v2 structures with headers, sections, and closure builders.
- Widgets & Components: Explore
DecoratedText,ButtonList,Divider,Columns, and icons. - Threading & Message Updates: Reply to existing threads and update/patch previously posted cards.