PHPackages                             waapi/waapi-laravel-sdk - 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. waapi/waapi-laravel-sdk

ActiveLibrary

waapi/waapi-laravel-sdk
=======================

WaAPI Laravel Package

v1.1.0(1y ago)94.4k↓33.3%7MITPHPPHP ^8.1CI failing

Since Sep 6Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/WaAPIapp/waapi-laravel-sdk)[ Packagist](https://packagist.org/packages/waapi/waapi-laravel-sdk)[ Docs](https://github.com/WaAPIapp/waapi-laravel-sdk)[ RSS](/packages/waapi-waapi-laravel-sdk/feed)WikiDiscussions master Synced 1mo ago

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

WaAPI Laravel Package
=====================

[](#waapi-laravel-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/e0d6a64dee7f38e3cf318201ca58c823ceef8ac307f97bfc53668e7d42b4abc5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77616170692f77616170692d6c61726176656c2d73646b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/waapi/waapi-laravel-sdk)[![Total Downloads](https://camo.githubusercontent.com/061569b5c040697dc7eef86ba566916d21ccbdb9c95efae7e6bc37a2f110e50b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f77616170692f77616170692d6c61726176656c2d73646b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/waapi/waapi-laravel-sdk)

Laravel Package to use with [waapi.app](https://waapi.app).

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

[](#installation)

You can install the package via composer:

```
composer require waapi/waapi-laravel-sdk
```

You can publish the config file with:

```
php artisan vendor:publish --tag="waapi-config"
```

This is the contents of the published config file:

```
return [
    'api_token' => env('WAAPI_API_TOKEN'),
    'instance_id' => env('WAAPI_INSTANCE_ID'),
];
```

Please adapt your .env with your instance ID and Token which can be obtained from your [API Tokens](https://waapi.app/user/api-tokens)

Replace with your token and your instance ID

```
WAAPI_API_TOKEN=abcdefghijkl123456789
WAAPI_INSTANCE_ID=123
```

Usage
-----

[](#usage)

```
$waAPI = new WaAPI\WaAPI();
$waAPI->sendMessage('1222333444@c.us', 'Hello there!');
```

### Webhook Listener

[](#webhook-listener)

The package provides a webhooks endpoint to handle incoming webhooks. Simply update your instance with the event types you want to listen to and the endpoint.

Make sure your app is running on a publicly availabel domain. Locally the webhooks won't work.

```
app(WaAPI::class)->updateInstance(
    route('waapi.webhooks'),
    [
        EventType::MESSAGE->value,
        EventType::QR->value
    ]
);
```

Create an event listener to listen on the webhook events

new Message example:

```
php artisan make:listener WaAPIMessageListener --event=\\WaAPI\\WaAPI\\Events\\MessageEvent
```

QR Code change example:

```
php artisan make:listener WaAPIQrCodeListener --event=\\WaAPI\\WaAPI\\Events\\QrEvent
```

Register your listener in `app/Providers/EventServiceProvider.php` if autodiscovery for events is disabled

```
    use App\Listeners\WaAPIInstanceReadyListener;
    use App\Listeners\WaAPIMessageListener;
    use WaAPI\WaAPI\Events\MessageEvent;
    use WaAPI\WaAPI\Events\QrEvent;

    [...]

    protected $listen = [
        MessageEvent::class => [
            WaAPIMessageListener::class,
        ],
        QrEvent::class => [
            WaAPIQrCodeListener::class,
        ],
    ];
```

Example for `WaAPIMessageListener`:

```
