@php // SMS campaigns reuse the same builder (SMS is a sender option). When SMS is // connected, "New campaign" opens a WhatsApp / SMS chooser instead of jumping // straight to the WhatsApp builder — mirrors the broadcasts index. $__campWsId = (int) (auth()->user()?->current_workspace_id ?? 0); $smsCampaign = $__campWsId > 0 && (bool) \App\Models\SystemSetting::get('sms_enabled', false) && \App\Models\WaProviderConfig::query()->forWorkspace($__campWsId)->connected()->where('provider', 'sms')->exists(); // Email campaigns ride the same builder (a linked mailbox is just a sender). // hasConnected() checks BOTH the live bridge and a connected mirror row, so a // disconnected bridge takes the card away on the next render. The plan flag // gates it too — the same one WorkspaceEngine::senders and the runner check, // so a plan without Email can't reach the builder from here either. $emailCampaign = $__campWsId > 0 && (bool) \App\Models\SystemSetting::get('email_enabled', false) && \App\Services\PlanLimitGuard::hasFeature(auth()->user()?->currentWorkspace, 'access_email') && (\App\Models\EmailAccount::hasConnected($__campWsId) || \App\Models\WorkspaceEmailAccount::hasConnected($__campWsId)); // Any non-WhatsApp channel connected => "New campaign" opens the chooser. $campChannelPicker = $smsCampaign || $emailCampaign; $stats = $stats ?? [ 'total' => 0, 'queued' => 0, 'running' => 0, 'sent' => 0, 'failed' => 0, 'sent_total' => 0, 'delivered_total' => 0, 'read_total' => 0, 'failed_total' => 0, 'processing' => 0, 'messageTypes' => [], 'statusCounts' => [], 'deliveryHealth' => ['avg_delivery_rate' => 0, 'failing_campaigns' => 0, 'status' => 'healthy'], 'queueHealth' => ['template_approval_rate' => null, 'template_approved' => 0, 'template_total' => 0, 'devices_ready' => 'N/A', 'retry_backlog' => 0], ]; $campaigns = $campaigns ?? collect(); $currentStatus = $currentStatus ?? 'all'; $currentType = $currentType ?? 'all'; $currentRange = $currentRange ?? 'all'; $currentSearch = $currentSearch ?? ''; $statusCounts = $stats['statusCounts'] ?? []; @endphp @if (session('status') || $errors->any()) @push('scripts') @endpush @endif
{{ __('Workspace') }} · {{ auth()->user()?->currentWorkspace?->name ?: __('Workspace') }}

{{ __('WhatsApp') }} {{ __('campaigns') }}

{{ __('Broadcast queues, templates, flows, schedule status, and delivery outcomes in one place.') }}

@if ($campChannelPicker) @else New WA campaign @endif
@if ($campChannelPicker) {{-- Channel chooser — WhatsApp (template/text to phone contacts) vs SMS (Twilio / MSG91 text) vs Email (a linked mailbox). Same builder every time; the channel is just a sender. --}} @endif
{{ __('Sent') }}
{{ number_format($stats['sent_total']) }}
{{ number_format($stats['total']) }} campaigns
{{ __('Delivered') }}
{{ number_format($stats['delivered_total']) }}
@if ($stats['sent_total'] > 0) {{ number_format(($stats['delivered_total'] / max($stats['sent_total'], 1)) * 100, 1) }} @else 0 @endif % delivery
{{ __('Read') }}
{{ number_format($stats['read_total']) }}
@if ($stats['delivered_total'] > 0) {{ number_format(($stats['read_total'] / max($stats['delivered_total'], 1)) * 100, 1) }} @else 0 @endif % read rate
{{ __('Failed') }}
{{ number_format($stats['failed_total']) }}
{{ number_format($stats['failed']) }} failed campaigns
{{ __('Processing') }}
{{ number_format($stats['processing']) }}
{{ number_format($stats['queued']) }} queued
{{-- Top filter strip — date range pills + live search --}}
@foreach ([['all', 'All time'], ['7d', 'Last 7 days'], ['30d', 'Last 30 days'], ['90d', 'Last 90 days']] as [$rk, $rl]) @php $active = $currentRange === $rk; @endphp @endforeach
@include('user.wa-campaigns._cards', ['campaigns' => $campaigns])
@include('user.partials.pagination', [ 'paginator' => $campaigns, 'dataAttr' => 'data-wac-page', 'label' => 'campaigns', ])
{{ __('Help - 01') }}
{{ __('What is a WhatsApp campaign?') }}

{{ __('A broadcast queue that sends a custom message, approved template, or flow to selected contacts through your connected device.') }}

{{ __('Help - 02') }}
{{ __('How do I improve delivery?') }}

{{ __('Keep lists clean, use approved templates for outbound sends, and schedule larger broadcasts instead of pushing every contact at once.') }}

{{ __('Help - 03') }}
{{ __('Which campaign should I launch first?') }}

{{ __('Begin with a template update or re-engagement broadcast, then compare delivered, read, and failed counts before scaling.') }}