The product and the problem
KisanDostAI explores a narrow access problem: getting agricultural guidance through a spoken Urdu conversation. A caller uses a configured Twilio telephone path; the service bridges audio to a realtime AI session and can retrieve documents or request current external information.
I led this university team project, focusing on its backend and AI direction alongside my teammates. The work explored how to make agricultural information accessible through a conversation, with telephone behavior and answer quality evaluated separately.
System overview
Urdu telephone assistant
Spoken questions in Urdu
Audio sessions + tool orchestration
- Realtime AI
- Documents
- Weather
How the experience works
Begin with a spoken question
The experience starts with a call to the configured Twilio service. A caller asks an agricultural question in Urdu, and the system carries that audio into an active AI conversation. This makes the call itself the main interaction surface. There is no screen on which to display a loading indicator, explain a failed request, or ask the caller to inspect a source link. Each of those moments needs an understandable spoken response.
Choose a source appropriate to the question
A question about current weather needs a different information path from a question about crop guidance or historical agro-climatic conditions. The realtime session can request a tool, while the backend executes the selected operation. The documented tool set covers weather, NASA POWER data, web search, page retrieval, and agricultural document retrieval. This separation lets the conversation use a suitable information source without exposing the underlying services to the caller.
Keep the caller informed during a lookup
When a lookup takes time, the conversation acknowledges the request in Urdu and uses a low-volume chime during the waiting interval. The chime stops when an answer is ready or the caller starts speaking. The result then returns to the active conversation so the assistant can explain it aloud. If the tool provides unusable information, the caller receives a brief failure notice and the missing value remains unknown.
My contribution
- Led project direction within the team and shaped the telephone-to-AI architecture.
- Backend and AI focus: the FastAPI session bridge, retrieval, and external-tool orchestration.
- Worked through interruption, long-turn, tool-wait, and call-monitoring behavior.
- Documented the evaluation methods and the limits of the prototype.
Architecture and implementation
Two live audio connections behind one conversation
The FastAPI gateway maintains a Twilio WebSocket and a realtime AI WebSocket for each admitted call. Concurrent asynchronous tasks move incoming telephone audio in one direction and process returned audio, transcripts, tool requests, and interruption events in the other. This is the central integration responsibility: the gateway coordinates several event streams while preserving the experience of a single conversation.
The documented telephone and AI streams use a compatible G.711 mu-law format, allowing the bridge to forward the payload without an additional transcoding stage. Each call also has its own pending-tool state and recent context. These boundaries explain how the prototype organizes a session; the research does not use them as evidence of a tested concurrent-call capacity.
Separate live sources, document grounding, and memory
Weather and environmental APIs return structured fields. Agricultural retrieval returns supporting document material, while web retrieval can introduce pages with varying relevance and reliability. The source policy therefore matters alongside the tool implementation. The research describes a preference for authoritative or expert-reviewed material on higher-risk questions, with uncertainty made explicit when support is weak.
MongoDB stores conversation events and supplies a bounded set of recent turns when a caller returns. That history provides continuity, but a remembered location or crop still needs confirmation because circumstances change and phones can be shared. Monitoring provides another view of the same service: call events, tool health, token use, and retrieval operations can be inspected independently of the live dialogue.
Key engineering decisions
Start with the telephone path
Twilio carries call audio to the FastAPI service. The evaluated route establishes a programmable telephone path, with ordinary Pakistani SIM and landline reachability left for further deployment work.
Give tools a specific responsibility
Weather, agro-climatic information, web retrieval, and document grounding serve different questions. The system must distinguish a returned result from a missing or unusable result.
Evaluate the layers separately
The evaluation separates telephone behavior, text-session answer quality, and a blinded answer comparison. That avoids presenting text answers as evidence of speech-recognition accuracy.
Challenges and trade-offs
A reachable service can still have a broken tool round trip
One of the research paper’s most useful engineering findings concerns tool-call validity. A routing response created outside the default conversation produced a function call whose matching output was rejected with an invalid tool-call identifier. The transport could be connected while a grounded answer was structurally impossible.
The documented repair extended the health probe through a silent route and function-output round trip. This gave the team a more meaningful check of the conversation contract. For an assistant that depends on external information, establishing a connection and completing an actionable turn are separate milestones.
Interruption and waiting are part of the product
The call tests exposed delayed interruption, queued audio after a stop request, repeated waiting prompts, truncated answers, and dead air. These problems appear between otherwise working components: audio can be flowing, a tool can be running, and the caller can still experience a stalled conversation.
The paper records changes to transcription and turn handling, including partial transcription for earlier interruption awareness and explicit start/stop behavior for lookup audio. Repairs were followed by repeating the sequence that exposed the fault. The waiting chime was checked operationally; the research does not establish a measured improvement in user preference from that design choice.
Validation and delivery considerations
Keep telephone behavior separate from answer quality
The research uses three different kinds of evidence. Ten logged telephone sessions exercise the connected call path and conversational faults. A 50-question Urdu text study examines generated answers without speech-recognition effects. A separate 20-question blinded comparison examines answer configurations with independent agronomist ratings.
Those methods answer different questions. A completed text answer cannot establish that spoken Urdu was understood correctly, and a working phone call cannot establish agronomic correctness. Keeping those layers visible makes the case study more useful to someone evaluating a voice-assistant project.
Treat the research limits as requirements for the next stage
The evaluated route uses the deployed Twilio setup, including application-originated calls. Ordinary Pakistani SIM and landline access, affordability, rural audio conditions, concurrent capacity, and broad field effectiveness require further work. The comparison also does not support a blanket claim that the full multi-tool configuration gives better answers than simpler configurations.
A next-stage assessment would need its own calling route, consent and retention process, representative spoken test set, and operational measurements. These are deployment and evaluation responsibilities beyond the prototype evidence presented here.
What was delivered
A programmable-telephone prototype, an asynchronous FastAPI audio bridge, retrieval and external-tool workflows, and a monitoring/dashboard layer. The research evaluation included ten logged call sessions, a 50-question text evaluation, and a 20-question controlled comparison.
Visit project websiteProject scope
- Format
- University team research prototype with a documented telephone-to-AI architecture.
- Evaluation
- Separate call-behavior, text-answer, and blinded-comparison methods.
- My focus
- Project leadership, backend architecture, and AI integration within the team.
The research tested a configured programmable-telephone route. It did not establish reachability through ordinary Pakistani SIM or landline calls, broad field effectiveness, or improved farmer income. Text-answer quality and speech-command accuracy are separate evaluation questions.
Key takeaways
- A voice product needs explicit behavior for interruption, lookup time, unusable tool output, and session failure.
- Integration health should exercise the action contract that the product depends on, including the matching tool output.
- Telephone tests, answer evaluation, and field deployment evidence support different conclusions and should remain separate.
