A Laravel-friendly pattern for sending WhatsApp messages from jobs and controllers.
Install nothing exotic
Laravel's HTTP client is enough.
use Illuminate\Support\Facades\Http;
// Use the instance API key from the dashboard. Instance is resolved from the key.
Http::withToken(config('services.flaresend.key'))
->post('https://api.flaresend.com/send-message', [
'recipients' => [$phone],
'type' => 'text',
'text' => $message,
]);
Where to call it
- After user registration (OTP)
- In a queued job after M-Pesa callback
- From a scheduled command for reminders
Laravel patterns that work well
ShouldQueuejobs for every send- Idempotent job middleware keyed by
payment_id/otp_id - Config values for API key and base URL (never hard-code secrets)
- Feature flags to disable WhatsApp in local/staging without breaking flows
Useful product pages
Tip
Keep WhatsApp sends in queues so web requests stay fast, and alert on job failures the same way you alert on failed payments.
Example job skeleton
Create SendWhatsAppTextJob with phone and text. On failure, release with backoff. On final failure, notify Slack or email. Tag logs with payment_id or user_id for tracing. This pattern keeps controllers thin and retries safe.
Config and environments
Use different FlareSend keys for staging and production. Never send staging OTPs to real customers. Gate sends behind APP_ENV checks plus an explicit feature flag.
Practical scenarios
Here are concrete situations teams solve with this topic.
Scenario A — early-stage product
You need to prove WhatsApp automation this week. Connect a QR-linked number, send a transactional message, and measure whether customers understand and act. Keep the copy short. Log every API response. Expand only after the first path is reliable.
Scenario B — growing SME
Volume is rising and manual WhatsApp replies are failing. Automate the top one or two events first (usually payment or OTP). Train support on what the system already sends. Add scheduling and webhooks after the basics are stable.
Scenario C — developer platform
You are embedding WhatsApp into your own SaaS. Wrap FlareSend behind your service layer so product code never hard-codes HTTP details. Use queues, idempotency keys, and environment-specific API keys. Document the contract for your teammates.
Quality bar before you go live
- Happy-path send works on a real phone.
- Failure path shows a clear customer message or retry.
- Disconnects are visible to an operator.
- Consent or transactional justification is written down.
- Someone owns monitoring for the next 30 days.
Common mistakes
- Treating WhatsApp like email blast infrastructure
- Mixing marketing copy into OTP or payment messages
- Ignoring quiet hours across African timezones
- Skipping idempotency on payment webhooks
- Leaving staging keys pointed at production numbers
Fix those five and most production incidents disappear before they start.
What to read next on FlareSend
Browse related solution pages from the footer Solutions menu, skim the FAQ for safety and pricing questions, and keep the API docs open while you implement. When you are ready, start the free trial and ship one real customer workflow end to end.
Field notes from production teams
Teams that succeed with WhatsApp automation treat it like payments infrastructure: monitored, idempotent, and owned by a named engineer. They write runbooks for disconnects, keep a staging number for tests, and review failed sends in the same standup as failed transactions. They also refuse to use the channel for unsolicited cold outreach, because reputation damage is expensive to reverse.
If you are mid-implementation, pick one customer journey, instrument it, and only then expand. Breadth without reliability creates noisy support queues. Depth with clear metrics creates a channel customers trust.
Finally, keep FlareSend docs and your internal README linked from the same place. On-call engineers should not hunt for curl examples during an incident.
Implementation checklist
- Confirm consent or transactional context before sending.
- Store API responses for support audits.
- Prefer background jobs so web requests stay fast.
- Respect quiet hours for your customers' timezones.
- Link every automation to a clear customer benefit.
Related FlareSend resources
Try FlareSend
Connect WhatsApp in minutes and send OTPs, notifications, or bulk messages from one API.
Start free 4-day trial View pricing