Section 1One message, ten stages, under two seconds
Every farmer message goes through the same fixed sequence. Stages are deterministic code unless marked; the model never decides what the advice is, only how a general answer is worded.
Section 2Five intents, one winner
The router counts keyword hits per intent. If any emergency word is present the message is an emergency regardless of what else it says. Otherwise the highest score wins, with diagnosis beating market and weather when tied. Twi is detected from characters like ɛ and ɔ and from common words such as aburo (maize) or osuo (rain).
| Intent | Typical message | What answers it |
|---|---|---|
| EMERGENCY | "Armyworm everywhere", "my child drank the chemical" | Holding message now, interim advice for pests, officer within 4 h |
| DIAGNOSTIC | "Maize leaves yellow from the tip" | Knowledge base → economic filter → template |
| MARKET_INPUT | "Price of NPK near Ejura" | Verified dealer stock within 25 km, up to 4 offers |
| WEATHER | "Should I plant now?" | 14-day rain vs 10-year normal, 7-day outlook, spray window |
| GENERAL | "How far apart do I plant maize?", "How do I make compost?", "Are there fires near me?" | First the agronomy FAQ (planting calendar, spacing, fertiliser, storage, safe spraying: rule-matched, fixed text). Only when no FAQ topic matches does the local model answer, with the farm's weather and crops as context, then the guardrail |
Section 3The safety gate
Before any advice is written, the message is checked against four lists. Any hit creates a hold: the farmer gets an immediate acknowledgement and the case goes to an officer. Nothing the model writes can lift a hold.
Section 4Where the advice comes from
Diagnoses come from a hand-written knowledge base of 109 problems across 14 crops (maize, cassava, hot pepper, cowpea, plantain, cocoa, yam, tomato, garden egg, okra, groundnut, rice, cocoyam, cabbage) plus about 60 practice topics, condensed from CABI PlantwisePlus, FAO and CSIR-CRI guidance. Each problem has symptom keywords and an ordered list of treatments: cultural (no cost) first, then biological, then a chemical only if a product in the catalog is named. Confidence is 35% plus 15% per matched symptom, capped at 95%, nudged up when the satellite shows stress or the soil layer shows low nitrogen.
docs/KB_AUDIT.md.docs/twi_review.csv).Section 5The money rule
A product is only recommended if a verified dealer within 25 km has it in stock and the cost per acre is within the smaller of two caps:
Anything that fails is dropped and replaced by neem oil if that passes, otherwise by a home-made neem extract recipe. Seed is treated as a planting investment: stock-checked but not budget-capped. The farmer always leaves with something they can do today, and the reply says in brackets why a product was left out.
Section 6Data behind every reply
| Signal | Source | How it is used |
|---|---|---|
| Crop vigour (NDVI) | Sentinel-2 L2A via Earth Search, clearest scene from the last 90 days, cloud-masked 3×3 window around the plot | Ratio to a seasonal baseline: ≥0.90 none · ≥0.78 mild · ≥0.60 moderate · below severe. Hazy scenes (>35% cloud) are flagged and the reply says the reading is uncertain. |
| Rain, past 14 days | Open-Meteo forecast API, Africa/Accra time | Compared with a 10-year ERA5 climatology for the same two weeks to give "% vs normal" |
| Rain, next 7 days | Open-Meteo daily precipitation probability | Planting advice and the spray window ("spray on a dry morning before…") |
| Soil | Placeholder flags until an iSDAsoil account is set up | Low nitrogen raises confidence for nitrogen deficiency only |
| Dealer stock and prices | Dealers update their own inventory over the second WhatsApp line | Only verified dealers are shown; prices are theirs and the reply says so |
All of these have offline fallbacks so the system still answers if a source is down; the reply then carries the fallback label in its telemetry, which the demo sidebar shows.
Section 7Where people are in the loop
- Extension officers see every held case on the Officer Desk with the farmer's words, the diagnosis, NDVI, weather and a draft. Their reply is sent as "FieldLink extension officer (name): …" and closes the case. The SLA clock is 4 hours; breaches are counted.
- Dealers are verified by a person before their stock appears, and can be suspended.
- Farmers can always ask for an officer, and any photo the system cannot interpret is escalated rather than guessed.
Section 8What FieldLink will not do
- It never names a product that is not in the vetted catalog, and never a banned or restricted one, even if a farmer asks for it by name.
- It never lets the language model write a diagnosis, a dose or a price. The model only answers open questions, and that answer is re-checked and capped at 120 words.
- It never silently drops a safety hold. Interim advice is additive; the officer still reviews.
- It does not diagnose from a photo yet. Photos go to an officer.
- It does not store anything beyond the phone number, plot location, crops and the conversation needed to help; nothing is shared with dealers except what the farmer asks to buy.