{"slug": "how-i-built-an-ai-agricultural-advisor-that-talks-to-indian-farmers-10-days-of", "title": "How I Built an AI Agricultural Advisor That Talks to Indian Farmers — 10 Days of Voice Agents", "summary": "An engineer built Samar, an AI agricultural advisor voice agent for Indian farmers, in 10 days as part of Murf AI's VoiceForBharat challenge. The agent speaks Hindi and English, provides weather forecasts, crop prices, and pest advice, and can make outbound calls to warn farmers of weather alerts. It uses Deepgram for speech-to-text, Google Gemini for language processing, and Murf Falcon for text-to-speech.", "body_md": "How I Built an AI Agricultural Advisor That Talks to Indian Farmers — 10 Days of Voice Agents\n\nThe Problem and the Users\n\nOver 60% of India's workforce depends on agriculture, yet accessing timely agricultural advice remains a massive challenge for rural farmers. Language barriers, low digital literacy, and poor internet connectivity mean that text-based apps simply don't work for most of them.\n\nWhat if farmers could just pick up the phone and talk to an AI expert — in Hindi, in their own language, like talking to a friend?\n\nThat's exactly what I built over the last 10 days as part of the 10 Days of Voice Agents — VoiceForBharat Edition challenge by Murf AI.\n\nMeet Samar — an AI Agricultural Advisor for Farm & Field, a voice-first helpline that provides real-time weather forecasts, mandi crop prices, pest diagnosis, and farming advice to Indian farmers through natural conversation.\n\nWhat the Voice Agent Does\n\nSamar is a fully functional voice AI agent that:\n\n🗣️ Speaks naturally in Hindi (Devanagari script) and English using Murf Falcon TTS\n\n🌦️ Fetches live weather data for any Indian city using the OpenWeatherMap API\n\n💰 Looks up real-time crop prices from government mandi data\n\n🧠 Remembers returning farmers — their name, location, and crops across sessions\n\n📞 Makes outbound phone calls via SIP to proactively warn farmers about weather alerts\n\n🎫 Escalates to human experts when it encounters problems it can't solve, creating trackable support tickets\n\n📊 Tracks call analytics — logging every call's success or failure in real-time on a live dashboard\n\n🤝 Hands off to a specialist agent — if a farmer asks about crop diseases, Samar transfers the call to \"Pooja\", a crop disease expert with a completely different voice\n\nHow the System Works\n\nThe architecture follows a standard voice AI pipeline:\n\nFarmer's Voice → Deepgram STT → Google Gemini LLM → Murf Falcon TTS → Farmer Hears Response\n\nCore Components:\n\nComponent Technology Role\n\nSpeech-to-Text (STT) Deepgram Nova-3 Converts farmer's speech to text\n\nLarge Language Model (LLM) Google Gemini (via LiveKit inference) Processes input, decides actions, generates responses\n\nText-to-Speech (TTS) Murf Falcon Converts text responses to natural Indian voice\n\nReal-time Transport LiveKit Agents SDK Manages audio streaming, WebRTC, SIP\n\nVoice Activity Detection Silero VAD + LiveKit Turn Detector Detects when the farmer is speaking\n\nDatabase SQLite Stores farmer profiles, tickets, call logs\n\nFrontend Next.js + Tailwind CSS Browser UI with dashboards\n\nBackend: Python with livekit-agents SDK — everything lives in a single agent.py file.\n\nFrontend: Next.js with LiveKit's Agents UI components, plus custom dashboards for escalation tickets and call analytics.\n\nThe Most Important Features\n\npython\n\ntts=murf.TTS(\n\nvoice=\"Samar\",\n\nstyle=\"Conversation\",\n\ntokenizer=tokenize.basic.SentenceTokenizer(min_sentence_len=2),\n\ntext_pacing=True,\n\n)\n\nLANGUAGE & SCRIPT (CRITICAL):\n\nAlways write every language in its own native script.\n\nHindi → Devanagari (नमस्ते), never romanized (never \"namaste\").\n\nPersistent Memory with SQLite (Day 4)\n\nSamar remembers every farmer she talks to. When a farmer calls back, she greets them by name, knows their location, and remembers their crops. This is powered by a simple SQLite database with lookup_farmer and save_farmer tools.\n\nLive Tool Integration (Day 5)\n\nSamar doesn't guess — she fetches real data:\n\nWeather: Calls the OpenWeatherMap API to get temperature, humidity, rain chance, and wind speed for any Indian location.\n\nCrop Prices: Queries government mandi market data to give farmers the latest prices for their crops.\n\nOutbound SIP Phone Calls (Day 6)\n\nThis was the most exciting feature. Samar can proactively call farmers on their real phone numbers via SIP trunking to warn them about incoming storms or pest outbreaks. The agent waits for the farmer to answer before speaking, and always offers an opt-out option.\n\nHuman Escalation Dashboard (Day 7)\n\nWhen Samar encounters a problem she can't solve (e.g., the farmer explicitly requests a human), she creates a support ticket with a unique reference ID. These tickets appear in a real-time dashboard overlay on the website, accessible via a notification bell icon.\n\nCall Analytics Dashboard (Day 8)\n\nEvery call is tracked. If Samar successfully provides weather or crop price data, she silently logs the call as \"successful\". If the farmer hangs up before getting help, it's logged as \"failed\". A live Next.js dashboard at /analytics shows Total Calls, Success Rate, Failure Types, Channel Mix, and a Recent Calls table — all updating in real-time.\n\nMulti-Agent Handoff (Day 9)\n\nSamar knows her limits. If a farmer asks about crop diseases or fungus, she doesn't try to answer — she transfers the call to Pooja, a specialized Crop Problem Expert. Pooja has her own voice, her own prompt, and receives the full conversation history so the farmer never has to repeat themselves.\n\npython\n\n@function_tool()\n\nasync def transfer_to_crop_specialist(self, context: RunContext) -> tuple[Agent, str]:\n\nspecialist = CropSpecialist(\n\nchat_ctx=self.chat_ctx.copy(exclude_instructions=True)\n\n)\n\nreturn specialist, \"Transferring you to our crop specialist.\"\n\nChallenges and How I Overcame Them\n\nChallenge 1: Hindi Romanization\n\nProblem: Despite explicit instructions, the LLM would sometimes output \"Dhanyavaad\" instead of \"धन्यवाद\".\n\nSolution: I added the language rule in multiple places in the system prompt and marked it as (CRITICAL). Repeating the instruction at the top AND bottom of the prompt significantly improved compliance.\n\nChallenge 2: SIP Outbound Call Timing\n\nProblem: When making outbound phone calls, the agent would start speaking before the farmer picked up the phone, wasting the greeting.\n\nSolution: I added logic to wait for the farmer's audio track to be published before generating the greeting. The agent polls for the participant's audio track and only speaks once detected:\n\npython\n\nif is_outbound:\n\n# Wait for user to answer before speaking\n\nwhile not any(t.kind == rtc.TrackKind.KIND_AUDIO\n\nfor t in participant.track_publications.values()):\n\nawait asyncio.sleep(0.5)\n\nChallenge 3: Native SQLite Build Errors on Windows\n\nProblem: The better-sqlite3 npm package requires native C++ build tools, which caused compilation errors on Windows.\n\nSolution: I switched to the sqlite + sqlite3 JavaScript packages which don't require native compilation, and the backend Python agent handles all heavy database operations directly.\n\nHow to Build and Run It Yourself\n\nPrerequisites\n\nPython 3.10+\n\nNode.js 18+\n\nuv (Python package manager)\n\npnpm (Node package manager)\n\nAPI keys for: LiveKit, Murf AI, Deepgram, Google AI\n\nStep 1: Clone the Repository\n\nbash\n\ngit clone [https://github.com/SatishBoya07/murf-livekit-starter.git](https://github.com/SatishBoya07/murf-livekit-starter.git)\n\ncd murf-livekit-starter\n\nStep 2: Set Up the Backend\n\nbash\n\ncd backend\n\ncp .env.example .env.local\n\nuv sync\n\nuv run python src/agent.py download-files # first time only\n\nuv run python src/agent.py dev\n\nStep 3: Set Up the Frontend\n\nbash\n\ncd frontend\n\ncp .env.example .env.local\n\npnpm install\n\npnpm dev\n\nStep 4: Open and Talk\n\nOpen [http://localhost:3000](http://localhost:3000) in your browser, click \"Talk to Samar\", and start a conversation!\n\n⚠️ Important: Never commit your .env.local files or expose API keys publicly. The .gitignore file is already configured to exclude them.\n\nWhat I Would Improve Next\n\nRegional Language Support: Add support for Tamil, Telugu, Kannada, and other Indian languages beyond Hindi and English.\n\nVoice Cloning: Train custom voices that sound even more natural and region-specific.\n\nWhatsApp Integration: Many Indian farmers use WhatsApp — integrating voice messages through WhatsApp would massively increase accessibility.\n\nOffline Mode: Build a lightweight offline model for areas with poor connectivity.\n\nProduction Deployment: Deploy on cloud infrastructure with proper scaling, monitoring, and security.\n\nLinks\n\n🔗 GitHub Repository: github.com/SatishBoya07/murf-livekit-starter\n\n🎙️ Murf Falcon TTS: murf.ai\n\n🔊 LiveKit Agents: docs.livekit.io/agents\n\nThis project was built as part of the 10 Days of Voice Agents — VoiceForBharat Edition challenge by Murf AI. The fastest TTS API — Murf Falcon — made it possible to deliver natural, low-latency Indian voices that feel real to the farmers who need them most.", "url": "https://wpnews.pro/news/how-i-built-an-ai-agricultural-advisor-that-talks-to-indian-farmers-10-days-of", "canonical_source": "https://dev.to/satish_boya_3e96fe77e6464/how-i-built-an-ai-agricultural-advisor-that-talks-to-indian-farmers-10-days-of-voice-agents-1ikd", "published_at": "2026-08-15 17:05:20+00:00", "updated_at": "2026-08-15 17:11:53.683105+00:00", "lang": "en", "topics": ["artificial-intelligence", "natural-language-processing", "ai-products", "ai-agents", "developer-tools"], "entities": ["Samar", "Murf AI", "Deepgram", "Google Gemini", "LiveKit", "OpenWeatherMap", "SQLite", "Next.js"], "alternates": {"html": "https://wpnews.pro/news/how-i-built-an-ai-agricultural-advisor-that-talks-to-indian-farmers-10-days-of", "markdown": "https://wpnews.pro/news/how-i-built-an-ai-agricultural-advisor-that-talks-to-indian-farmers-10-days-of.md", "text": "https://wpnews.pro/news/how-i-built-an-ai-agricultural-advisor-that-talks-to-indian-farmers-10-days-of.txt", "jsonld": "https://wpnews.pro/news/how-i-built-an-ai-agricultural-advisor-that-talks-to-indian-farmers-10-days-of.jsonld"}}