Developer guides
Laravel Rust WhatsApp: Send and Receive Messages
Laravel Rust WhatsApp guide: send messages from your own number with the hypersender-laravel-rust crate and reply to incoming ones from a listener.


Laravel Rust WhatsApp messaging takes one crate: hypersender-laravel-rust, the Hypersender package for Laravel Rust. Laravel Rust came out in beta on December 1, 2026, and this guide uses it to send a WhatsApp message from your own number, reply to incoming messages with an event listener, and test both without touching the network.
What you need
- Rust 1.99 or newer and the Laravel CLI, as the Laravel Rust installation guide describes.
- A Hypersender account with a WhatsApp instance. You link your number by scanning a QR code, the same way you'd link WhatsApp Web, so there's no Meta business verification and no message templates.
Create an app if you don't have one:
laravel new whatsapp-demo --rust
cd whatsapp-demoInstall the package
cargo add hypersender-laravel-rustLaravel Rust packages ship a service provider. Register it in src/app.rs:
use laravel::Application;
Application::configure()
.with_providers(|providers| {
providers.add(hypersender_laravel_rust::HypersenderServiceProvider);
})Then copy the instance ID and API token from your instance page in the dashboard into .env:
HYPERSENDER_WHATSAPP_API_KEY=your_api_token
HYPERSENDER_WHATSAPP_INSTANCE_ID=your_instance_idThe provider registers a Whatsapp service, an Sms service, an Otp service and two webhook routes. The package keeps laravel-rust default features off, as the Laravel Rust package guide asks, so it doesn't add Inertia or MiniJinja to your build.
Send a WhatsApp message from Laravel Rust
Inject Whatsapp into any handler, listener, job or command:
use hypersender_laravel_rust::Whatsapp;
use laravel::container::Inject;
pub async fn send(whatsapp: Inject<Whatsapp>) -> laravel::Result<String> {
whatsapp
.send_text("201001234567@c.us", "Hi Omar, your order #1042 has shipped.")
.await?;
Ok("Sent".into())
}Add route.get("/send", send); to src/routes/web.rs, run laravel dev, open http://127.0.0.1:8000/send, and the message reaches the phone a moment later.
- The chat ID is the number with its country code and no
+, followed by@c.us. Groups end in@g.us. send_textsends right away.safe_send_textshows "typing…" and pauses first, which suits many messages in a row.- A non-2xx answer from Hypersender comes back as an error, so
?stops the handler instead of carrying on silently.
Send an image or a file
URL methods take a link, and upload methods take a Laravel Attachment:
use laravel::http::client::Attachment;
whatsapp
.send_image_url("201001234567@c.us", "https://example.com/receipts/1042.png", Some("Your receipt"))
.await?;
whatsapp
.send_file("201001234567@c.us", Attachment::from_path("storage/app/invoice-1042.pdf"), Some("Invoice #1042"))
.await?;Video, voice notes, locations and polls have their own methods. For any endpoint without one, whatsapp.post("/endpoint", json!({ .. })) calls it directly.
Receive messages and reply
The package adds POST /api/whatsapp/webhook in the api route group, so CSRF protection doesn't block it. Each webhook becomes a Laravel event: MessageAny, MessageAck, MessageRevoked, MessageWaiting and the rest. This listener answers every new message:
use hypersender_laravel_rust::Whatsapp;
use hypersender_laravel_rust::events::MessageAny;
use laravel::container::Inject;
use laravel::event::{Event, listener};
#[listener]
pub async fn auto_reply(event: Event<MessageAny>, whatsapp: Inject<Whatsapp>) -> laravel::Result<()> {
let message = &event.payload["data"]["payload"];
// message.any also fires for messages you send, so skip those.
if message["fromMe"] == true {
return Ok(());
}
whatsapp
.send_text(message["from"].as_str().unwrap_or_default(), "Thanks, we got your message")
.await?;
Ok(())
}Put it in src/listeners/ and Laravel Rust discovers it. While you build, expose the app with a tunnel such as ngrok, then add https://<your-tunnel>/api/whatsapp/webhook to your instance's webhooks in the dashboard. Message your number from another phone and the reply comes back.
- If you set an authorization secret in the dashboard, put the same value in
HYPERSENDER_WHATSAPP_WEBHOOK_AUTHORIZATION_SECRET. Requests without it get a401. - The route answers Hypersender straight away and runs listeners in the background. For work that must finish, use
#[listener(queued)]; every event derivesQueueable. - The Laravel Rust WhatsApp webhooks docs list every event and its payload.
Test it without sending real messages
The package makes its calls through Laravel's HTTP client, so client::fake() catches them in your tests:
use laravel::http::client;
use laravel::testing::prelude::*;
#[laravel::test]
async fn shipping_sends_a_whatsapp_message(app: Application) {
let http = client::fake();
app.get("/send").await.assert_ok();
http.assert_sent(|request| request.url().ends_with("/send-text"));
}SMS and OTP from the same package
Sms sends from the SIM in an Android phone running the Hypersender SMS app, and Otp sends login codes and one-tap WhatsApp login links. The Laravel Rust OTP use case walks through a sign-in flow. The PHP version of this package is covered in Laravel WhatsApp package.
Price
WhatsApp plans start at $9.99 per number a month with unlimited messages, and the first 5 days are free. The package is MIT licensed, and the source is on GitHub.
Create a Hypersender account, link your number with a QR code and send your first WhatsApp message from Laravel Rust.





