Skip to main content

Overview

The service provider adds a webhook route to your app’s api group:
When a request arrives, the package checks the secret, reads the event name from the body, and dispatches the matching Laravel event in the background. It answers Hypersender with 200 right away, so slow listeners never cause a timeout. Routes in the api group skip CSRF protection, so Hypersender can post to it without a token.

Set up the webhook

1

Give Hypersender a public URL

Hypersender can’t reach localhost. In development, expose your app with a tunnel such as ngrok (ngrok http 8000) and use https://<your-tunnel>/api/whatsapp/webhook.
2

Add the webhook in the dashboard

Open your WhatsApp instance in the Hypersender dashboard, add the URL and pick the events you want.
3

Set a secret (recommended)

If you set an Authorization Secret on the webhook, put the same value in .env. Requests without it get a 401.
.env
To use another path, set HYPERSENDER_WHATSAPP_WEBHOOK_ROUTE=/hooks/whatsapp. The route stays under /api, so this one becomes /api/hooks/whatsapp.

Events

Every event is a struct in hypersender_laravel::events with one field, payload, holding the full JSON body Hypersender sent. A request with an unknown event gets a 422 and dispatches nothing. Payload fields for each event are in the WhatsApp webhooks reference. The body looks like this, so the message itself is at payload["data"]["payload"]:

Listen for an event

Write a listener the way you would for any Laravel Rust event. Your app discovers #[listener] functions in its own crate automatically.
src/listeners/log_receipts.rs

Build a WhatsApp auto-reply bot

This listener answers every incoming message. It injects Whatsapp to send the reply.
src/listeners/auto_reply.rs
Always skip fromMe messages in a MessageAny listener that sends messages. Your own reply fires message.any too, and without the check the bot answers itself forever.

Queued listeners

The webhook runs listeners in a background task. Background tasks live in memory and aren’t retried, so a crash or deploy can lose one. For work that must finish, such as writing to your database or calling another API, use a queued listener. Every event derives Queueable:
Start a worker as described in the Laravel Rust queue docs.

Test your listeners

event::fake() records events instead of running listeners:
Last modified on December 2, 2026