AI · Analytics

WhatsApp School-Enquiry Agent

An AI agent that answers school leaders with their own school data

An agent on the official WhatsApp Cloud API that answers questions on central-exam schedules, Nafs results, school analytics and comparisons with the office, department and national levels — no database: a file index plus PHP tools compute every number, and the model only phrases the answer.

PHP (no framework)DeepSeek · Tool callingWhatsApp Cloud APIBM25Pure-PHP XLSX/DOCX readers
Illustrative conversation showing how the agent works
3,453
Schools indexed
77K+
Nafs result rows
8
Agent tools
~2s
Response time
The challenge

The department receives thousands of repetitive enquiries; sending huge spreadsheets (77K Nafs rows alone) to a language model is technically infeasible, costly and yields unreliable figures.

The solution

An indexer reads each file once, building a JSON file per school, comparison distributions and a BM25 document index; the model calls the right tool and receives a computed number. Each question costs a few thousand tokens and is answered in about two seconds.

Architecture: PHP computes, the model only phrases

Once, when a file is added
  1. data/ folderExcel · Word · PDF
  2. IndexerReads each file once
  3. File indexJSON per school · comparison distributions · BM25
On every question
  1. WhatsAppCloud API
  2. webhook.phpSignature & session check
  3. DeepSeekChooses a tool
  4. PHP toolsComputed from the school file
  5. ReplyIn about two seconds

Key capabilities

School authentication

Statistical code + principal mobile; every tool is scoped to the signed-in school

8 model tools

School card, query, aggregate, compare with region, trend over time, document search…

Drop-in knowledge folder

Any Excel, Word or PDF is added and indexed (absence, behaviour, circulars…)

Broadcast circulars

Approved template messages to all school leaders with opt-out

Leadership access

Special code allowing leaders to query any school

Rank & percentile

School rank and percentile at office, department and national levels

The data-governance angle

Figures are computed deterministically from source — never by the model; access is scoped per school and the index keeps the source of every number: data-quality and data-minimisation principles in practice.