Skip to main content

Overview

In this guide, we will cover how to handle incoming WhatsApp webhooks and events using the Hypersender Laravel SDK. Webhooks are a powerful way to receive real-time updates from WhatsApp, allowing your application to respond to messages, status changes, and other events as they happen.

Setting Up Webhooks

  1. The package auto-registers a POST route (default /whatsapp/webhook).
  2. Verifies the signature using the secret in config/env.
  3. Dispatches a dedicated Laravel event for each webhook event type (e.g., MessagesUpserted, GroupsUpdated, etc.).
  4. Listen for events in your app:
use Hypersender\Events\Whatsapp\PresenceUpdate;

Event::listen(PresenceUpdate::class, function ($event) {
    $event->payload
});
See the Webhook Usage in it’s dedicated section for more details webhook usage.

Available Webhook Events

The following events are available for handling WhatsApp webhooks:
  • Hypersender\Events\Whatsapp\PresenceUpdate
  • Hypersender\Events\Whatsapp\MessagesAny
  • Hypersender\Events\Whatsapp\MessageReaction
  • Hypersender\Events\Whatsapp\MessagesAck
  • Hypersender\Events\Whatsapp\MessagesWaiting
  • Hypersender\Events\Whatsapp\MessagesRevoked
  • Hypersender\Events\Whatsapp\PollVote
  • Hypersender\Events\Whatsapp\PollVoteFailed

Customizing the Webhook Route

To customize the webhook route, you can publish the package’s configuration file and modify the webhook_route setting:
php artisan vendor:publish --tag="hypersender-config"
Then, update the whatsapp_webhook_route in config/hypersender-config.php:
'whatsapp_webhook_route' => 'your/custom/route',
I