VOOZH about

URL: https://dev.to/moatazkhaled93/send-whatsapp-messages-from-laravel-in-3-lines-of-code-4adh

⇱ Send WhatsApp Messages from Laravel in 3 Lines of Code - DEV Community


If you've ever needed to send WhatsApp messages from a Laravel app — order confirmations, OTP codes, shipping updates — you know how painful it can be to set up.

I built wasaas-php, an open-source Laravel SDK that makes it dead simple.

Install

composer require wasaas/wasaas-php

Add your API key to .env:

WASAAS_API_KEY=wsa_your_key_here

Get a free API key at wasaas.org — 7-day trial, no credit card required.

Send a Message in 3 Lines

use Wasaas\Laravel\Facades\Wasaas;

Wasaas::messages()->sendText(
 sessionId: 'my-session',
 to: '966501234567',
 message: 'Your order #1234 has shipped! 🚚',
);

That's it. Connect your WhatsApp number in the dashboard, grab a session ID, and you're sending messages.

What Else Can It Do?

Send an image:

Wasaas::messages()->sendImage(
 sessionId: 'my-session',
 to: '966501234567',
 imageUrl: 'https://example.com/invoice.png',
 caption: 'Invoice #1234',
);

Send a PDF or document:

$base64 = base64_encode(file_get_contents('/path/to/invoice.pdf'));

Wasaas::messages()->sendDocument(
 sessionId: 'my-session',
 to: '966501234567',
 base64: $base64,
 filename: 'invoice-1234.pdf',
 mime: 'application/pdf',
 caption: 'Your invoice is attached',
);

Check if a number has WhatsApp:

$result = Wasaas::numbers()->validate('my-session', '966501234567');
// ['exists' => true, 'phone' => '966501234567']

Works Without Laravel Too

Plain PHP — no framework needed:

use Wasaas\WasaasClient;

$client = new WasaasClient(apiKey: 'wsa_your_key_here');
$client->messages->sendText('my-session', '966501234567', 'Hello from PHP!');

Links

Would love your feedback — drop a comment or open an issue on GitHub!