1. Go to this page and download the library: Download denlopes/waha-laravel-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
denlopes / waha-laravel-sdk example snippets
use Waha;
$chat = Waha::chat('[email protected]');
$message = $chat->sendMessage('Hello from Laravel');
$message->id(); // WhatsApp message id
use DenLopes\Waha\Data\Input\RemoteFile;
$chat->sendImage(new RemoteFile('image/jpeg', 'https://example.com/pic.jpg'));
$chat->sendMessage('Thanks for reaching out!', replyTo: '[email protected]_ABC');
use DenLopes\Waha\Services\SessionService;
$sessions = app(SessionService::class)->listSessions();
use DenLopes\Waha\Client;
public function __construct(private Client $waha) {}
$chat = $this->waha->chat('[email protected]', 'sales');
use DenLopes\Waha\Data\Input\RemoteFile;
use Waha;
$chat = Waha::chat('[email protected]', 'sales'); // session name or Session object
$message = $chat->sendMessage('Hello from Laravel');
// Every send* returns a Message, so message actions chain directly.
$chat->sendImage(new RemoteFile(mimetype: 'image/jpeg', url: 'https://example.com/pic.jpg'))
->react('🔥');
$chat->message($message->id()); // lazy handle, no I/O until get()
$chat->find($message->id()); // eager fetch
$chat->getMessages(limit: 50); // list, as Message objects
use Waha;
$conversation = Waha::conversation('[email protected]');
// markRead → thinking delay → startTyping → random typing delay → stopTyping → sendText
$message = $conversation->send('Hello from Laravel');
// Reply to an inbound message with the same flow.
$reply = $conversation->reply('Thanks for reaching out!', $incomingMessageId);
$conversation = $chat->conversation();
$conversation
->markRead()
->startTyping()
->wait(800)
->stopTyping();
$conversation->reset(); // clear pacing state, e.g. when a human takes over
use DenLopes\Waha\Enums\ContactStage;
use DenLopes\Waha\Support\Pacing;
Pacing::fromConfig(); // reads waha.conversations
Pacing::off(); // no humanization, no pacing (useful in tests)
$conversation->withStage(ContactStage::Warm)->send('hi');
try {
$messaging->sendText('[email protected]', 'Hello');
} catch (\DenLopes\Waha\Exceptions\RateLimitException $e) {
// back off and retry later
} catch (\DenLopes\Waha\Exceptions\WahaException $e) {
report($e);
}
$debug = app(\DenLopes\Waha\Debug\DebugStore::class);
$debug->last(); // last masked request/response
$debug->lastCurl(); // last request as a copy-pasteable curl command