- How do I choose between Meta Cloud API and whatsapp-web.js in this Laravel package?
- Use the Meta Cloud API for official business accounts with compliance needs, requiring approval and API credentials. Opt for whatsapp-web.js when you need personal-number access (e.g., testing, groups, or free-form messages) and can manage a sidecar process. The package auto-selects the best backend via the `WhatsApp::` facade, but you can manually specify with `WhatsApp::web('session-name')` or `WhatsApp::cloud()`.
- What Laravel versions does this package support, and are there breaking changes?
- The package is designed for Laravel 10+ and leverages modern features like Livewire 3.x and PHP 8.1+. Check the [changelog](https://github.com/kstmostofa/laravel-whatsapp/blob/main/CHANGELOG.md) for version-specific updates. Breaking changes are documented, but the facade pattern minimizes disruption. Always test migrations and configurations when upgrading.
- Can I use this package without Livewire, or is the admin UI mandatory?
- The Livewire admin UI is optional. You can disable it by removing the `livewire` tag from the published config or overriding the routes. The core functionality (sending/receiving messages, webhooks, and Eloquent models) works independently of Livewire. If you prefer Inertia.js or another frontend, you’ll need to rebuild the UI layer separately.
- How do I handle webhook HMAC verification for WhatsApp in production?
- The package includes built-in HMAC verification for Meta Cloud API webhooks via the `WHATSAPP_APP_SECRET` in your `.env`. For whatsapp-web.js, webhooks are processed asynchronously via Laravel events triggered by the `whatsapp:web:listen` daemon. Ensure your server’s firewall allows incoming requests to your webhook endpoint and monitor the `webhook` table for failed validations.
- What’s the best way to deploy the whatsapp-web.js sidecar in production?
- Deploy the sidecar as a Docker container or serverless function (e.g., AWS Lambda) with persistent session storage (e.g., Redis or a database). Use a process manager like PM2 or systemd to auto-restart the sidecar if it crashes. The sidecar requires a stable IP or dynamic DNS if using QR-based pairing. Monitor its health with `php artisan whatsapp:health` and set up alerts for session disconnections.
- How do I customize message templates for Meta Cloud API in this package?
- Templates are defined in the `whatsapp-templates` table or via the Livewire admin UI. Use the `WhatsApp::messages()->sendTemplate()` method with the template name and parameters. For dynamic templates, store them in the database and fetch them via Eloquent. The package supports both pre-approved and interactive templates, but ensure compliance with Meta’s template policies.
- Are there rate limits or cost considerations for the Meta Cloud API?
- Meta Cloud API has strict rate limits (e.g., 100 messages/minute for most plans) and charges per message or API call. Monitor usage via the `whatsapp_messages` table and set up alerts for approaching limits. The whatsapp-web.js backend is free but lacks official support and may have lower reliability. Always review Meta’s pricing and terms for your region.
- How do I test WhatsApp functionality in my Laravel app without breaking production?
- Use the whatsapp-web.js backend for testing with a personal number, as it doesn’t require Meta approval. Mock the `WhatsApp` facade in unit tests with Laravel’s `MockFacade` or use the `WHATSAPP_TEST_MODE=true` env variable to bypass API calls. For integration tests, deploy a staging environment with the Meta Cloud API credentials and validate webhook responses.
- Can I extend the package to add custom webhook handlers or message types?
- Yes, the package supports custom webhook handlers by publishing the event listeners and extending the `WhatsAppServiceProvider`. For custom message types (e.g., interactive buttons), extend the `WhatsAppMessage` model or create a new facade method. The facade pattern allows for easy overrides, but complex changes may require forking or contributing back to the package.
- What are the alternatives to this package for Laravel WhatsApp integration?
- Alternatives include `spatie/laravel-whatsapp` (simpler, Cloud API-only) or `mobiledetectio/laravel-whatsapp` (basic wrapper). For more control, use the official Meta Cloud API SDK directly or build a custom solution with `whatsapp-web.js`. This package stands out for its dual-backend support, Livewire UI, and deep Laravel integration, but evaluate your needs—simpler packages may suffice for basic use cases.