Building a crop advice bot responsibly
A farm advice bot must speak the farmer's language, show where its answers come from, and hand hard or risky questions to people. It must never guess a pesticide dose.
In 60 seconds
Building a crop advice bot responsibly
A farm advice bot must speak the farmer's language, show where its answers come from, and hand hard or risky questions to people. It must never guess a pesticide dose.
Five rules for a farm advice bot
- 1
Speak the farmer's language
Support local languages and dialects, and voice, not only text. Many farmers prefer to speak rather than type. - 2
Answer from trusted sources
Give the bot approved material, for example from agricultural universities, KVKs and government advisories, and make it answer from that. - 3
Show the source
Every answer says where it came from, so the farmer or an expert can check it. - 4
Know when to stop
For pesticide doses, poisoning, loans, or anything it is unsure about, hand over to a person. - 5
Learn from experts
Experts regularly review answers and fix wrong ones.
Language and voice
- Test with real farmers from the region, not only with the team's own sentences.
- People mix languages, like Hindi with English crop names. The bot must handle this.
- Local names of crops, pests and diseases differ between districts. Build a list with local experts.
- Speech recognition can mishear words. For important details, the bot should repeat what it heard and ask "is this right?"
Questions the bot must hand to people
| Type of question | What the bot should do |
|---|---|
| Pesticide or chemical dose, mixing chemicals | Do not give a number. Say to follow the product label and confirm with the KVK or agriculture officer. Offer to connect. |
| Someone feels ill after spraying | Tell them to get medical help immediately. Do not give treatment advice. |
| Loans, insurance claims, money decisions | Explain general terms only. Send to the bank, insurer or agriculture office. |
| Anything the sources do not cover | Say "I don't know" honestly and offer a human contact, such as the Kisan Call Centre (1800-180-1551). |
Grounding and citing
- Answers every question, even when unsure
- No sources shown
- Gives chemical doses from memory
- Only works in English text
- Says "I don't know" and hands over to a person
- Shows where each answer came from
- Never gives doses; points to the label and the KVK
- Works in local languages, by voice too
Watch and read more
Lab
A small safety router that sends emergencies and pesticide-dose questions to people, and answers the rest.
The problem
This runs in your browser. The router is the first step of a farm bot: it decides who should answer, before any AI writes a reply.
- Complete
route(question). It must return:"emergency"if the question contains any word fromEMERGENCY_WORDS(this comes first, even if other words are present);"expert"if it contains any word fromEXPERT_WORDS;"answer"otherwise.
- Matching must ignore upper and lower case.
- Run it on the sample questions and check each result by eye.
- Add three questions of your own, including one in your language written in English letters, and add any words the router needs.
Practice lab
Edit the code and run it. Python runs in your browser — nothing is sent to our server.
No output. Add print(...) to see values.
You are done when
Hard questions
Try to answer before you reveal. If you can answer these, you understood the lesson.
Q1The word "ml" is in EXPERT_WORDS. Find a problem with simple word matching, and suggest a fix.Reveal
Matching "ml" inside other text can catch unrelated words that contain those letters, and it can miss doses written in other ways, like "millilitre" or a number with no unit. Fixes include matching whole words only, adding more ways people write the same thing, and testing with real questions. For extra safety, a trained classifier can be used alongside the word list, but it should only ever make the bot more cautious, never less.
Q2Why put this router before the language model, instead of asking the model to be careful?Reveal
A language model can be talked into answering, or can simply make a mistake. A fixed rule in code runs every time and cannot be persuaded. Putting it first means risky questions never reach the part that might invent an answer. The model can still be told to be careful, as a second layer.
Questions people ask
Is it enough to add "consult an expert" at the end of every answer?
No. If the bot gives a wrong dose and then adds a warning, harm can still happen. The bot must not give risky answers at all, and must route those questions to a person.
How do I find trusted sources for the bot?
Work with agricultural universities, KVKs or the state agriculture department. Ask for permission to use their material, keep it up to date, and record the date and source of each document.
How do I test a farm bot before launch?
Collect real questions from farmers, including tricky and risky ones. Have agriculture experts review the bot's answers. Test in the languages and accents of your users. Keep testing after launch, because new questions will appear.
What about farmers who cannot read?
Offer voice input and spoken answers, and keep answers short. A phone call option to a real person helps too.
Lesson test
5 questions. Get 3 right (60%) to pass and complete this lesson.