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
Requires
- php: ^8.2
- guzzlehttp/guzzle: ^7.2
- laravel/framework: ^8.0|^9.0|^10.0|^11.0|^12.0
README
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
- Open an issue on the repository, or
- Email: support@digiworld.com