- How do I send SMS notifications via Vonage in Laravel using this package?
- First, install the package via Composer: `composer require laravel/vonage-notification-channel`. Configure your Vonage API keys in `.env` (e.g., `VONAGE_KEY`, `VONAGE_SECRET`). Then, extend your notification class with `VonageChannel` and use it like any other Laravel notification. For example, `new OrderShipped($user, 'Your OTP: 12345')` with `VonageChannel` as the channel.
- Does this package support async SMS delivery for high-volume notifications?
- Yes, the package fully supports Laravel’s queue system (e.g., database, Redis). To enable async delivery, implement the `ShouldQueue` interface in your notification class. This is ideal for scaling SMS delivery without blocking your application’s response time.
- What Laravel and PHP versions are officially supported by this package?
- The package officially supports Laravel 10+ and requires PHP 8.1+. If you’re using an older Laravel version (e.g., 8.x), you may need to check for compatibility or use a forked version. Always verify your environment matches the package’s requirements before installation.
- How do I handle Vonage API rate limits or throttling errors in production?
- Vonage’s SMS API has rate limits (e.g., 1 SMS/sec by default). To handle throttling, implement retry logic with exponential backoff in your application. Laravel’s queue system can help by retrying failed jobs automatically. Monitor logs for HTTP 429 (Too Many Requests) errors and adjust your sending rate accordingly.
- Can I use this package for OTP (One-Time Password) SMS notifications?
- Absolutely. This package is perfect for OTPs. Simply create a notification class that extends `VonageChannel` and pass dynamic content (e.g., the OTP code) to the message template. Ensure your Vonage number is verified for transactional messages, and consider using a dedicated number for better deliverability.
- How do I configure dynamic SMS templates for personalized messages?
- Dynamic templates are supported by passing variables to the notification constructor. For example, `new OTPNotification($user, $otpCode)` and then referencing `$otpCode` in your message template. The package uses Laravel’s notification system, so you can leverage blade templates or plain text with placeholders for personalization.
- Is there a way to receive delivery receipts or track failed SMS notifications?
- Vonage provides message status callbacks, but the package itself doesn’t include built-in webhook handling for real-time failure notifications. You’ll need to set up a webhook endpoint in your application to listen for Vonage’s delivery status updates. Log these events and trigger fallback actions (e.g., email) if needed.
- What are the alternatives to this package for sending SMS in Laravel?
- Alternatives include third-party packages like `nesbot/carbon` for date handling (not SMS-specific) or `spatie/laravel-sms-notifications`, which supports multiple SMS providers. However, this package is the official Laravel solution for Vonage, offering tight integration with Laravel’s notification system and Vonage’s API features like Unicode SMS and number validation.
- How do I test SMS notifications locally without sending real messages?
- Vonage offers a sandbox API for testing. Configure your `.env` with sandbox credentials (e.g., `VONAGE_SANDBOX=true`). The package will route messages to Vonage’s test environment, where you can verify delivery without incurring costs. Ensure your test numbers are registered in Vonage’s sandbox dashboard.
- Can I use this package alongside other notification channels like Mail or Slack?
- Yes, this package is designed to work seamlessly with Laravel’s multi-channel notification system. You can send SMS notifications alongside email, Slack, or database notifications in a single notification class. For example, a `UserRegistered` notification could include `MailChannel`, `VonageChannel`, and `SlackChannel` for a unified user experience.