octopusteam / waapi-laravel
WAAPI whatsapp api integration for Laravel
Fund package maintenance!
Requires
- php: >=8.0
- illuminate/support: ^8.0|^9.0|^10.0|^11.0|^12.0
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0|^10.0
- phpunit/phpunit: ^10.0|^11.0|^12.0|^13.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Modern WhatsApp API Integration for Laravel
Built with ❤️ by Octopus Team
Overview
octopusteam/waapi-laravel provides an expressive, fluent client for integrating the WAAPI Pro WhatsApp API service into any Laravel application.
Whether you need automatic load-balanced message routing across multiple WhatsApp devices, group management, rich media, templates, OTPs, or device management, this package makes it clean and effortless.
Highlights & Features
- ⚡ Auto-Device Load Balancing: Route messages automatically across your connected WhatsApp devices using Least Recently Used (LRU) round-robin.
- 👥 Group Management & Messaging: Fetch WhatsApp groups per device and send messages directly to groups.
- 💬 Rich Messaging Support: Send plain text, OTPs, files (PDF/Images), templates with dynamic variables, stickers (WebP), voice notes, location coordinates, and contacts.
- 📥 Tracked Conversation Inboxes: Keep messages organized inside customer conversation threads with custom tracking metadata.
- 📱 Device & QR Operations: Check device status and retrieve QR codes for instant connection.
- 📊 Message Status Tracking: Inspect delivery status for individual messages or query batch IDs.
- 👤 Contact Presence & Batch Avatars: Detect contact presence (online, offline) and download profile pictures in bulk.
- 🛠️ Full Devices & Apps CRUD: Create, read, update, and delete devices and apps programmatically.
- 🌐 Webhook Settings API: Inspect and configure your WAAPI account webhook endpoints directly via API.
- 💡 Complete IDE Autocompletion: The
Waapifacade includes full PHPDoc method signatures for PhpStorm and VS Code.
Requirements
- PHP: 8.0 or higher (Supports PHP 8.1, 8.2, 8.3, 8.4, 8.5)
- Laravel: 8.x, 9.x, 10.x, 11.x, or 12.x
Installation
Install the package via Composer:
composer require octopusteam/waapi-laravel
Publish the configuration file:
php artisan vendor:publish --provider="OctopusTeam\Waapi\WaapiServiceProvider"
This publishes config/waapi.php to your Laravel app.
Configuration
Add your WAAPI credentials to your .env file:
WAAPI_APP_URL=https://waapi.octopusteam.net/api/create-message WAAPI_APP_KEY=your_app_key WAAPI_AUTH_KEY=your_auth_key # Optional default device UUID for device-specific actions WAAPI_DEVICE_ID=your_device_uuid
You can find your Auth Key and create App Keys and Devices directly on your WAAPI Dashboard.
Usage Guide
Use the Waapi facade in your controllers, services, or jobs:
use OctopusTeam\Waapi\Facades\Waapi;
1. Auto-Device Load-Balanced Messaging
Sends messages automatically distributed across all connected devices using least-recently-used round-robin. Requires only your authkey (no appkey needed):
// Basic auto-routed message $response = Waapi::sendAutoDeviceMessage('2010xxxxxxxx', 'Hello from WAAPI auto routing!'); // With message type and custom tracking data $response = Waapi::sendAutoDeviceMessage( to: '2010xxxxxxxx', message: 'Your order #ORD-1001 has been dispatched.', type: 'text', customData: [ 'order_id' => 'ORD-1001', 'customer_id' => 45, ] );
Alias available:
Waapi::autoDeviceSendMessage(...)
2. Standard Messaging (App-Specific)
Simple Text Message
$response = Waapi::sendMessage('2010xxxxxxxx', 'Hello, world!');
OTP Verification Code
// Generate a 6-digit OTP $otp = Waapi::generateOtp(6); // Send the OTP $response = Waapi::sendOtp('2010xxxxxxxx', (string) $otp); // With custom message format $response = Waapi::sendOtp( phone: '2010xxxxxxxx', otp: (string) $otp, messageFormat: 'Your verification code is :otp. Do not share it.' );
Media Message (Image, PDF, Document)
$response = Waapi::sendMedia( phone: '2010xxxxxxxx', message: 'Here is your monthly invoice', fileUrl: 'https://example.com/invoices/INV-2026.pdf' );
Template Message
$response = Waapi::sendTemplate( phone: '2010xxxxxxxx', templateId: 'order_update', variables: [ 'variables[1]' => 'Mohamed', 'variables[2]' => 'ORD-1001', ] );
Sticker (WebP)
$response = Waapi::sendSticker( phone: '2010xxxxxxxx', stickerUrl: 'https://example.com/stickers/happy.webp', deviceId: 'your-device-uuid' // optional );
Voice Note (Audio)
$response = Waapi::sendVoice( phone: '2010xxxxxxxx', audioUrl: 'https://example.com/audio/voice-note.ogg', deviceId: 'your-device-uuid' // optional );
Location Pin
$response = Waapi::sendLocation( phone: '2010xxxxxxxx', latitude: '30.0444', longitude: '31.2357', name: 'Cairo Office' // optional );
Contact Card (vCard)
$response = Waapi::sendContact( phone: '2010xxxxxxxx', contactName: 'Octopus Support', contactNumber: '201000000000', organization: 'Octopus Team' // optional );
3. WhatsApp Groups
Fetch Groups for a Device
$groups = Waapi::getGroups('device-uuid');
Send a Message to a Group
$response = Waapi::sendGroupMessage( deviceId: 'device-uuid', groupId: '120363XXXXXXXX@g.us', message: 'Hello everyone in the team group!' );
4. Conversation Inbox Messaging
Maintains context inside the customer's chat conversation inbox:
$response = Waapi::sendConversationMessage( to: '2010xxxxxxxx', message: 'Message stored inside conversation inbox', type: 'text', customData: [ 'ticket_id' => 'TCK-552', ], deviceId: 'device-uuid' // optional );
5. Device Status & QR Code Connection
Get Device Status
$status = Waapi::getDeviceStatus('device-uuid'); // Returns connection state: connected, disconnected, etc.
Get QR Code for Device Linking
$qr = Waapi::getQrCode('device-uuid'); // Returns QR code payload / image URL to scan with WhatsApp
6. Message Status Tracking
Check Single Message Status
$status = Waapi::getMessageStatus('message_id');
Check Batch Messages Status
$status = Waapi::getMessagesStatus(['89', '90', '91', '92']);
7. Contact Presence & Batch Profile Pictures
Check Contact Presence (Online / Typing)
$presence = Waapi::contactPresence('device-uuid', '2010xxxxxxxx');
Batch Profile Picture Fetching
$pictures = Waapi::getProfilePictures( phones: ['2010xxxxxxxx', '2011xxxxxxxx'], deviceId: 'device-uuid', // optional isGroup: false // true for group JIDs );
8. Devices Management (CRUD)
// List all devices $devices = Waapi::getDevices(); // Create a new device $device = Waapi::createDevice( name: 'Sales WhatsApp', webhookUrl: 'https://your-domain.com/api/waapi/webhook' // optional ); // Get a specific device $device = Waapi::getDevice('device-uuid'); // Update device name or webhook destination $updated = Waapi::updateDevice( deviceId: 'device-uuid', name: 'Sales WhatsApp (Updated)', webhookUrl: 'https://your-domain.com/api/waapi/webhook' ); // Delete device $deleted = Waapi::deleteDevice('device-uuid');
9. Apps Management (CRUD)
// List all apps $apps = Waapi::getApps(); // Create a new app linked to a device $app = Waapi::createApp( name: 'E-commerce App', deviceId: 'device-uuid', website: 'https://example.com' // optional ); // Get a specific app $app = Waapi::getApp('app-uuid'); // Delete an app $deleted = Waapi::deleteApp('app-uuid');
10. Webhook Settings API
Configure the webhook destination directly on your WAAPI account:
// Retrieve current webhook configuration $settings = Waapi::getWebhookSettings(); // Update account webhook destination $updated = Waapi::updateWebhookSettings('https://your-domain.com/api/waapi/webhook');
Postman Collection
A complete, ready-to-import Postman Collection is included in the root of this repository:
waapi_collection.json.
You can import it into Postman to test and inspect all WAAPI Pro endpoints with pre-configured variables ({{baseUrl}}, {{authkey}}, {{appkey}}, {{device_uuid}}).
Running Tests
Run the test suite using PHPUnit:
composer test # or ./vendor/bin/phpunit
Security Vulnerabilities
If you discover any security vulnerabilities, please send an e-mail to octopussoftwareteam@gmail.com.
Credits
License
The MIT License (MIT). Please see the License File for more information.