PIPELINE  LANGGRAPH + MCPLLM  GROQ · QWENEVAL  92 MSGSRUNS  EVERY 30 MIN
LEVEL P-02ZERO DUPLICATES
◂ ALL PROJECTS
CASE FILE P-02 ── LLM · AGENTS · EVALS

KHATA
AI

WHATSAPP PAYMENT EXTRACTION PIPELINE

Small businesses run on WhatsApp: “Sharma Traders, Jaipur received ₹15,000, UTR12345”. KhataAI turns that chat stream into a 10-column Google Sheets ledger, a daily WhatsApp summary and a live dashboard.

Fully automatic and privacy-first, built on the Model Context Protocol.

THE LLM GETS NO TOOLS
It only turns text into JSON. It cannot read chats, send messages or touch the Sheet: Python does all I/O and arithmetic.
SCREEN ── LEDGERTEST DATA
KHATAAI — WHATSAPP PAYMENT EXTRACTION PIPELINE screenshot
▸ RUN PIPELINE NOW
SCORESCOREBOARD
HELD-OUT FIELD ACC.
100%
v2 prompt on 30 messages never used for tuning (v1: 94.8%).
HALLUCINATED FIELDS
0%
Held-out set, v2 prompt (v1: 2.9%).
EVAL SET
92
62 dev + 30 held-out messages, English and Hinglish.
TOOLS GIVEN TO LLM
0
Down from 8 Sheets tools in v1.
PATHV1 → V2
V1 AGENTLLM▸8 SHEETS TOOLS▸COUNT ROWS▸UNBOUNDED LOOPjunk rows
V2 GRAPHDISCOVER GROUPS▶FETCH▶FILTER NEW▶EXTRACT JSON▶WRITE SHEET▶MARK PROCESSED

Each node calls one small function and the routers are plain if/else. Messages are marked processed only after a successful write, so a failed run retries the same messages next time.

BOSSHOW IT HOLDS UP
CORE AEVALUATION

Hand-labelled synthetic sets, scored field by field after normalisation. Five of v1's six dev failures were one pattern: a business name put in client_name. v2 defines every field.

PRECISION96.7%
RECALL100%
FIELD ACCURACY100%
FULLY CORRECT96.7%
Held-out set, v2 prompt, 3 runs with identical scores.
CORE BRELIABILITY

SQLite dedup plus commit-after-write, a cross-process lock so the scheduler and the dashboard button never double-ingest, and Pydantic validation with one retry.

DEDUPSQLITE
LOCKSINGLE-RUN
OUTPUTPYDANTIC
EXIT CODES0 OK · 1 ERR
Known failure: v2 reads one delivery-order message per set as a transaction.
FIG 1 ── HELD-OUT RESULTSV1 vs V2 PROMPT
V1 FIELD
94.8%
V2 FIELD
100%
V1 MSGS
80%
V2 MSGS
96.7%
FIELD = field accuracy · MSGS = messages fully correct
VERDICT
Eval first, prompt second: held-out field accuracy went from 94.8% to 100%.
The eval also caught a production bug: 20 messages per call needed ~1,900 output tokens, above Groq's free-tier limit, so extraction now runs in batches of 5 with backoff.
NEXT LEVEL
▸ Persistent MCP sessions (each tool call starts the server today, ~6 s).
▸ Message-ID based dedup instead of full-text dedup.
▸ Optional allowlist for individual chats.
▸ Always-on listener instead of 30-minute polling.
SELECTENTRY POINTS
RUN
P-02 · 01
CLIENT.PY

Every 30 minutes or from the dashboard button: new WhatsApp messages → Sheet.

SUM
P-02 · 02
SUMMARY.PY

Daily at 21:00: today's totals → WhatsApp, in plain Python math.

DASH
P-02 · 03
DASHBOARD.PY

KPIs, filters, charts, the ledger and a Run pipeline now button.

LEVEL MAPROUTES
M1CLEAR
NEW + TRANSACTIONS
extract → write → mark
M2CLEAR
NO NEW MESSAGES
filter → end
M3CLEAR
ONLY CHIT-CHAT
marked, never resent
M4LOCKED
LLM FAILS TWICE
nothing marked, retried
M5LOCKED
SHEET WRITE FAILS
nothing marked, retried
RULES OF PLAY
▸ The LLM gets text, never tools.
▸ Mark processed only after a successful write.
▸ Python copies Date & Time and Original Message; the LLM never types them.
▸ The summary refuses to post into a monitored group.
ARTEFACTS
STACK ▸ Python · LangGraph · MCP · Groq · Pydantic
STORAGE ▸ Google Sheets · SQLite
UI ▸ Streamlit dashboard
SCHEDULE ▸ Windows Task Scheduler
[ ▸ LIVE DEMO ]
[ ▸ WATCH DEMO ]
[ ▸ SOURCE CODE ]
◂ P-01 TRAVELOS CONTINUE? ▸ ALL PROJECTS P-03 ETAGRAPH ▸
LOKESH KUMAR
IIT Roorkee engineer building AI agents, LLM evals and data systems that change real decisions.
CONTACT
MAIL ▸ lokeshkumar22119032@gmail.com
GHUB ▸ github.com/lokifergusion9
LNKD ▸ in/lokesh-kumar-1768262b9
INDEX
░▒▓ END OF FILE ▓▒░LOKESH KUMAR · MMXXVI