Inspiration

Growing up in Uganda, I witnessed firsthand how smallholder farmers work tirelessly for six months, only to sell their harvest at a fraction of its value to middlemen. The root cause isn't a lack of hard work; it's information asymmetry. A farmer in rural Mukono doesn't know that beans are selling for 3,200 UGX/kg in Kampala when the middleman offers them 800 UGX/kg at the farm gate. I wanted to build a solution that democratizes market access and eliminates this exploitation. However, it had to work for the 65% of rural African farmers who don't own smartphones or have reliable internet. That's when the idea of combining advanced, autonomous AI with the most accessible technology in Africa—USSD—was born.

What it does

Sokoto Agent is a USSD-powered AI Autopilot that puts market power directly into farmers' hands. A farmer dials a simple USSD code (e.g., *384*99#) and texts unstructured input like "Beans, 5 bags in Mukono." The AI agent autonomously takes over: it parses the request, queries real-time Kampala market prices, finds verified bulk buyers, negotiates the best deal, and locks in the offer. The farmer receives a guaranteed fair price and delivery instructions directly on their basic feature phone screen, completely bypassing exploitative brokers.

How we built it

We built a full-stack architecture bridging legacy telecom infrastructure with cutting-edge cloud AI: The Edge (USSD): We integrated the Africa's Talking API to route USSD requests from basic feature phones to our backend. The Backend: A Node.js/Express server handling stateless USSD session management and acting as the orchestration layer. The Brain (QwenCloud): We utilized the Qwen-Max model via its OpenAI-compatible API. Crucially, we implemented Function Calling (Tools). We defined custom tools like get_market_price(crop) and find_buyers(crop, volume). The AI doesn't just chat; it autonomously executes these tools to fetch real data and synthesize a business deal. The Frontend: A React/Vite/Tailwind landing page with Framer Motion animations to visually guide users and judges through the USSD flow and technical architecture.

Challenges we ran into

The 160-Character Constraint: USSD screens are tiny and sessions time out in seconds. Getting a massive LLM to output concise, actionable, and perfectly formatted 160-character chunks without hallucinating or timing out was incredibly difficult. We had to engineer aggressive system prompts and implement a response-truncation formatter. Stateless Sessions: USSD is inherently stateless. We had to build a robust session tracker to remember where the farmer was in the multi-turn AI negotiation.

Cloud Infrastructure: We faced initial delays with Alibaba Cloud ECS real-name verification due to regional restrictions. To ensure we met the hackathon deadline and kept the project moving, we rapidly pivoted to deploy our Node.js backend on Render, while maintaining our production architecture design for Alibaba Cloud.

Accomplishments that we're proud of

We are incredibly proud of successfully executing the Function Calling loop over a 2G USSD network. Watching the terminal logs show the Qwen Agent autonomously triggering the get_market_price tool and formatting the output for a basic feature phone in under 3 seconds was a massive engineering thrill. Furthermore, we are proud of building a solution that perfectly targets Track 4 (Autopilot Agent) and Track 5 (EdgeAgent). It isn't just a technical showcase; it's a lifeline for millions of unbanked, unconnected farmers in East Africa.

What we learned

We learned that deploying AI in "Edge" environments requires a completely different mindset than building for the web. We can't rely on streaming tokens or massive context windows. We learned how to deeply leverage QwenCloud's tool-use capabilities to turn a standard chatbot into an autonomous business agent. We also learned the importance of graceful degradation—ensuring that if the AI takes too long to respond, the USSD session doesn't just drop into a void, but provides a polite "Please wait" fallback.

What's next for Sokoto Agent

Mobile Money Integration: Connecting the backend to MTN/Airtel Mobile Money APIs so farmers can receive instant digital payouts. Local Language Support: Fine-tuning the Qwen agent to understand and respond in Luganda, Runyankole, and Swahili through integrating it with Sunbird AIs model that will give the local language translation capability before relaying the massage to the QwenCloud AI API. Production Migration: Completing the migration of our backend to Alibaba Cloud ECS with Redis for distributed session management and RDS for the buyer/market database. Pilot Program: Launching a beta test with 50 smallholder farmers in the Mukono district to gather real-world feedback.

Built With

Share this project:

Updates