Case · 02 — Production

MerchBot

Stock and complaints assistant

An AI assistant that answers plain-language questions about stock, orders, restocking and policies, and logs complaints at any hour. Every number comes from a SQL query; the model only writes the reply.

454automated tests

System view · demo data

At 03:20, with the warehouse closed, the complaint is logged with a number and the bot says a person will review it on the next business day.
Procedure questions go through RAG, and the answer names the policy section it comes from.
Each complaint gets a tone and a 0–100 priority with its reasons; urgent ones go first.
The metrics panel, with test activity. Every number comes from a database query.

The problem

Checking stock meant walking to the warehouse or asking someone, and the same questions came up every day. Complaints arrived through scattered channels and were lost before they could turn into improvements.

What I built

It started as a Telegram bot that put the stock in the model's prompt. Today Gemini picks one of nine functions, the code runs the query and the answer comes from the database. Questions about procedures go through RAG over the policy document, with BM25 as a fallback. It is read-only on the business: the only thing it writes is complaints, each scored for tone and given a 0–100 priority with its reasons. It has voice, a metrics panel, login and rate limits.

What changed

In production inside the ERP with the purchasing team, who check stock without walking to the warehouse. The public repository holds the same idea with fictional data, set up to run locally with Docker; round-the-clock deployment is left as future work. It is measured with 28 assistant cases, 25 RAG questions and a sentiment set where VADER scored 42% against 88% for the custom lexicon. If Gemini runs out of quota, it falls back to backup models.

Tools

  • Python
  • Gemini
  • Function calling
  • RAG
  • FastAPI
  • Docker