Download the PHP package laravel-notification-channels/google-chat without Composer

On this page you can find all versions of the php package laravel-notification-channels/google-chat. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package google-chat

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Total Downloads

Google Chat - Laravel Notification Channel

This package makes it easy to send notifications using Google Chat , (formerly known as Hangouts Chat) with Laravel 9.x

``

For Laravel 8.x, please use version 1.x of this package.

Contents

Installation

The Google Chat notification channel can be installed easily via Composer:

`

Generating a Webhook

This package makes use of Google Chat's convenient 'Webhooks' feature, which allows for quick and easy setup.

You can learn how to create a room, and generate a new Webhook on Google's documentation.

Throughout Google's own documentation, the term 'space' is used to reference conversations generally across Google Chat, whether that be a one-on-one chat between co-workers, or a 'room' with conversations between multiple people.

Although this package only has the ability to send messages into 'rooms', we still refer to a room as a 'space' for consistency between this package's documentation, and Google's.

Configuring & Using Webhooks in Your Application

Firstly, let's publish the configuration file used by the Google Chat notification channel into your application, so that we can start configuring our webhooks:

`

Default Room

If we only have a single room / webhook we want to post into, we can simply configure the space key which defines the default conversation notifications sent via the Google Chat channel will be posted to.

``

Notifications that have not otherwise been directed to another room will now be sent to this default space.

CAUTION! If your application sends sensitive notifications via Google Chat, we recommend you configure the space key to NULL, so that notifications must be explicitly directed to an endpoint.

Alternate Rooms (Preferred)

You can also define alternate webhooks under the spaces (plural) key, and reference these more easily throughout your application:

``

You can now direct notifications to one of these configured rooms by using the relevant key anywhere you can route notifications, like:

``

Explicit Webhook Routing

If needed, you can route notifications to explicit webhooks in all the same places listed above. This isn't the preferred method, however, as it gives you less flexibility should you ever need to change a webhook.

``

Usage

In order to send a notification via the Google Chat channel, you'll need to specify the channel in the via() method of your notification:

``

If you haven't already, make sure you understand how notification classes are constructed.

Google Chat messages have two formats: Simple Messages, and Card Messages. This package allows you to construct both.

Simple Messages

Simple messages can be created easily using a NotificationChannels\GoogleChat\GoogleChatMessage instance directly, and returned in your notification class like so:

``

Simple messages can also contain basic formatting:

``

Card Messages

Google Chat cards are more complex pieces of UI that can display organized information to the recipient. Cards are added to a GoogleChatMessage instance, and can be used in combination with a simple message.

The structure of cards in this package closely resembles the actual data format sent to the webhook endpoint. For this reason, it's worth checking out how cards are structured.

``

Visual learner? Us too. Here's a visual overview of the card structure:

`

API Overview

Google Chat Message

Namespace: NotificationChannels\GoogleChat\GoogleChatMessage

The GoogleChatMessage class encompasses an entire message that will be sent to the Google Chat room.

Card Layout

The layout is split into two concepts: The card, and the section. The card can be thought of as the container, whilst the sections can be thought of as rows within the card itself. The card can have a complex, overarching header, whilst each section can contain a simple text based header.

You can add multiple sections to a card, in order to group related pieces of information.

Card

Namespace: NotificationChannels\GoogleChat\Card

The Card class represents the top level layout definition for a Card UI to be sent in a message. Cards define one or more sections, and may optionally define header information

Section

Namespace: NotificationChannels\GoogleChat\Section

The Section class defines the intermediary layout definition of a card. From a UI perspective, it groups related widgets.

Widgets

Widgets are the meaningful pieces of UI displayed throughout a single card. There are different types of widgets, in order to display information more appropriately to the user.

Widgets are added to a section, and a section can contain multiple widgets of various types.

Text Paragraph

Namespace: NotificationChannels\GoogleChat\Widgets\TextParagraph

The TextParagraph widget defines rich text. This widget can define more complex text formats than permissible in a simple message.

Key Value

Namespace: NotificationChannels\GoogleChat\Widgets\KeyValue

The KeyValue widget defines a table like element that can segment information and provide an external click through

Image

Namespace: NotificationChannels\GoogleChat\Widgets\Image

The Image widget defines a simple image to be displayed in the card. Optionally, a click through URL can be configured for when a user clicks/taps on the image.

Buttons

Namespace: NotificationChannels\GoogleChat\Widgets\Buttons

The Buttons widget acts as a container for one or more buttons, laid out horizontally. This widget accepts instances of NotificationChannels\GoogleChat\Components\Button\AbstractButton and can accept buttons of different types.

Components

Components are structures that are nestled within widgets. For simplicity, the Google Chat notification channel only supports button components.

Both the Text Button and Image Button can be nested within the Buttons widget, as well as in the button properties of the KeyValue and ImageWidget.

Text Button

Namespace: NotificationChannels\GoogleChat\Components\Button\TextButton

The TextButton defines a simple text button, and can be accepted anywhere that an AbstractButton is accepted.

Image Button

Namespace: NotificationChannels\GoogleChat\Components\Button\ImageButton

The ImageButton defines a clickable icon or image, and can be accepted anywhere that an AbstractButton is accepted. The icon can either be a default icon (one of the constants defined in NotificationChannels\GoogleChat\Enums\Icon) or an external image url.

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

The test suite also includes one end-to-end test. In order for this test to pass, a GOOGLE_CHAT_TEST_SPACE environment variable should be set, containing a webhook to a test room.

Alternatively, you can exclude this test with PHPUnit during local development:

`

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of google-chat with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
guzzlehttp/guzzle Version ^6.3 || ^7.0
illuminate/notifications Version ^9.0.2 || ^10.0 || ^11.0
illuminate/support Version ^9.0.2 || ^10.0 || ^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package laravel-notification-channels/google-chat contains the following files

Loading the files please wait ....