@extends('layouts.app') @section('title', __('whatsappnotification::lang.whatsapp_notification') . ' - ' . ($template ? __('whatsappnotification::lang.edit_template') : __('whatsappnotification::lang.add_template'))) @section('content') @component('components.widget', ['class' => 'box-primary']) @slot('title') {{ $template ? __('whatsappnotification::lang.edit_template') : __('whatsappnotification::lang.add_template') }} @endslot @slot('tool') {{ __('whatsappnotification::lang.back_to_templates') }} @endslot @if ($errors->any())
@endif

Quick Template Presets

Choose a preset, then select your provider. For Official Meta Cloud API, click Load templates and choose your approved Meta template.

@php $form_action = $template ? route('whatsappnotification.templates.update', $template->id) : route('whatsappnotification.templates.store'); $buttons = $template ? ($template->template_buttons ?? []) : []; $trigger_type = old('trigger_type', $template->trigger_type ?? 'new_sale'); $provider = old('provider', $template->provider ?? 'unofficial'); $meta_body_params = old('meta_body_params', (isset($template) && !empty($template->meta_components_mapping['body_params'])) ? implode("\n", $template->meta_components_mapping['body_params']) : '' ); $meta_header_media_url = old('meta_header_media_url', (isset($template) && !empty($template->meta_components_mapping['header_media_url'])) ? $template->meta_components_mapping['header_media_url'] : '' ); @endphp {!! Form::open(['url' => $form_action, 'method' => $template ? 'PUT' : 'POST']) !!} {{-- Basic Info --}}

{{ __('whatsappnotification::lang.template_info') }}


{!! Form::label('name', __('whatsappnotification::lang.template_name') . ':') !!} {!! Form::text('name', old('name', $template->name ?? ''), ['class' => 'form-control', 'placeholder' => 'e.g. Payment Reminder - Overdue 7 Days', 'required' => true]) !!}
{!! Form::label('trigger_type', __('whatsappnotification::lang.trigger_type') . ':') !!} {!! Form::select('trigger_type', $trigger_labels, old('trigger_type', $template->trigger_type ?? 'new_sale'), ['class' => 'form-control', 'id' => 'trigger_type_select']) !!}

{{-- Provider selection: unofficial (default) or Meta Official Cloud API --}}
{!! Form::label('provider', 'Send via:') !!} {!! Form::select('provider', ['unofficial' => 'Unofficial (personal WhatsApp / QR-paired)', 'meta_official' => 'Meta Official Cloud API'], $provider, ['class' => 'form-control', 'id' => 'provider_select']) !!}

Unofficial = free-form text via QR-paired instance. Meta = billable, template-only, higher deliverability.

{{-- Meta template config — visible only when provider = meta_official --}}

Meta Official Template


{!! Form::label('meta_template_name', 'Approved Meta Template:') !!}

Loads only approved templates from your Meta WABA. Save Meta API key in Settings first.

@if(!empty($template->meta_template_name))

Currently: {{ $template->meta_template_name }} ({{ $template->meta_language }})

@endif
{!! Form::label('meta_body_params', 'Body Parameters (one per line, in order):') !!} {!! Form::textarea('meta_body_params', $meta_body_params, ['class' => 'form-control', 'rows' => 4, 'placeholder' => "{customer_name}\n{invoice_no}\n{total_amount}"]) !!}

Each line maps to one Meta variable position (@{{1}}, @{{2}}, …) in your template's body, in order. Use any placeholder tag from the list below (e.g. {customer_name}, {invoice_no}).

{!! Form::label('meta_header_media_url', 'Header Media URL (optional):') !!} {!! Form::text('meta_header_media_url', $meta_header_media_url, ['class' => 'form-control', 'placeholder' => 'e.g. {invoice_pdf_url} — leave blank if template has no media header']) !!}

Used only if your Meta template has an image/video/document header. Supports placeholders like {invoice_pdf_url}.

{{-- Payment Reminder Settings (shown only when trigger_type = payment_reminder) --}}

{{ __('whatsappnotification::lang.payment_reminder_settings') }}


{!! Form::label('reminder_days_overdue', __('whatsappnotification::lang.reminder_days_overdue') . ':') !!} {!! Form::number('reminder_days_overdue', old('reminder_days_overdue', $template->reminder_days_overdue ?? 0), ['class' => 'form-control', 'min' => 0, 'placeholder' => '0 = any outstanding balance']) !!}

{{ __('whatsappnotification::lang.reminder_days_overdue_help') }}

{!! Form::label('reminder_send_time', __('whatsappnotification::lang.reminder_send_time') . ':') !!} {!! Form::time('reminder_send_time', old('reminder_send_time', $template->reminder_send_time ?? '09:00'), ['class' => 'form-control']) !!}

{{ __('whatsappnotification::lang.reminder_send_time_help') }}

{{ __('whatsappnotification::lang.payment_reminder_cron_note') }}
{{-- Message Template --}}

{{ __('whatsappnotification::lang.message_template') }}


{!! Form::label('message_title', __('whatsappnotification::lang.message_title') . ':') !!} {!! Form::textarea('message_title', old('message_title', $template->message_title ?? ''), ['class' => 'form-control', 'rows' => 5, 'placeholder' => 'Dear {customer_name}, your invoice #{invoice_no} has an outstanding due of ₹{total_due}.']) !!}
{!! Form::label('message_footer', __('whatsappnotification::lang.message_footer') . ':') !!} {!! Form::text('message_footer', old('message_footer', $template->message_footer ?? ''), ['class' => 'form-control', 'placeholder' => '{business_name} - {business_phone}']) !!}
{{ __('whatsappnotification::lang.available_tags') }}
{invoice_no} — Invoice No
{invoice_url} — Invoice URL
{total_amount} — Total Amount
{total_paid} — Total Paid
{total_due} — Total Due
{contact_name} — Customer Name
{customer_mobile} — Mobile
{business_name} — Business Name
{transaction_date} — Date
{payment_status} — Payment Status
— Payment Reminder Tags —
{overdue_days} — Days Overdue
{due_date} — Due Date
{{-- Template Buttons --}}

{{ __('whatsappnotification::lang.template_buttons') }}

{{ __('whatsappnotification::lang.template_buttons_help') }}


@foreach($buttons as $index => $btn)
@if(($btn['type'] ?? 'urlButton') == 'urlButton')
@elseif(($btn['type'] ?? '') == 'callButton')
@elseif(($btn['type'] ?? '') == 'quickReplyButton')
@elseif(($btn['type'] ?? '') == 'copyCodeButton')
@endif
@endforeach
Max 3 buttons per message

{{ __('lang_v1.cancel') }}
{!! Form::close() !!} @endcomponent @stop @section('javascript') @endsection