PHPackages                             aon4o/laravel-rocket-chat-notification-channel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. aon4o/laravel-rocket-chat-notification-channel

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

aon4o/laravel-rocket-chat-notification-channel
==============================================

Rocket.Chat REST API Notifications channel for Laravel

221PHPCI passing

Since May 20Pushed 11mo agoCompare

[ Source](https://github.com/aon4o/laravel-rocket-chat-notification-channel)[ Packagist](https://packagist.org/packages/aon4o/laravel-rocket-chat-notification-channel)[ RSS](/packages/aon4o-laravel-rocket-chat-notification-channel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Rocket.Chat REST API Laravel Notifications Channel
==================================================

[](#rocketchat-rest-api-laravel-notifications-channel)

[![Packagist Version](https://camo.githubusercontent.com/2192016ba89d419aa0e190fc9127df692ea224f2ddf2022888e8c825cd3d74c3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616f6e346f2f6c61726176656c2d726f636b65742d636861742d6e6f74696669636174696f6e2d6368616e6e656c3f7374796c653d666c61742d737175617265266c6f676f3d7061636b6167697374)](https://camo.githubusercontent.com/2192016ba89d419aa0e190fc9127df692ea224f2ddf2022888e8c825cd3d74c3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616f6e346f2f6c61726176656c2d726f636b65742d636861742d6e6f74696669636174696f6e2d6368616e6e656c3f7374796c653d666c61742d737175617265266c6f676f3d7061636b6167697374)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/0b56648f9216938e517a5bfaceb06b53a9f0cbc1a9318a8d0695c2e01dfc96c5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616f6e346f2f6c61726176656c2d726f636b65742d636861742d6e6f74696669636174696f6e2d6368616e6e656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aon4o/laravel-rocket-chat-notification-channel)

Introduction
------------

[](#introduction)

This package makes it easy to send notifications using [RocketChat](https://rocket.chat/) with Laravel 5.6+. The package uses the REST API of RocketChat to send messages to channels instead of using the Webhooks method.

Contents
--------

[](#contents)

- [Installation](#installation)
    - [Setting up the RocketChat service](#setting-up-the-rocketchat-service)
- [Usage](#usage)
    - [Available Message methods](#available-message-methods)
- [Testing](#testing)
- [Linting](#linting)
- [Security](#security)
- [Credits](#credits)
- [Change log](#change-log)
- [License](#license)

Installation
------------

[](#installation)

You can install the package via composer:

```
$ composer require aon4o/laravel-rocket-chat-notification-channel
```

### Setting up the RocketChat service

[](#setting-up-the-rocketchat-service)

In order to send message to RocketChat channels, you need to obtain [Webhook](https://rocket.chat/docs/administrator-guides/integrations#how-to-create-a-new-incoming-webhook).

Add your RocketChat API server's base url, incoming Webhook Token and optionally the default channel to your `config/services.php`:

```
// config/services.php
...
'rocketchat' => [
     // Base URL for RocketChat API server (https://your.rocketchat.server.com)
    'url' => env('ROCKETCHAT_URL'),
    'token' => env('ROCKETCHAT_TOKEN'),
    // Default user id (optional)
    'user_id' => env('ROCKETCHAT_USER_ID'),
    // Default channel (optional)
    'channel' => env('ROCKETCHAT_CHANNEL'),
],
...
```

Usage
-----

[](#usage)

You can use the channel in your `via()` method inside the notification:

```
use Illuminate\Notifications\Notification;
use NotificationChannels\RocketChat\RocketChatMessage;
use NotificationChannels\RocketChat\RocketChatChannel;

class TaskCompleted extends Notification
{
    public function via($notifiable): array
    {
        return [
            RocketChatChannel::class,
        ];
    }

    public function toRocketChat($notifiable): RocketChatMessage
    {
        return RocketChatMessage::create('Test message')
            ->to('channel_name') // optional if set in config
            ->from('webhook_token'); // optional if set in config
    }
}
```

In order to let your notification know which RocketChat channel you are targeting, add the `routeNotificationForRocketChat` method to your Notifiable model:

```
public function routeNotificationForRocketChat(): string
{
    return 'channel_name';
}
```

### Available methods

[](#available-methods)

`from()`: Sets the sender's access token.

`to()`: Specifies the channel id to send the notification to (overridden by `routeNotificationForRocketChat` if empty).

`content()`: Sets a content of the notification message. Supports GitHub flavored Markdown.

`alias()`: This will cause the message’s name to appear as the given alias, but your username will still display.

`emoji()`: This will make the avatar on this message be an emoji. (e.g. ':see\_no\_evil:')

`avatar()`: This will make the avatar use the provided image url.

`attachment()`: This will add an single attachment.

`attachments()`: This will add multiple attachments.

`clearAttachments()`: This will remove all attachments.

### Adding Attachment

[](#adding-attachment)

There are several ways to add one or more attachments to a message

```
public function toRocketChat($notifiable)
{
    return RocketChatMessage::create('Test message')
        ->to('channel_name') // optional if set in config
        ->from('webhook_token') // optional if set in config
        ->attachments([
            RocketChatAttachment::create()->imageUrl('test'),
            RocketChatAttachment::create(['image_url' => 'test']),
            new RocketChatAttachment(['image_url' => 'test']),
            [
                'image_url' => 'test'
            ]
        ]);
}
```

#### Available methods

[](#available-methods-1)

`color()`: The color you want the order on the left side to be, any value background-css supports.

`text()`: The text to display for this attachment, it is different than the message’s text.

`timestamp()`: Displays the time next to the text portion. ISO8601 Zulu Date or instance of any `\DateTime`

`thumbnailUrl()`: An image that displays to the left of the text, looks better when this is relatively small.

`messageLink()`: Only applicable if the ts is provided, as it makes the time clickable to this link.

`collapsed()`: Causes the image, audio, and video sections to be hiding when collapsed is true.

`author($name, $link, $icon)`: shortcut for author methods

`authorName()`: Name of the author.

`authorLink()`: Providing this makes the author name clickable and points to this link.

`authorIcon()`: Displays a tiny icon to the left of the Author’s name.

`title()`: Title to display for this attachment, displays under the author.

`titleLink()`: Providing this makes the title clickable, pointing to this link.

`titleLinkDownload()`: When this is true, a download icon appears and clicking this saves the link to file.

`imageUrl()`: The image to display, will be “big” and easy to see.

`audioUrl()`: Audio file to play, only supports what html audio does.

`videoUrl()`: Video file to play, only supports what html video does.

`fields()`: An array of Attachment Field Objects.

```
[
    [
        'short' => false, // Whether this field should be a short field. Default: false
        'title' => 'Title 1', //The title of this field. Required
        'value' => 'Value 1' // The value of this field, displayed underneath the title value. Required
    ],
    [
        'short' => true,
        'title' => 'Title 2',
        'value' => 'Value 2'
    ],

];
```

Testing
-------

[](#testing)

```
$ composer test
```

Linting
-------

[](#linting)

```
$ composer lint
```

Security
--------

[](#security)

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

Credits
-------

[](#credits)

- [Anton Komarev](https://komarev.com)
- [Nicholas](https://github.com/Funfare)
- [atymic](https://github.com/atymic)
- [All Contributors](../../contributors)

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/927acab553d76e07d6d2e2081b7eb6bea657b9550901a036f647b6a7f5af5c66?d=identicon)[aon4o](/maintainers/aon4o)

---

Top Contributors

[![antonkomarev](https://avatars.githubusercontent.com/u/1849174?v=4)](https://github.com/antonkomarev "antonkomarev (21 commits)")[![aon4o](https://avatars.githubusercontent.com/u/48474870?v=4)](https://github.com/aon4o "aon4o (15 commits)")[![atymic](https://avatars.githubusercontent.com/u/50683531?v=4)](https://github.com/atymic "atymic (5 commits)")[![Funfare](https://avatars.githubusercontent.com/u/13119997?v=4)](https://github.com/Funfare "Funfare (3 commits)")[![Krishan19](https://avatars.githubusercontent.com/u/1979578?v=4)](https://github.com/Krishan19 "Krishan19 (1 commits)")[![thecaliskan](https://avatars.githubusercontent.com/u/13554944?v=4)](https://github.com/thecaliskan "thecaliskan (1 commits)")

### Embed Badge

![Health badge](/badges/aon4o-laravel-rocket-chat-notification-channel/health.svg)

```
[![Health](https://phpackages.com/badges/aon4o-laravel-rocket-chat-notification-channel/health.svg)](https://phpackages.com/packages/aon4o-laravel-rocket-chat-notification-channel)
```

###  Alternatives

[tijsverkoyen/css-to-inline-styles

CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.

5.8k505.3M227](/packages/tijsverkoyen-css-to-inline-styles)[minishlink/web-push

Web Push library for PHP

1.9k12.0M53](/packages/minishlink-web-push)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[spatie/url-signer

Generate a url with an expiration date and signature to prevent unauthorized access

4422.3M16](/packages/spatie-url-signer)[mattketmo/email-checker

Throwaway email detection library

2742.0M5](/packages/mattketmo-email-checker)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
