digiworld/digichat

Laravel package for DigiChat WhatsApp API integration

Installs: 3

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 0

Forks: 0

pkg:composer/digiworld/digichat

v1.0.4 2025-09-21 11:18 UTC

This package is auto-updated.

Last update: 2025-10-21 11:30:24 UTC


README

DigiChat Logo DigiChat

DigiChat is a lightweight Laravel package that lets your app send WhatsApp messages and manage the session (QR / status / logout) via the DigiWorld DigiChat API.

โœ… Requirements

  • PHP 8.1+
  • Laravel 10 or 11
  • cURL enabled

๐Ÿ“ฆ Installation

Install via Composer:

composer require digiworld/digichat

Then publish the config & boilerplate:

php artisan digichat:install

This will publish the config/digichat.php file where you can set your API credentials.

โš™๏ธ Configuration

Add the following to your .env:

DIGICHAT_API_TOKEN=your_token_here
DIGICHAT_API_SECRET=your_secret_here

You can find these credentials in your DigiChat dashboard: https://chat.digiworld-dev.com/
If you donโ€™t have access, please contact DigiWorld support.

๐Ÿ” How requests are signed

Every request is signed the same way your server expects:

signature = HMAC_SHA256( timestamp + token + jsonPayload, secret )

Headers sent:

X-API-Token: {token}
X-API-Timestamp: {unix_timestamp}
X-API-Signature: {hmac_sha256_hex}
Content-Type: application/json
Accept: application/json

๐Ÿš€ Quick Start

Using the Facade (recommended):

use Digiworld\DigiChat\Facades\DigiChat;

Route::get('/test-digichat', function () {
    $response = DigiChat::sendMessage(
        '963XXXXXXXX',                 // recipient without + or 0 prefix
        'Test from local package'      // message
    );

    return response()->json($response);
});

Using the service container:

use Digiworld\DigiChat\DigiChatManager;

Route::get('/test-digichat-manager', function (DigiChatManager $dc) {
    return $dc->sendMessage('963XXXXXXXX', 'Hello from Manager!');
});

๐Ÿ“š Available Methods (current)

The package currently exposes these methods in DigiChatManager (and via the Facade):

1) sendMessage(string $phoneNumber, string $message): array

Send a plain text WhatsApp message.

DigiChat::sendMessage('963XXXXXXXX', 'Hello there');

2) getQr(): array

Get the current QR code payload (if the session is not yet authenticated).

$qr = DigiChat::getQr();

3) getStatus(): array

Get the session status (e.g., connected / disconnected / waiting-for-qr).

$status = DigiChat::getStatus();

4) logout(bool $withDeletion = false): array

Log out the current session. If $withDeletion is true, also request server-side data cleanup.

DigiChat::logout();                    // normal logout
DigiChat::logout(withDeletion: true);  // logout + delete persisted data

๐Ÿงฐ Error Handling

  • On success, methods return the decoded JSON response array from the API.
  • On failure, the client attempts to surface the server error and returns a consistent array structure like:
[
  'success' => false,
  'message' => 'DigiChat API error 401: {"error":"Invalid token"}'
]

You can wrap calls in a try/catch if you prefer throwing exceptions in your own layer.

๐Ÿ›  Example Route (copyโ€“paste)

use Illuminate\Support\Facades\Route;
use Digiworld\DigiChat\Facades\DigiChat;

Route::get('/digichat/demo', function () {
    try {
        $client = new DigiChat();
        $send = $client->sendMessage('963XXXXXXXX', 'Hello from DigiChat ๐Ÿ‘‹');
        $status = $client->getStatus();

        return response()->json([
            'send'   => $send,
            'status' => $status,
        ]);
    } catch (\Throwable $e) {
        return response()->json([
            'success' => false,
            'error'   => $e->getMessage(),
        ], 500);
    }
});

๐Ÿ›‘ Disclaimer

Important Notice: DigiChat uses unofficial access to WhatsApp, which may violate WhatsAppโ€™s Terms of Service.

By using this package, you acknowledge that:

  • Your phone number may be banned by WhatsApp for using unofficial APIs.
  • DigiWorld is not responsible for any bans, suspensions, or loss of access to your WhatsApp account.
  • Use this tool at your own risk and only for permitted purposes.

๐Ÿ’ฌ Support

Happy Messaging ๐Ÿš€