1. Go to this page and download the library: Download wawabot/laravel 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/ */
wawabot / laravel example snippets
use WaWaBot\Facades\WaWaBot;
// Kirim teks
WaWaBot::send('6281234567890', 'Halo dari Laravel!');
// Kirim gambar
WaWaBot::sendMedia(
to: '6281234567890',
filePath: storage_path('app/public/foto.jpg'),
caption: 'Ini caption gambar',
);
use WaWaBot\WaWaBot;
class NotificationController extends Controller
{
public function __construct(private WaWaBot $waWaBot) {}
public function sendWelcome(string $phone): array
{
return $this->waWaBot->send($phone, 'Selamat datang!');
}
}
use WaWaBot\WaWaBot;
$bot = new WaWaBot(
apiKey: 'api-key-anda',
accountId: 'user-1',
baseUrl: 'https://wa-api.wawabot.id', // opsional, ini default-nya
);
$bot->send('6281234567890', 'Pesan dari akun user-1');
use WaWaBot\Facades\WaWaBot;
use WaWaBot\Exceptions\WaWaBotException;
try {
// 1. Mulai sesi akun
WaWaBot::start();
// 2. Ambil QR (JSON — untuk ditampilkan di frontend)
$qrData = WaWaBot::qr();
// $qrData berisi response JSON dari API (mis. data QR base64)
// Atau ambil sebagai HTML (untuk langsung render di browser)
// $qrHtml = WaWaBot::qr(isHtml: true);
// 3. Setelah user scan QR di HP, cek status login
$info = WaWaBot::infoMe();
$session = WaWaBot::session();
// 4. Kirim pesan teks
$result = WaWaBot::send('6281234567890', 'Halo, ini pesan teks!');
// 5. Kirim gambar / media
$mediaResult = WaWaBot::sendMedia(
to: '6281234567890',
filePath: public_path('images/promo.jpg'),
caption: 'Promo bulan ini!',
);
// 6. (Opsional) Cek apakah nomor terdaftar di WhatsApp
$lookup = WaWaBot::lookup('085612312311');
} catch (WaWaBotException $e) {
// Handle error dari API
logger()->error('WaWaBot error', [
'message' => $e->getMessage(),
'status' => $e->getCode(),
'body' => $e->response?->json(),
]);
}
WaWaBot::send(
to: '6281234567890', // nomor tujuan (format internasional disarankan)
text: 'Isi pesan',
);
WaWaBot::sendMedia(
to: '6281234567890',
filePath: '/path/ke/gambar.jpg', // path file lokal yang bisa dibaca
caption: 'Caption opsional', // boleh null
);
// Response JSON (default)
$data = WaWaBot::qr();
// Response HTML mentah (untuk embed di halaman web)
$html = WaWaBot::qr(isHtml: true);
use WaWaBot\Exceptions\WaWaBotException;
try {
WaWaBot::send('6281234567890', 'Halo');
} catch (WaWaBotException $e) {
echo $e->getMessage(); // pesan error
echo $e->getCode(); // HTTP status code
$e->response?->json(); // body response lengkap
$e->response?->body(); // raw body
}