Chain Labs

Stock-keeping over WhatsApp for textile traders

Textile traders keep their fabric stock by sending WhatsApp messages, voice notes and photos of mill receipts. We built Traider, the agents that turn those messages into stock records, and it is live with paying customers.

Client
A textile trading firm in Surat, India
Services
AI Agents, Business Process Automation
When
November 2025 to February 2026
Team
Mihir
Status
Live

The problem

A textile trading firm hired us to fix how it kept its fabric stock. Small firms like it buy fabric from mills in rolls. They sell the fabric by the meter, in many colors of each fabric.

The firm's stock records sat in paper registers, WhatsApp messages and spreadsheets. Nobody at the firm could quickly answer a simple question: how much of this fabric, in this color, do we have right now?

The traders already ran their business on WhatsApp. They type in a mix of Hindi, Gujarati and English. They forward photos of mill receipts and invoices. We did not want to ask them to learn a new app.

What we built

The firm paid a one-off $5,000 setup, and we built the first version of Traider in 15 days. Traider is our product. Chain Labs owns Traider, and other trading firms run on it too.

A trader types that a delivery came in, records a voice note, or forwards a photo of a mill receipt. A coordinator agent hands each message to one of its specialists: fabrics, stock movements, questions, documents and reports. The specialists work through an inventory service we built on PostgreSQL. The inventory service records every movement. It keeps stock in meters, while letting traders enter rolls.

Traders ask questions in their own words, such as which colors are running low. Gemini, Google's AI model, turns each question into a database query. The query can only read. The query must be a single SELECT on the inventory tables. It has a time limit. It runs inside a transaction that is always rolled back.

Traider sends each firm a stock report on WhatsApp every day and every week, as a short message and a PDF.

A Traider daily stock report for a demo firm: stock totals, the day's receipts and issues in meters, the top seller, a movement log with document references and stock by color.

We chose WhatsApp over an app of our own, so traders had nothing to install. The cost is a WhatsApp rule: a business may send a free-form message only within 24 hours of the customer's last message. Traider tracks that window for every trader. Traider sends the report early when the window would close before the report is due.

One WhatsApp number serves every firm. Each phone number maps to its firm, and each firm's stock sits in its own inventory service.

What was hard

Mill receipts arrive as phone photos. Document AI, Google's service for reading scanned documents, reads each receipt. When Document AI reads a receipt with low confidence, Traider shows the trader what it read and asks the trader to confirm.

To match a receipt line to the firm's catalog, Traider tries the exact color code, then a search, then a scoring pass by Gemini. When confidence stays below a set level, Traider sends the trader the closest matches to choose from. When an invoice gives one quantity for several colors, Traider asks how to split the quantity.

Typed codes caused duplicates: "905(A)" and "905 (A)" became two variants of one color. We took code cleanup away from the model and put it in plain code. Traider uppercases codes and strips spaces and symbols from them. Traider tells the trader when it changed a code.

In January 2026, context left over from a long conversation led the agent to record stock movements the trader had not asked for. We removed those entries from the firm's records. We also changed how conversations run. A long conversation now starts fresh once the conversation is idle or passes a message limit. Every conversation starts fresh when the agents' tools change. A wrong entry can also be canceled, and the entry stays in the movement log.

The result

Traider is live with paying customers. The trading firms that use Traider record deliveries and sales by message. They ask about stock in their own words. They get their stock report on WhatsApp.

Built with

ChatWhatsApp Business API, through pywa
AgentsGoogle ADK on Gemini: a coordinator and specialist agents
Inventory servicePython, FastAPI and PostgreSQL, with an MCP server
Reading receipts and invoicesGoogle Document AI
Voice notesGladia speech-to-text, for Hindi, Gujarati and English
Stock reportsAPScheduler and ReportLab
Fabric photosCloudinary
BuildingClaude Code