# WhatsApp Integration Plan

## Overview
Add WhatsApp as a notification channel to all 13 existing Laravel Notification classes, using the existing `TwilioService`, `NotificationHelper`, and `SmsTemplate` infrastructure.

## Architecture
- **Create** `app/Channels/WhatsAppChannel.php` - Custom Laravel notification channel
- **Create** `app/Messages/WhatsAppMessage.php` - Message class for WhatsApp
- **Modify** all 13 notification classes to add `toWhatsApp()` method and update `via()`
- **Keep** `NotificationHelper` as a convenience wrapper

---

## Step 1: Create WhatsAppChannel

**File:** `app/Channels/WhatsAppChannel.php`

```php
class WhatsAppChannel
{
    protected TwilioService $twilio;
    
    public function send(object $notifiable, Notification $notification): void
    {
        $message = $notification->toWhatsApp($notifiable);
        $phone = $notifiable->phone ?? null;
        
        if (!$phone || !$this->twilio->canSendSms()) {
            return;
        }
        
        if ($message->template) {
            $this->twilio->sendTemplate($phone, $message->template, $message->data, $notifiable->id);
        } else {
            $this->twilio->sendSms($phone, $message->body, $notifiable->id);
        }
    }
}
```

## Step 2: Create WhatsAppMessage

**File:** `app/Messages/WhatsAppMessage.php`

```php
class WhatsAppMessage
{
    public ?string $body = null;
    public ?string $template = null;
    public array $data = [];
    
    public static function create(): static { return new static(); }
    public function body(string $body): static { $this->body = $body; return $this; }
    public function template(string $slug, array $data = []): static { 
        $this->template = $slug; 
        $this->data = $data; 
        return $this; 
    }
}
```

## Step 3: Template Slug Mapping

| Notification | Template Slug |
|---|---|
| BookingCreatedNotification | `booking-confirmation-client` / `booking-confirmation-professional` |
| BookingCancelledNotification | `booking-cancelled-client` |
| BookingStatusChangedNotification | `booking-status-changed` |
| OtpNotification | `otp-verification` |
| CreateEmployeeNotification | `employee-welcome` |
| SubscriptionStartedNotification | `subscription-started` |
| SubscriptionCancelledNotification | `subscription-cancelled` |
| SubscriptionEndedNotification | `subscription-ended` |
| SubscriptionWelcomeNotification | `subscription-welcome` |
| UpcomingRenewalNotification | `subscription-renewal-reminder` |
| PaymentSuccessfulNotification | `payment-successful` |
| PaymentFailedNotification | `payment-failed` |
| AdminAlertNotification | `admin-alert-{event}` |

## Step 4: Cron Job Integration

No changes needed - cron jobs already use `NotificationService::sendByEvent()` which supports WhatsApp automatically.

## Files to Create
1. `app/Channels/WhatsAppChannel.php`
2. `app/Messages/WhatsAppMessage.php`

## Files to Modify (13 notification classes)
1. `app/Notifications/BookingCreatedNotification.php`
2. `app/Notifications/BookingCancelledNotification.php`
3. `app/Notifications/BookingStatusChangedNotification.php`
4. `app/Notifications/AdminAlertNotification.php`
5. `app/Notifications/OtpNotification.php`
6. `app/Notifications/CreateEmployeeNotification.php`
7. `app/Notifications/SubscriptionStartedNotification.php`
8. `app/Notifications/SubscriptionCancelledNotification.php`
9. `app/Notifications/SubscriptionEndedNotification.php`
10. `app/Notifications/SubscriptionWelcomeNotification.php`
11. `app/Notifications/UpcomingRenewalNotification.php`
12. `app/Notifications/PaymentSuccessfulNotification.php`
13. `app/Notifications/PaymentFailedNotification.php`
