PHPackages                             silasrm/chat-api - 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. silasrm/chat-api

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

silasrm/chat-api
================

Chat API Notifications channel for Laravel 5.6+

v0.1.24(4y ago)573MITPHPPHP ^7.1.0CI failing

Since Jun 1Pushed 4y ago1 watchersCompare

[ Source](https://github.com/silasrm/chat-api)[ Packagist](https://packagist.org/packages/silasrm/chat-api)[ Docs](https://github.com/silasrm/chat-api)[ RSS](/packages/silasrm-chat-api/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (3)Dependencies (6)Versions (10)Used By (0)

Chat API Laravel Notifications Channel
======================================

[](#chat-api-laravel-notifications-channel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3238aaaf4cbc39e3834b9205b1545556228760036991a6258b6950910473c0bf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73696c6173726d2f636861742d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/silasrm/chat-api)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

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

[](#introduction)

This package makes it easy to send notifications using [Chat API](https://chat-api.com/) with Laravel 5.6+.

First of all: contract or get your free demo account and setup your Whatsapp number: [Whatsapp authentication process](https://chat-api.com/img/whatsapp_auth_en.gif)

Contents
--------

[](#contents)

- [Installation](#installation)
    - [Setting up the Chat API service](#setting-up-the-chat-api-service)
- [Usage](#usage)
    - [Available Message methods](#available-message-methods)
- [Changelog](#changelog)
- [Testing](#testing)
- [Security](#security)
- [Contributing](#contributing)
- [Credits](#credits)
- [Change log](#changelog)
- [License](#license)

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

[](#installation)

You can install the package via composer:

```
$ composer require silasrm/chat-api
```

### Setting up the Chat API service

[](#setting-up-the-chat-api-service)

In order to send message to Whatsapp using Chat API, you need to authenticate your number using [QR Code](https://chat-api.com/en/sdk/php.html#/instance/getQRCode) on API.

Add your Chat API url and token to your `config/services.php`:

```
// config/services.php
...
'chatapi' => [
     // Like: https://euXXXX.chat-api.com/instanceYYYYY/
    'url' => env('CHATAPI_URL'),
    'token' => env('CHATAPI_TOKEN'),
],
...
```

Usage
-----

[](#usage)

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

```
use Illuminate\Notifications\Notification;
use Silasrm\ChatApi\ChatApiMessage;
use Silasrm\ChatApi\ChatApiChannel;

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

    public function toRocketChat($notifiable): ChatApiMessage
    {
        return ChatApiMessage::create('John Doe create a new order with value US$ 50.0')
            ->to('NNNNNNNNNNNNNN'); // Phone number with country code
    }
}
```

In order to let your notification know which Chat API phone number you are targeting, add the `routeNotificationForChatApi` method to your Notifiable model:

```
public function routeNotificationForChatApi(): string
{
    return $this->phone;
}
```

### Available methods

[](#available-methods)

`to()`: Specifies the phone number to send the notification to (overridden by `routeNotificationForChatApi` if empty).

`content()`: Sets a content of the notification message. Supports pure text, UTF-8 or UTF-16 string with emoji.

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

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

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

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

### Adding Attachment

[](#adding-attachment)

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

```
public function toChatApi($notifiable)
{
    return ChatApiMessage::create('Test message')
        ->to('NNNNNNNNNNNNNN') // Phone number with country code
        ->attachments([
            // url (for remote) or path (for local), file
            ChatApiAttachment::create()->url('test'),
            ChatApiAttachment::create(['url' => 'test']),
            new ChatApiAttachment(['url' => 'test']),
            ['url' => 'test']
        ]);
}
```

#### Available methods

[](#available-methods-1)

`caption()`: The text caption for this attachment.

`filename()`: Name of this file. If empty, use the original name of file.

```
[
    [
        'caption' => 'Caption of file',
        'filename' => 'payment.xlsx',
    ]
];
```

### Adding Link

[](#adding-link)

There are several ways to add one ore more links to a message

```
public function toChatApi($notifiable)
{
    return ChatApiMessage::create('Test message')
        ->to('NNNNNNNNNNNNNN') // Phone number with country code
        ->links([
            ChatApiLink::create()
                ->url('https://wikimedia.org/nature')
                ->title('All about Nature')
                ->previewImage('https://upload.wikimedia.org/wikipedia/ru/3/33/NatureCover2001.jpg'),
            ChatApiLink::create([
                'url' => 'https://wikimedia.org/nature',
                'title' => 'All about Nature',
                'previewImage' => 'https://upload.wikimedia.org/wikipedia/ru/3/33/NatureCover2001.jpg',
            ]),
            new ChatApiLink([
                'url' => 'https://wikimedia.org/nature',
                'title' => 'All about Nature',
                'previewImage' => 'https://upload.wikimedia.org/wikipedia/ru/3/33/NatureCover2001.jpg',
            ]),
            [
                'url' => 'https://wikimedia.org/nature',
                'title' => 'All about Nature',
                'previewImage' => 'https://upload.wikimedia.org/wikipedia/ru/3/33/NatureCover2001.jpg',
            ]
        ]);
}
```

#### Available methods

[](#available-methods-2)

`title()`: The title of link. Required.

`previewImage()`: The image url/path of link preview. Required.

`description()`: The description for this link.

```
[
    [
        'title' => 'All about Nature',
        'previewImage' => 'https://upload.wikimedia.org/wikipedia/ru/3/33/NatureCover2001.jpg',
        'description' => 'See that!',
    ]
];
```

Changelog
---------

[](#changelog)

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

Testing
-------

[](#testing)

```
$ vendor/bin/phpunit
```

Security
--------

[](#security)

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

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Silas Ribas](http://silasribas.com.br)

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

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~60 days

Recently: every ~91 days

Total

9

Last Release

1693d ago

PHP version history (2 changes)v0.1.10PHP ^7.2.0

v0.1.24PHP ^7.1.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4303414783efee854cef1390ccd9aa197b6d6b9bcc6623cd475bba87fdcbfc66?d=identicon)[silasrm](/maintainers/silasrm)

---

Top Contributors

[![silasrm](https://avatars.githubusercontent.com/u/197187?v=4)](https://github.com/silasrm "silasrm (25 commits)")[![antonkomarev](https://avatars.githubusercontent.com/u/1849174?v=4)](https://github.com/antonkomarev "antonkomarev (20 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 (1 commits)")

---

Tags

laravelnotificationschatwhatsappChat-APInotification-channel

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/silasrm-chat-api/health.svg)

```
[![Health](https://phpackages.com/badges/silasrm-chat-api/health.svg)](https://phpackages.com/packages/silasrm-chat-api)
```

###  Alternatives

[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[laravel-notification-channels/discord

Laravel notification driver for Discord.

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

Laravel FCM (Firebase Cloud Messaging) Notification Channel

210964.1k1](/packages/benwilkins-laravel-fcm-notification)[laravel-notification-channels/rocket-chat

Rocket.Chat Notifications channel for Laravel 5.6+

1345.5k](/packages/laravel-notification-channels-rocket-chat)

PHPackages © 2026

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