-
-
architecture
-
login_screen
-
agent_welcome_page
-
deal_created_notification
-
deal_status_update_notification
-
farmer_profile
-
deals_of_farmer
-
nearest_buyer_serach
-
sign_up_screen
-
buyer_profile
-
buyer_product_search_part1
-
buyer_product_serach_part2
-
workflow_elasticsearch
-
index_elasticsearch
-
custom_tools_elasticsearch
-
agribazaar-ai-agent_elasticsearch
Inspiration
Agriculture is the backbone of India's economy, employing over 50% of the workforce and feeding 1.4 billion people. Despite this, farmers continue to face deep-rooted challenges that limit their income and growth:
- Price Exploitation: Middlemen often take 30–40% margins, leaving farmers with unfair prices
- Limited Market Access: Small farmers struggle to reach buyers beyond local mandis
- Information Gap: Lack of real-time market intelligence leads to poor pricing decisions
- Trust Deficit: No transparent system to track deals, payments, or delivery status
- Geographic Barriers: Buyers cannot easily discover high-quality produce from distant regions
We witnessed this problem firsthand when a farmer in Punjab sold premium Basmati rice at ₹60/kg to a middleman, who later resold it at ₹95/kg in Delhi.
The farmer deserved fair compensation.
The buyer deserved transparency.
The system needed disruption.
AgriBazaar AI was born from a simple yet powerful question:
What if we could directly connect farmers and buyers using intelligent technology, ensuring fair prices, transparency, and trust?
By leveraging Elasticsearch’s powerful search and analytics engine along with Agent Builder’s multi-step, tool-driven AI, we saw an opportunity to create a smart agricultural marketplace that:
- Understands natural language queries
- Intelligently matches farmers with buyers
- Provides real-time market insights
- Automates the end-to-end trading lifecycle
AgriBazaar AI is our step toward building a transparent, intelligent, and farmer-first digital marketplace for Indian agriculture.
What it does
AgriBazaar AI is an intelligent agricultural marketplace that connects farmers and buyers through conversational AI — eliminating middlemen and enabling fair, transparent trade.
For Farmers
Conversational Product Listing
Farmers can simply say:
"I want to sell 500 kg of organic rice at ₹90 per kg"
The AI automatically structures and stores the product.Inventory Management via Natural Language
Commands like:
"Add 200 kg more" or "Reduce by 50 kg"
instantly update stock levels.Fair Price Guidance
Real-time market prices fetched using live Tavily search integration.Deal Tracking Dashboard
Monitor transactions, payment status, and delivery progress.Automatic Notifications
Email alerts when buyers show interest or when deals progress.
For Buyers
Smart Natural Language Search
Example:
"Find organic tomatoes in Maharashtra"
The AI understands intent, product type, and location.Proximity-Based Matching
Results ranked intelligently by:- Distance
- Price
- Quality
- Distance
Direct Deal Creation
Buyers can create purchase orders directly with farmers — no intermediaries.Market Intelligence Insights
Compare crop prices across regions and seasons.Real-Time Delivery Tracking
Track order lifecycle from creation to completion.
🤖 Intelligent Automation
Automatic ID Generation
- Products →
PROD-YYYYMMDD-XXXXXXXX - Deals →
DEAL-YYYYMMDD-XXXXXXXX
- Products →
Smart Calculations
Automatically computes:- Total amounts
- Timestamps
- Harvest and expiry dates
- Total amounts
Geo-Based Matching
Uses Elasticsearch geo-queries to find nearest buyers and sellers.Automated Email Workflows
Sends beautifully formatted HTML notifications for deal updates.Status Lifecycle Tracking
Inventory Synchronization
Automatically updates product quantity when deals are created.
AgriBazaar AI transforms agricultural trade from a fragmented, opaque system into a smart, transparent, AI-driven marketplace.
How we built it
🔹 Architecture Overview
┌─────────────────────────────────────────────────────────────┐
│ USER INTERFACE │
│ • Conversational Chat Interface │
│ • Real-time Updates │
│ • Responsive Design │
└────────────────────────┬────────────────────────────────────┘
│
│ HTTPS API Call
│ /api/agent_builder/converse
│
▼
┌─────────────────────────────────────────────────────────────┐
│ ELASTICSEARCH CLOUD (Kibana Agent Builder) │
│ • Agent Builder UI - Agent Configuration │
│ • Agent API Endpoint │
│ • Natural Language Understanding │
│ • Tool Orchestration │
│ • Context Management │
│ • Custom Instructions (1000+ lines) │
└────┬────────────────────────────────┬───────────────────────┘
│ │
▼ ▼
┌──────────────────────┐ ┌──────────────────────────────┐
│ WORKFLOWS (5) │ │ ELASTICSEARCH INDICES (4) │
│ • add_product │ │ • products │
│ • create_deal │ │ • deals │
│ • update_deal │ │ • farmers │
│ • update_quantity │ │ • buyers │
│ • send_email │ │ • Geo-point fields │
└──────┬───────────────┘ └──────────┬───────────────────┘
│ │
▼ ▼
┌──────────────────────┐ ┌──────────────────────────────┐
│ INGEST PIPELINES(3) │ │ CUSTOM TOOLS │
│ • product-pipeline │ │ • ES|QL queries │
│ • deals-pipeline │ │ • Tavily MCP (market data) │
│ • quantity-pipeline │ │ • Index search │
└──────┬───────────────┘ └──────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ BACKEND SERVICE (Python FastAPI) │
│ • Email Service (SMTP) │
│ • REST API Endpoints │
│ • HTML Email Templates │
└─────────────────────────────────────────────────────────────┘
Implementation Details
1️⃣ Elasticsearch Indices
Created 4 optimized indices:
productsdealsfarmersbuyers
Each index includes:
- Optimized field mappings
- Keyword + text fields for search flexibility
- Geo-point fields for proximity matching
- Timestamp tracking
- Status-based filtering fields
👉 Detailed mappings available in the project link https://github.com/bachan25/agribazaar-ai-service/tree/main/elasticsearch/index
2️⃣ Ingest Pipelines
Created 3 Painless script-based ingest pipelines for automatic data enrichment:
agribazaar-product-pipelineagribazaar-deals-pipelineagribazaar-product-quantity-pipeline
These pipelines handle:
- Auto ID generation (PROD-YYYYMMDD-XXXXXXXX, DEAL-YYYYMMDD-XXXXXXXX)
- Timestamp generation
- Total price calculations
- Status initialization
- Inventory synchronization
- Data validation and transformation
👉 Full pipeline configurations available Link
3️⃣ Workflows
Built 5 workflows to automate complete marketplace operations:
add_product_to_marketplacecreate_dealupdate_deal_statusupdate_product_quantitysend_email_notification
These workflows manage:
- Product listing automation
- Deal creation and lifecycle tracking
- Inventory updates
- Payment and delivery status transitions
- Automated email triggers
👉 Workflow configurations available Link
4️⃣ AI Agent Configuration
🔹 Agent Creation
- Built using Kibana Agent Builder UI
- Configured in Elasticsearch Cloud deployment (us-east-1)
- Endpoint: https://my-elasticsearch-project-d9f0cb.kb.us-east-1.aws.elastic.cloud:443/api/agent_builder/converse
🔹 Custom Instructions (1000+ lines)
Designed comprehensive instructions covering:
- Farmer workflows (product listing, inventory management)
- Buyer workflows (search, deal creation)
- Deal lifecycle management (status tracking)
- Pricing guidance (market intelligence)
- Email notification rules (automatic triggers)
- Error handling and validation
- Natural language interpretation patterns
🔹 Tools Integrated
Custom Tools Configuration File
✅ 5 Workflow tools
add_productcreate_dealupdate_dealupdate_quantitysend_email
✅ ES|QL Tool – Analytics and aggregations
✅ Index Search Tool – Product, buyer, and farmer search
✅ Tavily MCP Tool – Real-time market prices and news
5️⃣ Frontend
- Built with React + Vite + TypeScript
- Conversational chat interface
- Real-time agent responses
- Responsive Tailwind UI
- Direct HTTPS integration with Agent Builder API
6️⃣ Backend Service (FastAPI)
- Python 3.9+ based REST backend
- SMTP-powered email service
- HTML email templates (Jinja2)
- Order notifications and transaction alerts
- Business logic orchestration
Challenges we ran into
1️⃣ Date Formatting Issues
Challenge:
Workflow's {{now}} returned JavaScript date strings, but Elasticsearch expected ISO 8601 format.
Error Encountered:
document_parsing_exception: failed to parse date field
[Fri Feb 20 2026 07:14:48 GMT+0000 (Coordinated Universal Time)]
with format [strict_date_optional_time||epoch_millis]
Solution:
- Removed all date fields from workflow inputs
- Created ingest pipelines with Painless scripts to generate proper ISO dates
SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
isoFormat.setTimeZone(TimeZone.getTimeZone('UTC'));
ctx.created_at = isoFormat.format(new Date());
2️⃣ Email Connector Integration
Challenge:
Kibana email connectors couldn't be directly used inside workflows as tools.
Initial Approach:
Tried adding email connector as a workflow step.
Problem:
No generic connector step type available.
Solution:
- Built a FastAPI backend with SMTP integration
- Used workflow HTTP steps to call REST API
- Created a reusable
send_email_notificationworkflow
Learning:
External services exposed via REST APIs provide more flexibility than built-in connectors.
Accomplishments that we're proud of
1️⃣ Complete End-to-End Marketplace
Built a fully functional AI-powered agricultural marketplace in 2 weeks — covering product listing, smart matching, deal lifecycle, delivery tracking, and notifications.
2️⃣ Zero Manual Data Entry Automation
- Auto-generated Product & Deal IDs
- Automatic timestamps
- Smart total calculations
- Status lifecycle automation
Impact: Eliminated manual errors and reduced transaction processing time by 5+ minutes per deal.
3️⃣ Natural Language-First Experience
The AI understands flexible commands like:
- “I want to sell rice”
- “Add 200 kg more”
- “I sold 50 kg”
Impact: Zero learning curve for farmers with limited technical literacy.
What we learned
🔹 1️⃣ Elasticsearch Mastery
- Designed optimized index mappings for performance
- Built ingest pipelines using Painless for automated data enrichment
- Explored ES|QL for analytics and aggregations
🔹 2️⃣ Agent Builder Deep Dive
- Writing detailed custom instructions significantly improves agent accuracy
- Learned how agents orchestrate and chain tools dynamically
- Implemented conversation context management
- Built error recovery flows for production reliability
- Integrated Agent Builder API for real-world deployment
🔹 3️⃣ Workflow Engineering
- Worked within workflow engine constraints effectively
- Used inline Painless scripts for dynamic logic
- Integrated external services via HTTP steps
- Built robust validation and fallback handling
🔹 4️⃣ Painless Scripting Expertise
- Implemented ISO date formatting using Java time APIs
- Solved type conversion issues (String → Number)
- Built conditional business rules inside pipelines
- Optimized scripts for efficiency and reliability
🔹 5️⃣ Full-Stack System Integration
- Built REST APIs using FastAPI
- Implemented SMTP-based email notifications with HTML templates
- Connected Next.js frontend with Agent Builder API securely
- Integrated Tavily MCP for real-time market intelligence
- Secured API keys using Next.js server-side proxy routes
What's next for AgriBazaar AI
🔹 Short-Term
Multi-Language + Voice Support
Hindi, Tamil, Telugu, Marathi + voice input/output
→ Expand accessibility to regional farmers.Mobile App (Android)
Offline mode + push notifications
→ Increase farmer adoption 3x.UPI Payment Integration
Secure payments + escrow system
→ Reduce payment disputes by 95%.Quality & Logistics Integration
AI-based grading + transport partnerships
→ Improve buyer trust and reduce delivery time.
🔹 Long-Term Vision
AI-Powered Crop Recommendations
Soil, climate, and demand-based suggestions
→ Increase yield and profitability.Blockchain Traceability
Transparent, tamper-proof transaction records
→ Build complete trust in the supply chain.Export Marketplace
Connect Indian farmers to global buyers
→ Open international markets.IoT & Real-Time Farm Data
Soil sensors, weather integration
→ Enable data-driven agriculture.
Vision Statement
"By 2027, AgriBazaar AI will connect 1 million Indian farmers to fair markets, eliminate exploitation, and ensure every farmer gets the price they deserve."
We are not just building a marketplace.
We are building a transparent, AI-powered agricultural ecosystem that restores dignity, fairness, and prosperity to farmers.
AgriBazaar AI — Built with ❤️ for Indian farmers, powered by Elasticsearch.
Built With
- elastic-index
- elasticsearch
- elasticsearch-agent-builder
- express.js
- fastapi
- node.js
- python
- react
- smtp
- tailwind-css
- typescript
- vite
Log in or sign up for Devpost to join the conversation.