### Quick Start Example: Sending a WhatsApp Message Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md A complete example demonstrating the process of sending a WhatsApp text message using the SDK, from client instantiation to checking the response. ```APIDOC ## Quick Start Example Here's a complete example showing how to send your first WhatsApp message: ```php sessions()->startTheSession('default'); // 3. Send a text message $messageResponse = $waha->sendText()->sendTextMessage( chatId: '1234567890@c.us', // WhatsApp number with @c.us suffix text: 'Hello from Laravel WAHA SDK!', session: 'default', replyTo: null, linkPreview: null, linkPreviewHighQuality: null ); // 4. Check if message was sent successfully if ($messageResponse->successful()) { $messageData = $messageResponse->json(); echo "Message sent! ID: " . $messageData['id']; } else { echo "Failed to send message: " . $messageResponse->body(); } ``` ``` -------------------------------- ### Install Laravel WAHA Saloon SDK Source: https://context7.com/chengkangzai/laravel-waha-saloon-sdk/llms.txt Install the SDK using Composer and publish the configuration file to set up credentials and connection details. ```bash composer require chengkangzai/laravel-waha-saloon-sdk php artisan vendor:publish --tag="waha-saloon-sdk-config" ``` -------------------------------- ### Working with WAHA Sessions Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Examples for managing WhatsApp sessions, including listing, getting information, starting, stopping, and obtaining QR codes for pairing. ```php // Get all active sessions (using misc resource) $response = $waha->misc()->listAllSessions(null); $sessions = $response->json(); foreach ($sessions as $session) { echo "Session: {$session['name']}, Status: {$session['status']} "; } // Get detailed information about a specific session $response = $waha->sessions()->getSessionInformation('default'); if ($response->successful()) { $session = $response->json(); echo "Session Status: {$session['status']} "; echo "Session Config: " . json_encode($session['config']) . " "; } // Start a new session (first time requires QR code scanning) $response = $waha->sessions()->startTheSession('default'); if ($response->successful()) { echo "Session started successfully "; // You may need to scan QR code if this is the first time } // Stop an active session $response = $waha->sessions()->stopTheSession('default'); if ($response->successful()) { echo "Session stopped successfully "; } // Get QR code for authentication $response = $waha->auth()->getQrCodeForPairingWhatsAppApi('default'); if ($response->successful()) { $qr = $response->json(); echo "QR Code: {$qr['qr']} "; } ``` -------------------------------- ### Install Dependencies Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/CLAUDE.md Installs project dependencies using Composer. ```bash composer install # Install dependencies ``` -------------------------------- ### Working with Sessions Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Provides examples for managing WhatsApp sessions, including listing, getting information, starting, stopping, and obtaining QR codes for pairing. ```APIDOC ## Working with Sessions Sessions are the foundation of WhatsApp communication. Each session represents a WhatsApp connection. ```php // Get all active sessions (using misc resource) $response = $waha->misc()->listAllSessions(null); $sessions = $response->json(); foreach ($sessions as $session) { echo "Session: {"{$session['name']}"}, Status: {"{$session['status']}"}\n"; } // Get detailed information about a specific session $response = $waha->sessions()->getSessionInformation('default'); if ($response->successful()) { $session = $response->json(); echo "Session Status: {"{$session['status']}"}\n"; echo "Session Config: " . json_encode($session['config']) . "\n"; } // Start a new session (first time requires QR code scanning) $response = $waha->sessions()->startTheSession('default'); if ($response->successful()) { echo "Session started successfully\n"; // You may need to scan QR code if this is the first time } // Stop an active session $response = $waha->sessions()->stopTheSession('default'); if ($response->successful()) { echo "Session stopped successfully\n"; } // Get QR code for authentication $response = $waha->auth()->getQrCodeForPairingWhatsAppApi('default'); if ($response->successful()) { $qr = $response->json(); echo "QR Code: {"{$qr['qr']}"}\n"; } ``` ``` -------------------------------- ### Quick Start: Send First WhatsApp Message Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md A complete example to send your first WhatsApp text message using the SDK. Ensure you have started a session first. ```php sessions()->startTheSession('default'); // 3. Send a text message $messageResponse = $waha->sendText()->sendTextMessage( chatId: '1234567890@c.us', // WhatsApp number with @c.us suffix text: 'Hello from Laravel WAHA SDK!', session: 'default', replyTo: null, linkPreview: null, linkPreviewHighQuality: null ); // 4. Check if message was sent successfully if ($messageResponse->successful()) { $messageData = $messageResponse->json(); echo "Message sent! ID: " . $messageData['id']; } else { echo "Failed to send message: " . $messageResponse->body(); } ``` -------------------------------- ### Install Laravel WAHA Saloon SDK Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Install the package using Composer. This command adds the SDK to your project's dependencies. ```bash composer require chengkangzai/laravel-waha-saloon-sdk ``` -------------------------------- ### Install SDK and Publish Config Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Steps to update the SDK package and optionally publish its configuration file. This is part of the upgrade process from v0.0.x to v0.1.0. ```bash composer update chengkangzai/laravel-waha-saloon-sdk ``` ```bash php artisan vendor:publish --tag="waha-saloon-sdk-config" --force ``` ```bash php artisan config:clear ``` -------------------------------- ### Get server environment Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Retrieves the server environment information. ```APIDOC ## Get server environment ### Description Retrieve the server environment information. ### Method ```php $waha->server()->getTheServerEnvironment() ``` ### Request Example ```php // Get server environment $response = $waha->server()->getTheServerEnvironment(); $env = $response->json(); echo "Environment: {$env['env']}\n"; ``` ``` -------------------------------- ### Get Server Environment Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Fetches the server environment details, such as 'production' or 'development'. The environment information is returned in a JSON object. ```php // Get server environment $response = $waha->server()->getTheServerEnvironment(); $env = $response->json(); echo "Environment: {$env['env']}\n"; ``` -------------------------------- ### Start typing indicator Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Sets the typing indicator for a chat. ```APIDOC ## Set typing indicator ### Description Set the typing indicator for a chat. ### Method ```php $waha->misc()->chattingControllerStartTyping(string $chatId, string $session = 'default') ``` ### Parameters #### Path Parameters - **chatId** (string) - Required - The ID of the chat to set the typing indicator for. - **session** (string) - Optional - The session name. Defaults to 'default'. ### Request Example ```php // Set typing indicator $response = $waha->misc()->chattingControllerStartTyping( chatId: '1234567890@c.us', session: 'default' ); ``` ``` -------------------------------- ### Manage WhatsApp Groups with SDK Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md This snippet demonstrates how to retrieve all groups, create new groups, get detailed group information, manage participants (add, remove, promote, demote), update group settings, leave groups, and manage invitation links. Requires appropriate admin privileges for certain operations. ```php // Get all groups you're part of $response = $waha->misc()->getAllGroups( session: 'default', sortBy: null, sortOrder: null, limit: null, offset: null, exclude: null ); $groups = $response->json(); foreach ($groups as $group) { echo "Group: {$group['name']} "; echo "ID: {$group['id']} "; echo "Participants: " . count($group['participants']) . " "; echo "Description: {$group['description']} "; echo "--- "; } // Create a new group $response = $waha->misc()->createNewGroup( session: 'default', name: 'Laravel Developers', participants: ['1234567890@c.us', '0987654321@c.us'] ); if ($response->successful()) { $group = $response->json(); echo "Group created: {$group['id']} "; } // Get detailed group information $response = $waha->groups()->getTheGroup( session: 'default', groupId: 'group_id@g.us' ); $groupDetails = $response->json(); // Add participants to a group (admin only) $response = $waha->participants()->addParticipants( session: 'default', groupId: 'group_id@g.us', participants: ['1234567890@c.us', '5555555555@c.us'] ); // Remove participants from a group (admin only) $response = $waha->participants()->removeParticipants( session: 'default', groupId: 'group_id@g.us', participants: ['1234567890@c.us'] ); // Promote participants to admin $response = $waha->admin()->promoteParticipantsToAdminUsers( session: 'default', groupId: 'group_id@g.us', participants: ['1234567890@c.us'] ); // Demote admins to regular participants $response = $waha->admin()->demotesParticipantsToRegularUsers( session: 'default', groupId: 'group_id@g.us', participants: ['1234567890@c.us'] ); // Update group settings $response = $waha->groups()->updatesTheGroupSubject( session: 'default', groupId: 'group_id@g.us', subject: 'New Group Name' ); $response = $waha->groups()->updatesTheGroupDescription( session: 'default', groupId: 'group_id@g.us', description: 'This is our updated group description' ); // Leave a group $response = $waha->groups()->leaveTheGroup( session: 'default', groupId: 'group_id@g.us' ); // Get group invitation link (admin only) $response = $waha->inviteCode()->getsTheInviteCodeForTheGroup( session: 'default', groupId: 'group_id@g.us' ); $inviteCode = $response->json(); echo "Invite link: https://chat.whatsapp.com/{$inviteCode['code']} "; // Revoke group invitation link (admin only) $response = $waha->inviteCode()->invalidatesTheCurrentGroupInviteCodeAndGeneratesNewOne( session: 'default', groupId: 'group_id@g.us' ); ``` -------------------------------- ### Generate QR Codes for WhatsApp Authentication Source: https://context7.com/chengkangzai/laravel-waha-saloon-sdk/llms.txt Provides examples for fetching QR codes required to pair a new WhatsApp session. Supports various output formats including Base64, raw string, and binary image. Instantiate the Waha class and use the qr() method. ```php $waha = new Waha(); // Base64-encoded image (for embedding in HTML or API responses) $response = $waha->qr()->getQrCodeBase64('default'); $qr = $response->json(); // ['value' => 'data:image/png;base64,iVBORw0K...'] // Raw QR string value (for third-party QR renderers) $response = $waha->qr()->getQrCodeRaw('default'); // ['value' => '2@xxxx,yyyy,zzzz,...'] // Binary PNG image response $response = $waha->qr()->getQrCodeImage('default'); file_put_contents('/tmp/qr.png', $response->body()); // Arbitrary format $response = $waha->qr()->getQrCodeForPairingWhatsAppApi('default', format: 'image'); ``` -------------------------------- ### Sending Messages Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Examples of sending different types of messages using the SDK, including text, images, documents, videos, voice messages, and polls. ```APIDOC ## Send Text Message ### Description Sends a simple text message to a specified chat. ### Method `sendText()->sendTextMessage()` ### Parameters - **chatId** (string) - Required - The ID of the chat to send the message to. - **text** (string) - Required - The content of the text message. - **session** (string) - Optional - The session name to use. - **replyTo** (string|null) - Optional - The ID of the message to reply to. - **linkPreview** (bool|null) - Optional - Whether to enable link previews. - **linkPreviewHighQuality** (bool|null) - Optional - Whether to enable high-quality link previews. ``` ```APIDOC ## Send Image ### Description Sends an image to a specified chat, either from a URL or base64 encoded string. Supports captions. ### Method `misc()->sendImage()` ### Parameters - **chatId** (string) - Required - The ID of the chat to send the image to. - **file** (string) - Required - The URL or base64 encoded string of the image file. - **session** (string) - Optional - The session name to use. - **replyTo** (string|null) - Optional - The ID of the message to reply to. - **caption** (string|null) - Optional - A caption for the image. ``` ```APIDOC ## Send Document ### Description Sends a document or file to a specified chat, either from a URL or base64 encoded string. Supports captions. ### Method `misc()->sendFile()` ### Parameters - **chatId** (string) - Required - The ID of the chat to send the file to. - **file** (string) - Required - The URL or base64 encoded string of the file. - **session** (string) - Optional - The session name to use. - **replyTo** (string|null) - Optional - The ID of the message to reply to. - **caption** (string|null) - Optional - A caption for the document. ``` ```APIDOC ## Send Video ### Description Sends a video to a specified chat, either from a URL or base64 encoded string. Supports captions and sending as a voice note. ### Method `misc()->sendVideo()` ### Parameters - **chatId** (string) - Required - The ID of the chat to send the video to. - **file** (string) - Required - The URL or base64 encoded string of the video file. - **session** (string) - Optional - The session name to use. - **replyTo** (string|null) - Optional - The ID of the message to reply to. - **asNote** (bool) - Optional - Whether to send the video as a voice note. - **caption** (string|null) - Optional - A caption for the video. ``` ```APIDOC ## Send Voice Message ### Description Sends a voice message to a specified chat, either from a URL or base64 encoded string. ### Method `misc()->sendVoiceMessage()` ### Parameters - **chatId** (string) - Required - The ID of the chat to send the voice message to. - **file** (string) - Required - The URL or base64 encoded string of the audio file. - **session** (string) - Optional - The session name to use. - **replyTo** (string|null) - Optional - The ID of the message to reply to. ``` ```APIDOC ## Send Location ### Description Sends a location message to a specified chat. ### Method `misc()->chattingControllerSendLocation()` ### Parameters - **chatId** (string) - Required - The ID of the chat to send the location to. - **latitude** (float) - Required - The latitude of the location. - **longitude** (float) - Required - The longitude of the location. - **title** (string|null) - Optional - The title of the location. - **session** (string) - Optional - The session name to use. - **replyTo** (string|null) - Optional - The ID of the message to reply to. ``` ```APIDOC ## Send Poll ### Description Sends a poll with options to a specified chat. ### Method `misc()->sendPollWithOptions()` ### Parameters - **chatId** (string) - Required - The ID of the chat to send the poll to. - **poll** (array) - Required - An array containing poll data with 'name', 'options', and 'selectableCount'. - **session** (string) - Optional - The session name to use. - **replyTo** (string|null) - Optional - The ID of the message to reply to. ``` ```APIDOC ## Check Message Delivery Status ### Description Checks the status of a sent message and provides details on success or failure. ### Method `$response->successful()` `$response->json()` `$response->status()` `$response->body()` ### Response #### Success Response - **id** (string) - The ID of the sent message. - **timestamp** (int) - The timestamp when the message was sent. #### Error Response - **status** (int) - The HTTP status code of the error. - **body** (string) - The error message or response body. ``` -------------------------------- ### Manage WhatsApp Contacts with SDK Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Use this snippet to retrieve all contacts, get detailed contact information, check phone number registration, and manage contact blocking. Ensure the 'default' session is configured. ```php // Get all contacts from the session $response = $waha->contacts()->getAllContacts('default'); $contacts = $response->json(); foreach ($contacts as $contact) { echo "Name: {$contact['name']} "; echo "Number: {$contact['id']} "; echo "Is Business: " . ($contact['isBusiness'] ? 'Yes' : 'No') . " "; echo "--- "; } // Get detailed information about a specific contact $response = $waha->contacts()->getContactBasicInfo( session: 'default', contactId: '1234567890@c.us' ); $contact = $response->json(); echo "Contact Name: {$contact['name']} "; echo "Push Name: {$contact['pushname']} "; // Get contact's about info $response = $waha->contacts()->getsTheContactAboutInfo( session: 'default', contactId: '1234567890@c.us' ); $about = $response->json(); // Check if a phone number exists on WhatsApp $response = $waha->contacts()->checkPhoneNumberIsRegisteredInWhatsApp( session: 'default', phone: '1234567890' ); $result = $response->json(); if ($result['numberExists']) { echo "Number exists on WhatsApp "; echo "WhatsApp ID: {$result['numberExists']} "; } else { echo "Number does not exist on WhatsApp "; } // You can also use misc resource to check number status $response = $waha->misc()->checkNumberStatus( phone: '1234567890', session: 'default' ); // Get contact's profile picture $response = $waha->contacts()->getContactProfilePictureUrl( session: 'default', contactId: '1234567890@c.us' ); $profilePic = $response->json(); // Block a contact $response = $waha->contacts()->blockContact( session: 'default', contactId: '1234567890@c.us' ); // Unblock a contact $response = $waha->contacts()->unblockContact( session: 'default', contactId: '1234567890@c.us' ); ``` -------------------------------- ### Fetch Paginated Chat Overview (GET) Source: https://context7.com/chengkangzai/laravel-waha-saloon-sdk/llms.txt Retrieves a paginated list of chats, including essential details for building a chat list UI. Suitable for smaller sets of IDs. Specify session, limit, and offset for pagination. ```php $waha = new Waha(); // GET (suitable for small ID sets) $response = $waha->overview() ->getChatsOverviewIncludesAllNecessaryThingsToBuildUiYourChatsOverviewPageChatIdNamePictureLastMessageSortingByLastMessageTimestamp( session: 'default', limit: '20', offset: '0', ids: null, ); $chats = $response->json(); foreach ($chats as $chat) { printf( "%-30s unread=%-3d last=%s\n", $chat['name'] ?? $chat['id'], $chat['unreadCount'], $chat['lastMessage']['body'] ?? '(media)', ); } ``` -------------------------------- ### Basic Waha Client Instantiation Patterns Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Demonstrates creating a Waha client instance using default configuration (from environment variables) or with custom base URL and API key. ```php use CCK\LaravelWahaSaloonSdk\Waha\Waha; // Create a new WAHA client with default config (uses env vars) $waha = new Waha(); // Or with a custom base URL and API key (overrides config) $waha = new Waha( baseUrl: 'https://your-waha-instance.com', apiKey: 'your-api-key' ); // Access different resources - each resource groups related API endpoints $sessions = $waha->sessions(); // Session management $chats = $waha->chats(); // Limited chat operations $messages = $waha->sendText(); // Send text messages $misc = $waha->misc(); // Most functionality (files, media, groups, etc.) $contacts = $waha->contacts(); // Contact management $overview = $waha->overview(); // Chat overview ``` -------------------------------- ### Use New Waha Facade Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Demonstrates the optional migration to the new `Waha` facade for a cleaner syntax when interacting with the SDK. The previous instantiation method is still supported. ```php // Before (still works) $waha = new CCK LaravelWahaSaloonSdk Waha Waha(); $waha->sessions()->listAllSessions(); // After (new option) use CCK LaravelWahaSaloonSdk Facades Waha; Waha::sessions()->listAllSessions(); ``` -------------------------------- ### Direct Instantiation Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Demonstrates how to instantiate the Waha client directly, overriding default configuration with a custom base URL and API key. ```APIDOC ## Direct Instantiation Direct instantiation still works and ignores the configuration: ```php use CCK\LaravelWahaSaloonSdk\Waha\Waha; $waha = new Waha( baseUrl: 'https://custom-instance.com', apiKey: 'custom-api-key' ); ``` ``` -------------------------------- ### Using the Waha Facade Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Demonstrates how to use the Waha facade to interact with different WAHA connections. You can use the default connection or specify a particular connection by name. ```APIDOC ## Using the Waha Facade (Recommended) ```php use CCK\LaravelWahaSaloonSdk\Facades\Waha; // Use default connection $response = Waha::sessions()->listAllSessions(); // Use a specific connection $response = Waha::connection('production')->sessions()->listAllSessions(); // Chain resource methods $response = Waha::connection('staging') ->chats() ->getsMessagesInTheChat('default', '1234567890@c.us'); ``` ``` -------------------------------- ### Basic Usage Patterns Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Illustrates different ways to instantiate the Waha client and access various resource groups for interacting with the WAHA API. ```APIDOC ## Basic Usage Patterns ```php use CCK\LaravelWahaSaloonSdk\Waha\Waha; // Create a new WAHA client with default config (uses env vars) $waha = new Waha(); // Or with a custom base URL and API key (overrides config) $waha = new Waha( baseUrl: 'https://your-waha-instance.com', apiKey: 'your-api-key' ); // Access different resources - each resource groups related API endpoints $sessions = $waha->sessions(); // Session management $chats = $waha->chats(); // Limited chat operations $messages = $waha->sendText(); // Send text messages $misc = $waha->misc(); // Most functionality (files, media, groups, etc.) $contacts = $waha->contacts(); // Contact management $overview = $waha->overview(); // Chat overview ``` ``` -------------------------------- ### Get server status Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Retrieves the current status of the server. ```APIDOC ## Get server status ### Description Retrieve the current status of the server. ### Method ```php $waha->server()->getTheServerStatus() ``` ### Request Example ```php // Get server status $response = $waha->server()->getTheServerStatus(); $status = $response->json(); ``` ``` -------------------------------- ### Waha Connector - Direct Instantiation Source: https://context7.com/chengkangzai/laravel-waha-saloon-sdk/llms.txt Demonstrates how to create a standalone Waha connector instance without requiring Laravel, useful for direct API calls with explicit credentials. ```APIDOC ## Waha Connector - Direct Instantiation ### Description Creates a standalone connector that does not require Laravel. When `$baseUrl` is empty inside a Laravel app it falls back to `config('waha-saloon-sdk.connections.default.base_url')`. The `X-Api-Key` header is automatically attached when `$apiKey` is provided. ### Method `new Waha(string $baseUrl, ?string $apiKey)` ### Parameters - **baseUrl** (string) - The base URL for the WAHA API. - **apiKey** (string, optional) - The API key for authentication. ### Request Example ```php use CCK\LaravelWahaSaloonSdk\Waha\Waha; use Saloon\Exceptions\Request\RequestException; // Explicit credentials — works outside Laravel $waha = new Waha( baseUrl: 'https://waha.example.com', apiKey: 'secret-key', ); // Inside Laravel — reads from config automatically $waha = new Waha(); try { $response = $waha->misc()->listAllSessions(expand: null, all: null); // $response->successful() => true // $response->status() => 200 $sessions = $response->json(); // [['name' => 'default', 'status' => 'WORKING', ...], ...] } catch (RequestException $e) { echo $e->getMessage(); echo $e->getResponse()->body(); } ``` ``` -------------------------------- ### Get WAHA version Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Retrieves the version of the WAHA server. ```APIDOC ## Get WAHA version ### Description Retrieve the version of the WAHA server. ### Method ```php $waha->misc()->getTheServerVersion() ``` ### Request Example ```php // Get WAHA version $response = $waha->misc()->getTheServerVersion(); $version = $response->json(); echo "WAHA Version: {$version['version']}\n"; ``` ``` -------------------------------- ### Instantiate Waha SDK with Default Authentication Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/CLAUDE.md Instantiates the Waha SDK. Authentication is automatic if WAHA_API_KEY is set in the .env file. ```php $waha = new SCDCWAHASaloonSdkWahaWaha(); ``` -------------------------------- ### Get presence status of a contact Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Retrieves the presence status of a contact. ```APIDOC ## Get presence status of a contact ### Description Retrieve the presence status of a contact. This will also subscribe to presence events if not already subscribed. ### Method ```php $waha->presence()->getThePresenceForTheChatIdIfItHasntBeenSubscribedItAlsoSubscribesToIt(string $session, string $chatId) ``` ### Parameters #### Path Parameters - **session** (string) - Required - The session name. - **chatId** (string) - Required - The ID of the chat. ### Request Example ```php // Get presence status of a contact $response = $waha->presence()->getThePresenceForTheChatIdIfItHasntBeenSubscribedItAlsoSubscribesToIt( session: 'default', chatId: '1234567890@c.us' ); $presence = $response->json(); ``` ``` -------------------------------- ### Get Server Status Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Retrieves the overall status of the WAHA server. The status is returned in a JSON object. ```php // Get server status $response = $waha->server()->getTheServerStatus(); $status = $response->json(); ``` -------------------------------- ### Direct Instantiation of Waha Client Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Instantiate the Waha client directly, bypassing configuration. Useful for custom instances. ```php use CCK\LaravelWahaSaloonSdk\Waha\Waha; $waha = new Waha( baseUrl: 'https://custom-instance.com', apiKey: 'custom-api-key' ); ``` -------------------------------- ### Get WAHA Version Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Retrieves the current version of the WAHA server. The version information is returned in a JSON object. ```php // Get WAHA version $response = $waha->misc()->getTheServerVersion(); $version = $response->json(); echo "WAHA Version: {$version['version']}\n"; ``` -------------------------------- ### Regenerate SDK Checklist Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/CLAUDE.md A comprehensive checklist for regenerating the Saloon SDK, covering steps from downloading the Postman collection to final quality checks and version tagging. ```bash # Regeneration Checklist # 1. Download new Postman collection to project root # 2. Edit collection to remove deprecated endpoints (check WAHA changelog) # 3. Update composer.json build script path # "build-from-postman": "sdkgenerator generate:sdk \"NEW_COLLECTION.json\" ..." # 4. Regenerate SDK composer build-from-postman # 5. Restore custom code in Waha.php, Qr.php, GetQrCodeForPairingWhatsAppApi.php # 6. Fix Response imports find src/Waha -name "*.php" -exec sed -i '' 's/use Saloon\\Contracts\\Response;/use Saloon\\Http\\Response;/g' {} + # 7. Fix missing HasBody interfaces (check and fix manually) # 8. Fix property conflicts (check PHPStan output) # 9. Quality checks composer format composer analyse # Regenerate baseline if needed composer test # 10. Delete old collection file, commit, and tag new version ``` -------------------------------- ### Get Basic Contact Information Source: https://context7.com/chengkangzai/laravel-waha-saloon-sdk/llms.txt Retrieves essential details for a contact, such as ID, name, and pushname. Requires contactId and session. ```php $response = $waha->contacts()->getContactBasicInfo( contactId: '15551234567@c.us', session: 'default', ); $contact = $response->json(); // ['id' => '15551234567@c.us', 'name' => 'Jane Doe', 'pushname' => 'Jane', 'isBusiness' => false] ``` -------------------------------- ### Get Group Details and Delete Group Source: https://context7.com/chengkangzai/laravel-waha-saloon-sdk/llms.txt Retrieve detailed information about a group or delete a group. Ensure you have admin privileges to delete a group. ```php $waha = new Waha(); // Get group details (participants, admins, description, etc.) $response = $waha->groups()->getTheGroup('default', '120363000000000001@g.us'); $group = $response->json(); // ['id' => '...@g.us', 'name' => 'Dev Team', 'participants' => [...], 'description' => '...'] // Create a group via misc() $response = $waha->misc()->createNewGroup( session: 'default', name: 'Laravel Squad', participants: ['15551111111@c.us', '15552222222@c.us'], ); $newGroup = $response->json(); // ['id' => '120363XXXXXX@g.us', 'name' => 'Laravel Squad'] // Delete a group (must be admin) $waha->groups()->deleteTheGroup('default', '120363000000000001@g.us'); ``` -------------------------------- ### Instantiate Waha SDK with Manual Authentication Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/CLAUDE.md Instantiates the Waha SDK manually providing the base URL and API key for authentication. ```php $waha = new SCDCWAHASaloonSdkWahaWaha( baseUrl: 'https://your-waha-instance.com', apiKey: 'your-api-key' ); ``` -------------------------------- ### Create and List WhatsApp Sessions Source: https://context7.com/chengkangzai/laravel-waha-saloon-sdk/llms.txt Demonstrates creating new WhatsApp sessions by name and listing all active or all sessions (including stopped ones). Instantiate the Waha class to access these methods. ```php $waha = new Waha(); // Create a new session $response = $waha->misc()->createSession(name: 'bot-session'); // ['name' => 'bot-session', 'status' => 'STOPPED', ...] // List all sessions (expand details, include stopped) $response = $waha->misc()->listAllSessions(expand: null, all: 'true'); $sessions = $response->json(); // [['name' => 'default', 'status' => 'WORKING'], ['name' => 'bot-session', 'status' => 'STOPPED']] ``` -------------------------------- ### Configure WAHA Environment Variables Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Set your WAHA instance URL and API key in your .env file. The API key is optional but recommended for authenticated endpoints. ```bash WAHA_BASE_URL=https://your-waha-instance.com WAHA_API_KEY=your-api-key-here ``` -------------------------------- ### Get Presence Status Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Retrieves the current presence status of a contact in a given chat. This operation also subscribes to presence events if not already subscribed. ```php // Get presence status of a contact $response = $waha->presence()->getThePresenceForTheChatIdIfItHasntBeenSubscribedItAlsoSubscribesToIt( session: 'default', chatId: '1234567890@c.us' ); $presence = $response->json(); ``` -------------------------------- ### Get Paginated Chat List Source: https://context7.com/chengkangzai/laravel-waha-saloon-sdk/llms.txt Retrieve a paginated and sorted list of chats. This is useful for lightweight indexing and does not include full chat overview data. ```php $waha = new Waha(); $response = $waha->misc()->getChats( session: 'default', sortBy: 'lastMessageTimestamp', sortOrder: 'desc', limit: '25', offset: '0', ); $chats = $response->json(); // [['id' => '15551234567@c.us', 'name' => 'Jane Doe', 'lastMessageTimestamp' => 1700000000], ...] ``` -------------------------------- ### Publish Configuration File Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Publish the configuration file to your application's config directory. This allows you to customize settings. ```bash php artisan vendor:publish --tag="waha-saloon-sdk-config" ``` -------------------------------- ### Get Basic Chat List with Laravel WAHA SDK Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Fetches a basic list of chats with options for sorting, limiting, and offsetting results. Useful for simple chat listings. ```php // Get basic chat list $response = $waha->misc()->getChats( session: 'default', sortBy: 'lastMessageTimestamp', sortOrder: 'desc', limit: '50', offset: '0' ); $chatList = $response->json(); ``` -------------------------------- ### Get a Single Message by ID Source: https://context7.com/chengkangzai/laravel-waha-saloon-sdk/llms.txt Retrieves a specific message using its unique ID. Options include downloading associated media. Ensure session, chatId, and messageId are correct. ```php $waha = new Waha(); // Get a single message $response = $waha->messages()->getsMessageById( session: 'default', chatId: '15551234567@c.us', messageId: 'true_15551234567@c.us_AABBCC112233', downloadMedia: 'true', ); $msg = $response->json(); // ['id' => '...', 'body' => 'Hello', 'type' => 'text', 'timestamp' => 1700000000] ``` -------------------------------- ### Manage WhatsApp Sessions with Waha SDK Source: https://context7.com/chengkangzai/laravel-waha-saloon-sdk/llms.txt Shows how to manage WhatsApp sessions using the Waha SDK. This includes retrieving session information, updating session configurations, and deleting sessions. Instantiate the Waha class to begin. ```php use CCK\ LaravelWahaSaloonSdk\Waha\Waha; $waha = new Waha(); // Get session info (status, config, etc.) $response = $waha->sessions()->getSessionInformation('default', expand: null); $session = $response->json(); // ['name' => 'default', 'status' => 'WORKING', 'config' => [...], ...] // Update session configuration $waha->sessions()->updateSession('default', name: 'renamed', config: ['debug' => true]); // Delete a session $waha->sessions()->deleteTheSession('default'); ``` -------------------------------- ### Get Messages from a Specific Chat with Laravel WAHA SDK Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Retrieves messages from a particular chat, with options for downloading media, pagination, and filtering by timestamp or sender. The `downloadMedia` parameter should be set to 'true' to fetch media content. ```php // Get messages from a specific chat with pagination $response = $waha->chats()->getsMessagesInTheChat( session: 'default', chatId: '1234567890@c.us', downloadMedia: 'true', limit: '50', offset: null, filterTimestampLte: null, filterTimestampGte: null, filterFromMe: null, filterAck: null ); $messages = $response->json(); foreach ($messages as $message) { echo "From: {$message['from']}\n"; echo "Text: {$message['body']}\n"; echo "Time: {$message['timestamp']}\n"; echo "Type: {$message['type']}\n"; // text, image, video, etc. echo "---\n"; } ``` -------------------------------- ### Waha Facade - Multi-Connection Access Source: https://context7.com/chengkangzai/laravel-waha-saloon-sdk/llms.txt Illustrates how to use the Waha facade for accessing WAHA API endpoints, supporting multiple named connections and runtime default connection switching. ```APIDOC ## Waha Facade - Multi-Connection Access ### Description The `Waha` facade proxies the `WahaManager` singleton and supports named connections defined in config. Methods called directly on the facade are forwarded to the default connection. ### Methods - `Waha::misc()->listAllSessions(expand: null, all: null)`: Calls the `listAllSessions` method on the default connection. - `Waha::connection('production')->sessions()->getSessionInformation('default', null)`: Calls the `getSessionInformation` method on the 'production' named connection. - `Waha::setDefaultConnection('production')`: Sets the default connection to 'production'. - `Waha::purge('production')`: Purges a cached connection instance for 'production'. - `Waha::purgeAll()`: Purges all cached connection instances. - `Waha::getConnections()`: Returns an array of all resolved connections. ### Request Example ```php use CCK\LaravelWahaSaloonSdk\Facades\Waha; // Default connection $response = Waha::misc()->listAllSessions(null, null); // Named connection $response = Waha::connection('production')->sessions()->getSessionInformation('default', null); // Switch default at runtime Waha::setDefaultConnection('production'); // Purge a cached connection instance Waha::purge('production'); Waha::purgeAll(); // Inspect all resolved connections $connections = Waha::getConnections(); // ['default' => Waha, 'production' => Waha] ``` ``` -------------------------------- ### Get Chat Overview with Laravel WAHA SDK Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Retrieves a comprehensive list of chats, including last message details, unread counts, and sorting options. Useful for building chat UIs. Pagination parameters `limit` and `offset` can be used. ```php // Get overview of all chats (includes last message, unread count, etc.) $response = $waha->overview()->getChatsOverviewIncludesAllNecessaryThingsToBuildUiYourChatsOverviewPageChatIdNamePictureLastMessageSortingByLastMessageTimestamp( session: 'default', limit: null, offset: null, ids: null ); $chats = $response->json(); foreach ($chats as $chat) { echo "Chat: {$chat['id']}\n"; echo "Name: {$chat['name']}\n"; echo "Last Message: {$chat['lastMessage']['body']}\n"; echo "Unread Count: {$chat['unreadCount']}\n"; echo "---\n"; } ``` -------------------------------- ### Run Tests with Composer Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/CLAUDE.md This command executes the `test` script defined in `composer.json`, typically running PHPUnit, to execute the project's test suite and ensure code correctness. ```bash composer test ``` -------------------------------- ### Using Dependency Injection Source: https://github.com/chengkangzai/laravel-waha-saloon-sdk/blob/main/README.md Illustrates how to use dependency injection to access the WahaManager in your Laravel controllers or services. This allows for cleaner code and easier testing. ```APIDOC ## Using Dependency Injection ```php use CCK\LaravelWahaSaloonSdk\WahaManager; class WhatsAppController extends Controller { public function __construct( private WahaManager $waha, ) {} public function send(Request $request) { // Use default connection $this->waha->sendText()->sendTextMessage(...); // Use specific connection $this->waha->connection('production')->sendText()->sendTextMessage(...); } } ``` ``` -------------------------------- ### Configure WAHA SDK Connections Source: https://context7.com/chengkangzai/laravel-waha-saloon-sdk/llms.txt Define default and named connections, including base URLs and API keys, in the SDK's configuration file. ```php // config/waha-saloon-sdk.php return [ 'default' => env('WAHA_CONNECTION', 'default'), 'connections' => [ 'default' => [ 'base_url' => env('WAHA_BASE_URL', ''), 'api_key' => env('WAHA_API_KEY', ''), ], 'production' => [ 'base_url' => env('WAHA_PRODUCTION_URL', ''), 'api_key' => env('WAHA_PRODUCTION_KEY', ''), ], ], 'timeout' => env('WAHA_REQUEST_TIMEOUT', 60), 'connect_timeout' => env('WAHA_CONNECT_TIMEOUT', 10), 'always_throw_on_errors' => env('WAHA_ALWAYS_THROW_ON_ERRORS', false), ]; ``` -------------------------------- ### Fetch Chat Overview with POST for Many IDs Source: https://context7.com/chengkangzai/laravel-waha-saloon-sdk/llms.txt Use the POST method to fetch chat overviews when dealing with a large number of IDs. This method allows for more flexible filtering and pagination parameters. ```php $waha->overview()->getChatsOverviewUsePostIfYouHaveTooManyIdsParamsGetCanLimitIt( session: 'default', pagination: ['limit' => 50, 'offset' => 0], filter: ['ids' => ['15551234567@c.us', '120363000000000001@g.us']], ); ``` -------------------------------- ### List All Groups with Options Source: https://context7.com/chengkangzai/laravel-waha-saloon-sdk/llms.txt Retrieve a list of all groups the session is a member of. Supports sorting, pagination, and field exclusion for efficiency. ```php $waha = new Waha(); $response = $waha->misc()->getAllGroups( session: 'default', sortBy: 'name', sortOrder: 'asc', limit: '50', offset: '0', exclude: 'participants', // omit heavy participants array ); $groups = $response->json(); foreach ($groups as $g) { echo "{$g['id']} — {$g['name']}\n"; } // 120363000000000001@g.us — Dev Team // 120363000000000002@g.us — Marketing ``` -------------------------------- ### Create & List Sessions Source: https://context7.com/chengkangzai/laravel-waha-saloon-sdk/llms.txt Create a new session by name and list all active (or all including stopped) sessions. ```APIDOC ## misc()->createSession() / misc()->listAllSessions() ### Description Create a new session by name and list all active (or all including stopped) sessions. ### Method POST (createSession), GET (listAllSessions) (conceptual, actual SDK methods) ### Endpoint N/A (SDK methods) ### Parameters #### createSession - **name** (string) - Required - The name for the new session. #### listAllSessions - **expand** (string) - Optional - Specifies which related data to expand. - **all** (string) - Optional - Set to 'true' to include stopped sessions. ### Request Example ```php $waha = new Waha(); // Create a new session $response = $waha->misc()->createSession(name: 'bot-session'); // List all sessions $response = $waha->misc()->listAllSessions(expand: null, all: 'true'); $sessions = $response->json(); ``` ### Response #### Success Response (200) - **session** (object) - Details of the created or listed session(s). ```