PHPackages                             masrodjie/laravel-whatspie - 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. masrodjie/laravel-whatspie

ActiveLibrary

masrodjie/laravel-whatspie
==========================

Laravel Whatspie is a Laravel package that simplifies integration with the Whatspie API

v1.0.0(1mo ago)04↓100%MITPHPPHP ^8.2CI passing

Since Apr 8Pushed 3w agoCompare

[ Source](https://github.com/masrodjie/laravel-whatspie)[ Packagist](https://packagist.org/packages/masrodjie/laravel-whatspie)[ Docs](https://github.com/masrodjie/laravel-whatspie)[ GitHub Sponsors](https://github.com/MasRodjie)[ RSS](/packages/masrodjie-laravel-whatspie/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (12)Versions (3)Used By (0)

Laravel Whatspie
================

[](#laravel-whatspie)

[![Latest Version on Packagist](https://camo.githubusercontent.com/588150af1c02bc47989989853669dc3eba1a79bf63918ae48a246222784c333a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6173726f646a69652f6c61726176656c2d77686174737069652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/masrodjie/laravel-whatspie)[![GitHub Tests Action Status](https://camo.githubusercontent.com/f3a5e468d079eac6f94c353dce0c9c6f0664f5660db5152ebf86fbef9d914784/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d6173726f646a69652f6c61726176656c2d77686174737069652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/masrodjie/laravel-whatspie/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/4339c5421cec2d87c7baf7d44ebdcb4aa644847b8685f2d1ac863bf2738410aa/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d6173726f646a69652f6c61726176656c2d77686174737069652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/masrodjie/laravel-whatspie/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/66d837486c204654f9f8c3aa01f86f6a04d25f5d17ba4a46d27b16e1beedaa0f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6173726f646a69652f6c61726176656c2d77686174737069652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/masrodjie/laravel-whatspie)

A Laravel package that provides a fluent interface for sending WhatsApp messages through the [Whatspie](https://whatspie.com) API. This package allows you to send text messages, images, files, and location messages, as well as receive webhooks for incoming messages.

Features
--------

[](#features)

- Send text messages with optional typing indicator
- Send images with captions
- Send files with custom filenames and MIME types
- Send location messages with name and address
- Handle incoming webhooks with typed events
- Automatic file upload to configured storage
- Fluent, expressive API

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

[](#installation)

You can install the package via composer:

```
composer require masrodjie/laravel-whatspie
```

You can publish the config file with:

```
php artisan vendor:publish --tag="laravel-whatspie-config"
```

This is the default contents of the published config file:

```
return [
    /*
    |--------------------------------------------------------------------------
    | Whatspie API Token
    |--------------------------------------------------------------------------
    |
    | Your Whatspie API token for authentication.
    | Get it from https://whatspie.com/dashboard
    |
    */

    'api_token' => env('WHATSPIE_API_TOKEN'),

    /*
    |--------------------------------------------------------------------------
    | Device Number
    |--------------------------------------------------------------------------
    |
    | Your registered WhatsApp device number in international format
    | without the + symbol (e.g., 6281234567890).
    |
    */

    'device' => env('WHATSPIE_DEVICE'),

    /*
    |--------------------------------------------------------------------------
    | Webhook Configuration
    |--------------------------------------------------------------------------
    |
    | Configure the webhook endpoint for receiving incoming messages.
    |
    */

    'webhook' => [
        'enabled' => env('WHATSPIE_WEBHOOK_ENABLED', true),
        'path' => env('WHATSPIE_WEBHOOK_PATH', '/whatspie/webhook'),
        'secret' => env('WHATSPIE_WEBHOOK_SECRET'),
    ],

    /*
    |--------------------------------------------------------------------------
    | Storage Configuration
    |--------------------------------------------------------------------------
    |
    | Configure where local files are uploaded before sending to Whatspie.
    | The disk must be publicly accessible.
    |
    */

    'storage' => [
        'disk' => env('WHATSPIE_STORAGE_DISK', 'public'),
        'path' => env('WHATSPIE_STORAGE_PATH', 'whatspie'),
    ],
];
```

Configuration
-------------

[](#configuration)

Add the following environment variables to your `.env` file:

```
WHATSPIE_API_TOKEN=your_api_token_here
WHATSPIE_DEVICE=6281234567890

# Optional - Webhook configuration
WHATSPIE_WEBHOOK_ENABLED=true
WHATSPIE_WEBHOOK_PATH=/whatspie/webhook
WHATSPIE_WEBHOOK_SECRET=your_webhook_secret

# Optional - Storage configuration
WHATSPIE_STORAGE_DISK=public
WHATSPIE_STORAGE_PATH=whatspie
```

### Getting Your API Token

[](#getting-your-api-token)

1. Sign up or log in at
2. Navigate to the dashboard
3. Copy your API token
4. Register your WhatsApp device number

Usage
-----

[](#usage)

### Sending Messages

[](#sending-messages)

The package provides a fluent API for sending messages through the `Whatspie` facade.

#### Text Messages

[](#text-messages)

Send a simple text message:

```
use MasRodjie\LaravelWhatspie\Facades\Whatspie;
use MasRodjie\LaravelWhatspie\Contracts\WhatspieClient;

$result = Whatspie::to('6281234567890')
    ->using(app(WhatspieClient::class))
    ->text('Hello from Laravel!')
    ->send();

if ($result->successful()) {
    echo "Message sent! ID: " . $result->id();
}
```

Send a text message with typing indicator:

```
$result = Whatspie::to('6281234567890')
    ->using(app(WhatspieClient::class))
    ->text('Hello from Laravel!')
    ->withTyping()
    ->send();
```

#### Image Messages

[](#image-messages)

Send an image from a URL:

```
$result = Whatspie::to('6281234567890')
    ->using(app(WhatspieClient::class))
    ->image('https://example.com/photo.jpg')
    ->send();
```

Send an image with a caption:

```
$result = Whatspie::to('6281234567890')
    ->using(app(WhatspieClient::class))
    ->image('https://example.com/photo.jpg')
    ->caption('Check this out!')
    ->send();
```

Upload and send a local image:

```
use MasRodjie\LaravelWhatspie\Messaging\FileUploader;

$uploader = new FileUploader(
    config('whatspie.storage.disk'),
    config('whatspie.storage.path')
);

$result = Whatspie::to('6281234567890')
    ->using(app(WhatspieClient::class), $uploader)
    ->image('/path/to/local/image.jpg')
    ->caption('Local image')
    ->send();
```

#### File Messages

[](#file-messages)

Send a file from a URL:

```
$result = Whatspie::to('6281234567890')
    ->using(app(WhatspieClient::class))
    ->file('https://example.com/document.pdf', 'application/pdf')
    ->send();
```

Send a file with a custom filename:

```
$result = Whatspie::to('6281234567890')
    ->using(app(WhatspieClient::class))
    ->file('https://example.com/document.pdf', 'application/pdf')
    ->fileName('Monthly Report.pdf')
    ->send();
```

Upload and send a local file:

```
use Illuminate\Http\UploadedFile;
use MasRodjie\LaravelWhatspie\Messaging\FileUploader;

$uploader = new FileUploader(
    config('whatspie.storage.disk'),
    config('whatspie.storage.path')
);

// From a file path
$result = Whatspie::to('6281234567890')
    ->using(app(WhatspieClient::class), $uploader)
    ->file('/path/to/document.pdf', 'application/pdf')
    ->send();

// From an UploadedFile (e.g., form upload)
$result = Whatspie::to('6281234567890')
    ->using(app(WhatspieClient::class), $uploader)
    ->file($uploadedFile, 'application/pdf')
    ->send();
```

#### Location Messages

[](#location-messages)

Send a location:

```
$result = Whatspie::to('6281234567890')
    ->using(app(WhatspieClient::class))
    ->location(-6.2088, 106.8456)
    ->send();
```

Send a location with name and address:

```
$result = Whatspie::to('6281234567890')
    ->using(app(WhatspieClient::class))
    ->location(-6.2088, 106.8456)
    ->name('Monas')
    ->address('Jakarta, Indonesia')
    ->send();
```

### Handling Results

[](#handling-results)

The `send()` method returns a `Result` object:

```
$result = Whatspie::to('6281234567890')
    ->using(app(WhatspieClient::class))
    ->text('Hello!')
    ->send();

// Check if successful
if ($result->successful()) {
    // Get message ID
    $messageId = $result->id();
}

// Check if failed
if ($result->failed()) {
    // Get error message
    $error = $result->error();
    $code = $result->errorCode();
}

// Get full response data
$data = $result->data();
```

### Webhooks

[](#webhooks)

The package automatically registers a webhook route when enabled in the configuration. Webhooks are dispatched as Laravel events that you can listen to in your application.

#### Available Events

[](#available-events)

EventDescription`WebhookReceived`Base event for all incoming webhooks`TextMessageReceived`Fired when a text message is received`ImageMessageReceived`Fired when an image message is received`AudioMessageReceived`Fired when an audio message is received`FileMessageReceived`Fired when a file/document message is received`ContactMessageReceived`Fired when a contact message is received`LocationMessageReceived`Fired when a location message is received#### Event Listeners

[](#event-listeners)

Create an event listener. For example, using `php artisan make:listener`:

```
php artisan make:listener HandleIncomingWhatsAppMessage
```

In your `AppServiceProvider` or a dedicated service provider:

```
use Illuminate\Support\Facades\Event;
use MasRodjie\LaravelWhatspie\Events\TextMessageReceived;
use MasRodjie\LaravelWhatspie\Events\ImageMessageReceived;
use App\Listeners\HandleIncomingWhatsAppMessage;

protected $listen = [
    TextMessageReceived::class => [
        HandleIncomingWhatsAppMessage::class,
    ],
    ImageMessageReceived::class => [
        HandleIncomingWhatsAppMessage::class,
    ],
];
```

Example listener:

```
namespace App\Listeners;

use MasRodjie\LaravelWhatspie\Events\TextMessageReceived;

class HandleIncomingWhatsAppMessage
{
    public function handle(TextMessageReceived $event)
    {
        $from = $event->fromUser();
        $message = $event->message();
        $timestamp = $event->timestamp();

        // Process the incoming message
        // Store in database, trigger auto-reply, etc.
    }
}
```

#### Event Methods

[](#event-methods)

**TextMessageReceived:**

- `fromUser()` - Sender's phone number
- `message()` - Message text content
- `timestamp()` - Message timestamp
- `messageId()` - Unique message ID
- `isForwarded()` - Whether message was forwarded
- `isBroadcast()` - Whether message was a broadcast

**ImageMessageReceived:**

- `fileUrl()` - URL to the image
- `caption()` - Image caption (if any)
- Inherits all methods from `WebhookReceived`

**AudioMessageReceived:**

- `fileUrl()` - URL to the audio file
- `duration()` - Audio duration in seconds (if available)
- Inherits all methods from `WebhookReceived`

**FileMessageReceived:**

- `fileUrl()` - URL to the file
- `fileName()` - File name (if available)
- Inherits all methods from `WebhookReceived`

**ContactMessageReceived:**

- `contacts()` - Array of contact data
- Inherits all methods from `WebhookReceived`

**LocationMessageReceived:**

- `latitude()` - Latitude coordinate
- `longitude()` - Longitude coordinate
- `name()` - Location name (if available)
- `address()` - Location address (if available)
- Inherits all methods from `WebhookReceived`

**WebhookReceived (base event):**

- `from()` - Sender's phone number
- `payload()` - Raw webhook payload array

#### Webhook Security

[](#webhook-security)

For production use, you should verify webhook requests. Configure a webhook secret in your `.env`:

```
WHATSPIE_WEBHOOK_SECRET=your_random_secret_string
```

Then create middleware to verify incoming webhook signatures.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Arnas MasRodjie](https://github.com/masrodjie)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance94

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90% of commits — single point of failure

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

Unknown

Total

1

Last Release

34d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d281edae472fa450c125131785b4552900e15f09f6412ce9c7045876cf029e54?d=identicon)[masrodjie](/maintainers/masrodjie)

---

Top Contributors

[![masrodjie](https://avatars.githubusercontent.com/u/2186593?v=4)](https://github.com/masrodjie "masrodjie (27 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

laravelMasRodjielaravel-whatspie

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/masrodjie-laravel-whatspie/health.svg)

```
[![Health](https://phpackages.com/badges/masrodjie-laravel-whatspie/health.svg)](https://phpackages.com/packages/masrodjie-laravel-whatspie)
```

###  Alternatives

[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[spatie/laravel-prometheus

Export Laravel metrics to Prometheus

2651.3M6](/packages/spatie-laravel-prometheus)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[musahmusah/laravel-multipayment-gateways

A Laravel Package that makes implementation of multiple payment Gateways endpoints and webhooks seamless

852.2k1](/packages/musahmusah-laravel-multipayment-gateways)

PHPackages © 2026

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