@extends('layouts.admin') @section('title', setting('school_name', 'ShulePoint') . ' | WhatsApp Chatbot') @section('page-title', 'WhatsApp Chatbot') @section('content') {{-- Connection: this school's own WhatsApp Business number --}}

Connection — {{ $school->name }}

@if($school->whatsappReady()) Bot live @else Not configured @endif
@csrf @method('PUT')

Each school uses its own WhatsApp Business number. Meta calls one webhook for the whole system; messages are routed by the number they arrive on, and every lookup stays inside that school. Switch schools from the top bar to configure another number.

whatsapp_enabled))>
{{-- Commands: full CRUD --}}

Bot menu ({{ $commands->count() }})

@csrf
@forelse($commands as $c) @empty @endforelse
CommandDescriptionStatusActions
{{ $c->command }} {{ $c->description ?? '—' }} {!! $c->enabled ? 'On' : 'Off' !!}
@csrf @method('DELETE')
@csrf @method('PUT')
enabled)>
No commands yet.

Guardians type these exactly (leading / optional). The six built-ins fetch live data; free text goes to the AI layer, which may only pick one of these vetted commands — never raw data access.

{{-- Events: full CRUD --}}

School events

@csrf
@forelse($events as $e) @empty @endforelse
DateEventPublicActions
{{ $e->event_date->format('d/m/Y') }} {{ $e->title }}@if($e->location)
{{ $e->location }}@endif
{!! $e->is_public ? 'Yes' : 'No' !!}
@csrf @method('DELETE')
@csrf @method('PUT')
is_public)>
No events yet — add PTA days, sports, closing dates.
{{-- Linked guardians --}}

Linked guardians ({{ $links->total() }})

@forelse($links as $l) @empty @endforelse
LearnerWhatsAppVerified
{{ $l->learner->full_name ?? ('#'.$l->learner_id) }}
{{ $l->learner->admission_no ?? '' }} · {{ ucfirst($l->relationship) }}
{{ \App\Support\PhoneNumbers::mask($l->phone) }} {{ $l->verified_at?->format('d/m/Y') ?? '—' }}
@csrf @method('DELETE')
No linked numbers yet.
@if($links->hasPages()) @endif
{{-- Audit log --}}

Request audit latest 50

@forelse($logs as $g) @empty @endforelse
WhenCommandLearner
{{ $g->created_at->format('d/m H:i') }} {{ $g->command }} {{ $g->learner->full_name ?? ('#'.$g->learner_id) }}
No bot requests yet.

How guardians link

  1. Guardian messages this number: register 12345 (admission no).
  2. A 6-digit PIN goes by SMS to the phone on file (not the sender).
  3. Guardian replies with the PIN → number links to the learner plus siblings sharing that guardian phone.
  4. Unlinked numbers can only use register. Guardians reply STOP to unlink.
@endsection