- How do I send an SMS notification using Vonage in Laravel?
- Use Laravel’s `Notification` facade to dispatch a notification class extending `Notification`. The channel is registered as 'vonage', so call `$user->notify(new YourNotification)` where `YourNotification` uses `VonageMessage`. Example: `new VonageMessage('Your OTP code: 12345')`.
- What Laravel versions does this package support?
- This package requires **Laravel 10.x or higher** and **PHP 8.1+**. Check compatibility with your version by reviewing the [Laravel documentation](https://laravel.com/docs/notifications#sms-notifications) for breaking changes in newer releases.
- Can I use fallback channels if Vonage SMS fails?
- Yes. Configure fallback channels in your notification class by overriding the `via()` method. For example, `public function via($notifiable) { return ['vonage', 'mail']; }`. The notification will attempt Vonage first, then fall back to email or other channels.
- How do I configure Vonage API credentials?
- Add your Vonage credentials to `.env`: `VONAGE_SID=your_sid`, `VONAGE_AUTH_TOKEN=your_token`, and `VONAGE_FROM=YourApp`. Then, register the channel in `config/services.php` under the `'vonage'` key. No additional steps are needed for basic usage.
- Does this package support async notifications via Laravel queues?
- Yes. The package integrates with Laravel’s queue system (database, Redis, etc.). Dispatch notifications with `->delay()` or use `queue:work` to process them asynchronously. This is ideal for high-volume SMS notifications to avoid timeouts.
- How do I handle rate limits or API failures from Vonage?
- Laravel’s notification system supports retries. Configure retries in your notification class with `->later()` or use Laravel’s `retry-after` logic. Monitor Vonage’s API status and log failures for debugging. Fallback channels (like email) can also mitigate disruptions.
- Can I customize SMS message formatting or templates?
- Yes. Extend the `VonageMessage` class or override the `toVonage()` method in your notification class to customize content. Handle SMS-specific constraints (e.g., 1600-character limit, Unicode) by preprocessing messages before sending.
- Is there a sandbox or test environment for Vonage?
- Vonage provides a sandbox environment for testing. Use Vonage’s sandbox credentials in your `.env` during development or CI/CD. The package doesn’t enforce sandbox mode—you must configure it manually via Vonage’s dashboard.
- How do I manage Vonage credentials for multi-tenant applications?
- Store tenant-specific credentials in a `tenants` table or use environment variables per tenant. Override the channel configuration dynamically in your notification logic or via a service provider. Avoid hardcoding credentials in the app.
- Are there alternatives to this package for SMS notifications in Laravel?
- Yes. Alternatives include third-party packages like `spatie/laravel-notification-channels-twilio` or `laravel-notification-channels/nexmo`. However, this is the **official Vonage channel**, ensuring tight integration with Laravel’s notification system and Vonage’s API. Evaluate based on your needs for Vonage-specific features like Verify API integration.