fahrigunadi/whatsapp

This is my package whatsapp

Fund package maintenance!
Fahri Gunadi

Installs: 67

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 1

pkg:composer/fahrigunadi/whatsapp

v1.1.1 2025-07-11 06:43 UTC

README

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

Installation

You can install the package via composer:

composer require fahrigunadi/whatsapp

You can publish the config file with:

php artisan vendor:publish --tag="whatsapp-config"

This is the contents of the published config file:

return [
    /**
     * --------------------------------------------------------------------------
     * WhatsApp Driver
     * --------------------------------------------------------------------------
     *
     * This option defines which driver implementation to use for sending
     * WhatsApp messages. You may configure your own custom driver or use
     * one of the available drivers such as 'aldinokemal', 'wuzapi', etc.
     *
     * Supported: "aldinokemal", "wuzapi"
     */
    'driver' => env('WHATSAPP_DRIVER', 'aldinokemal'),

    /**
     * --------------------------------------------------------------------------
     * WhatsApp Username
     * --------------------------------------------------------------------------
     *
     * The username used to authenticate with the selected WhatsApp provider.
     * This value is typically provided by the API service you are integrating with.
     */
    'username' => env('WHATSAPP_USERNAME'),

    /**
     * --------------------------------------------------------------------------
     * WhatsApp Password or Token
     * --------------------------------------------------------------------------
     *
     * The password or access token required to authenticate with the provider.
     * This credential should be kept secure and never exposed publicly.
     */
    'password' => env('WHATSAPP_PASSWORD'),

    /**
     * --------------------------------------------------------------------------
     * WhatsApp Base URL
     * --------------------------------------------------------------------------
     *
     * The base endpoint URL for the WhatsApp API. This is where all requests
     * will be sent. Make sure the URL is correct and includes the necessary
     * protocol (http or https).
     */
    'base_url' => env('WHATSAPP_BASE_URL'),
];

Usage

whatsapp()
    ->to('+628XXXXXXXXXX')
    ->message('Hello World')
    ->send();

whatsapp()
    ->to('+628XXXXXXXXXX')
    ->image('https://files.f-g.my.id/images/dummy/botol-2.jpg')
    ->send();

\FahriGunadi\Whatsapp\Whatsapp::to('+628XXXXXXXXXX')
    ->image('https://files.f-g.my.id/images/dummy/botol-2.jpg')
    ->message('Image Caption')
    ->send();

// handle webhook in controller
public function webhook(\FahriGunadi\Whatsapp\WebhookRequest $request)
{
    // get webhook sender
    $sender = $request->sender();

    // get webhook message text
    $text = $request->messageText();

    // get webhook chat room
    $room = $request->chat();

    // reply webhook message
    $request->reply()->message("Hello $sender, you said: $text")->send();

    // ....
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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