geekads-laravel maintained by threegeeks
Author
Last update
2026/12/04 13:59
(v1.0.0)
License
Downloads
0
Tags
GeekAds for Laravel
WhatsApp notifications, OTPs and webhooks for Laravel 11, 12 and 13, through GeekAds.
composer require threegeeks/geekads-laravel
GEEKADS_API_KEY=your-workspace-api-key
GEEKADS_WEBHOOK_SECRET=whsec_... # only if you receive webhooks
Publishing the config is optional: php artisan vendor:publish --tag=geekads-config.
Notifications
use GeekAds\Laravel\Notifications\GeekAdsMessage;
class InvoiceReady extends Notification
{
public function __construct(private Invoice $invoice) {}
public function via(object $notifiable): array
{
return ['geekads'];
}
public function toGeekAds(object $notifiable): GeekAdsMessage
{
return GeekAdsMessage::template('invoice_ready', 'en')
->body($this->invoice->number, $this->invoice->total) // {{1}}, {{2}}
->document($this->invoice->pdf_url, "{$this->invoice->number}.pdf")
->urlButton("invoices/{$this->invoice->id}")
->idempotencyKey("invoice-{$this->invoice->id}"); // never sent twice
}
}
The notifiable says which number to send to. Return null to skip:
public function routeNotificationForGeekads(): ?string
{
return $this->whatsapp_number; // e.g. "919876543210"
}
GeekAdsMessage::text('…') sends free-form text, which only works within 24 hours of the customer's last message.
Facade
use GeekAds\Laravel\Facades\GeekAds;
GeekAds::messages()->template('919876543210', 'order_update', 'en_US', bodyParams: ['A-1042']);
$otp = GeekAds::otp()->send($phone, 'login_otp');
session(['otp_id' => $otp['otp_id']]);
// later
GeekAds::otp()->verify(session('otp_id'), $request->input('code')); // true / false
Partner apps keep a GeekAds key per customer. Send with that customer's key:
GeekAds::forKey($agency->geekads_api_key)->messages()->template(/* … */);
// or, in a notification:
GeekAdsMessage::template('quote_ready', 'en')->body(/* … */)->usingKey($agency->geekads_api_key);
// Partner API (GEEKADS_PARTNER_KEY / GEEKADS_PARTNER_SECRET)
$result = GeekAds::partner()->provision("agency-{$agency->id}", $agency->name, $owner->email, $owner->name);
$link = GeekAds::partner()->connectLink("agency-{$agency->id}", route('settings.whatsapp'));
Webhooks
Route::post('geekads/webhook', function (Request $request) {
$event = $request->attributes->get('geekads_event'); // already verified
if ($event['event'] === 'message.received') {
// $event['data']['from'], $event['data']['body'], $event['data']['referral']
}
return response()->noContent();
})->middleware('geekads.webhook')->withoutMiddleware(VerifyCsrfToken::class);
Testing
$fake = GeekAds::fake();
$user->notify(new InvoiceReady($invoice));
$fake->assertTemplateSent('919876543210', 'invoice_ready');
$fake->assertTextSent('919876543210');
$fake->assertOtpSent('919876543210');
$fake->assertNothingSent();
$fake->acceptOtp('123456'); // the code otp()->verify() accepts
Nothing leaves your test process.
License
MIT