@extends('backend.app') @section('title', 'WhatsApp Settings') @push('style') @endpush @section('content')
@include('backend.partials.breadcrumb', [ 'items' => [ ['url' => route('dashboard'), 'title' => 'Dashboard', 'icon' => 'fas fa-home'], [ 'url' => route('settings.index'), 'title' => 'Settings', 'icon' => 'fas fa-cog', ], ['title' => 'WhatsApp', 'icon' => 'fab fa-whatsapp'], ], ])
@csrf @if(session('success'))
Success! {{ session('success') }}
@endif @if ($errors->any())
Error: Please fix the following issues:
    @foreach ($errors->all() as $error)
  • {{ $error }}
  • @endforeach
@endif
Twilio WhatsApp Configuration
WhatsApp Integration - Configure your Twilio WhatsApp to send WhatsApp notifications. Get your credentials from Twilio Console. Enable WhatsApp sandbox from WhatsApp Sandbox.
Your Twilio Account SID from console
Keep this secret and secure
Your Twilio WhatsApp sandbox number (e.g., whatsapp:+14155238886)
Cancel
WhatsApp Templates
@php $lastSynced = $templates->max('content_synced_at'); @endphp @if ($lastSynced) Last synced with Twilio {{ $lastSynced->diffForHumans() }} @else Never synced with Twilio @endif
@php $approvalCounts = $templates->countBy('approval_status'); @endphp
{{ $approvalCounts['approved'] ?? 0 }} Approved {{ $approvalCounts['rejected'] ?? 0 }} Rejected {{ ($approvalCounts['pending'] ?? 0) + ($approvalCounts['received'] ?? 0) }} Pending {{ $templates->whereNull('content_sid')->count() }} Not Linked
@foreach ($templates as $template)
{{ $template->name }} {{ $template->slug }} {{ $template->approvalLabel() }} @if ($template->approval_category) {{ $template->approval_category }} @endif
@if ($template->content_sid)
{{ $template->content_sid }}
@endif @if ($template->approval_status === 'rejected')
Rejected by WhatsApp{{ $template->rejection_reason ? ': ' . $template->rejection_reason : '.' }} Messages using this template will not be delivered.
@elseif (!$template->content_sid)
Not linked to a Twilio template - sends as freeform text, which only works within the 24-hour customer service window.
@endif @php $openBrace = '{' . '{'; $closeBrace = '}' . '}'; $previewContent = preg_replace('/\{(\w+)\}/', $openBrace . '$1' . $closeBrace, $template->content); @endphp

{{ $previewContent }}

@if ($template->variables)
Variables: @foreach ($template->variables as $variable) {{ '{' }}{{ '{' }} {{ $variable }} {{ '}' }}{{ '}' }} @endforeach
@endif
@endforeach
WhatsApp Statistics

{{ $stats['total_sent'] ?? 0 }}

Total Sent

{{ $stats['total_failed'] ?? 0 }}

Failed

{{ $stats['today_sent'] ?? 0 }}

Today

{{ $stats['this_month_sent'] ?? 0 }}

This Month

@push('script') @php $whatsappTemplateData = $templates->map(fn($t) => [ 'id' => $t->id, 'name' => $t->name, 'slug' => $t->slug, 'content' => $t->content, 'variables' => $t->variables ?? [], 'content_variables' => $t->content_variables ?: ($t->variables ?? []), 'content_sid' => $t->content_sid, 'approval_status' => $t->approval_status, 'approval_label' => $t->approvalLabel(), 'approval_category' => $t->approval_category ?: 'UTILITY', 'is_approved' => $t->isApproved(), ])->values(); @endphp @endpush @endsection