AI for farmingMiddleLesson 1245 min read

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.

Lesson in motion

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.

1/6
In simple words
A good helper at a shop answers simple questions himself. When someone asks about medicine, he says "wait, let me call the pharmacist". A good farm bot is like that helper. It knows when to answer and when to call a real expert.
Many teams in India are building chat and voice bots that answer farmers' questions. These bots often use a large language model (LLM). LLMs write fluent answers, but they can also make up facts in a confident voice. On a farm, a wrong answer can waste money, harm crops, or harm people.

Five rules for a farm advice bot

  1. 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. 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. 3

    Show the source

    Every answer says where it came from, so the farmer or an expert can check it.
  4. 4

    Know when to stop

    For pesticide doses, poisoning, loans, or anything it is unsure about, hand over to a person.
  5. 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 questionWhat the bot should do
Pesticide or chemical dose, mixing chemicalsDo 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 sprayingTell them to get medical help immediately. Do not give treatment advice.
Loans, insurance claims, money decisionsExplain general terms only. Send to the bank, insurer or agriculture office.
Anything the sources do not coverSay "I don't know" honestly and offer a human contact, such as the Kisan Call Centre (1800-180-1551).
Danger
A wrong pesticide dose can harm the farmer, the family, animals, the soil and the people who eat the crop. A bot must never guess or calculate a pesticide dose. That decision needs the product label and a qualified local expert.

Grounding and citing

A safer design is retrieval: the bot first searches a library of approved documents, then answers only from what it found, and shows the source. If nothing relevant is found, it says so. This does not make the bot perfect, but it makes mistakes easier to catch.
A risky farm bot
  • Answers every question, even when unsure
  • No sources shown
  • Gives chemical doses from memory
  • Only works in English text
A responsible farm bot
  • 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
Try this. Write five questions a farmer in your area might ask a bot. Mark each one: can the bot answer from a trusted source, or should it hand over to a person?

Watch and read more

Lab

A small safety router that sends emergencies and pesticide-dose questions to people, and answers the rest.

~20 min

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.

  1. Complete route(question). It must return:
    • "emergency" if the question contains any word from EMERGENCY_WORDS (this comes first, even if other words are present);
    • "expert" if it contains any word from EXPERT_WORDS;
    • "answer" otherwise.
  2. Matching must ignore upper and lower case.
  3. Run it on the sample questions and check each result by eye.
  4. 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.

Output

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.

Please sign in to continue.

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.

Sign in to take the test and save your progress