GovTech · AI / RAG · WhatsApp
Chatbot Pengawasan
On-premise WhatsApp AI assistant for Bawaslu Provinsi Sumatera Barat that answers only from official documents, citing the article and page it used.

Overview
An internal WhatsApp chatbot for Bawaslu Provinsi Sumatera Barat, the election supervisory agency of West Sumatra, serving around 250 registered supervision staff across the province's regencies and cities. Staff ask questions in WhatsApp; the assistant answers only from documents uploaded by admins — laws, work guides, best practices, FAQs and meeting outcomes — and cites the document, article and page behind every answer. When the documents don't cover a question, it says so plainly and offers a Live Chat hand-off to the supervision team. The language model runs on the agency's own server through Ollama, so no third-party AI service ever sees the data.
Architecture
Channels (WhatsApp Cloud API, Admin dashboard & simulator) → Webhook · HTMX → Go API (Webhook + signature check, PostgreSQL job queue) → Jobs → Worker (Menu, content & Live Chat, Hybrid retrieval + RRF, Anti-hallucination gates, OCR & chunking per article) → Local inference → On-premise AI (Ollama · Qwen 3.5 4B, bge-m3 embeddings, pgvector)
Key features
- Retrieval-augmented answers citing the source document, article (Pasal) and page
- Hybrid retrieval — pgvector embeddings plus PostgreSQL full-text search — fused with Reciprocal Rank Fusion
- Two anti-hallucination gates: a similarity threshold before the LLM is called, then checks on citations, numbers and refusals
- Ingestion pipeline: pdftotext / OCRmyPDF with Indonesian OCR, cleaning, chunking per article, bge-m3 embeddings
- WhatsApp Cloud API with webhook signature verification and a whitelist of registered numbers
- Live Chat hand-off to staff with service hours; the AI stays silent during a live session
- Admin dashboard (Go templates + HTMX): content library, users with CSV import, conversation logs, unanswered-question tracker, AI playground and a WhatsApp simulator
- Persistent PostgreSQL job queue that prioritises chat over ingestion, per-user daily limits and an answer cache
- Self-hosted deployment with Docker Compose, Caddy and backup/restore scripts; Qwen 3.5 (4B) runs locally via Ollama
Tech stack
- Go
- PostgreSQL
- pgvector
- Ollama
- Qwen 3.5
- HTMX
- WhatsApp Cloud API
- OCRmyPDF
- Docker
Screenshots
Want the details behind this project?
I'm happy to walk through the architecture, trade-offs and what I'd do differently.