From Leaf to Chat: Building an AI Consultant for Tea Shopping

10 min read
From Leaf to Chat logo

Imagine entering a cozy tea shop where a tea master guides you toward the perfect infusion based on your preferences and mood. Now imagine this experience happening entirely through Telegram—augmented by AI, search engines, and cloud infrastructure. That’s the idea behind our latest project: an intelligent Telegram-based chat assistant for product recommendation, designed initially for a traditional tea shop but extensible across verticals. We call it CatalogIQ.

This article explores the architecture, tools, and challenges we faced while building an AI-powered Telegram bot that doesn’t just answer questions—it understands customers, guides them through the catalog, and helps them buy what fits best.

Project Overview

Our goal was to help small-to-medium businesses (starting with a tea shop client) turn their static product catalogs into dynamic, conversational tools. Users interact with the assistant through Telegram by sending freeform messages about what they’re looking for. The assistant replies in natural language, asks clarifying questions, and recommends products based on a scoring system.

Telegram was chosen as the initial platform because of its simple and familiar chat interface, making it easier for customers to communicate with the bot in the same way they would message a friend. Some clients may prefer other platforms like Instagram, and the architecture supports that flexibility. Regardless of the channel, we provide a unified experience through a common Mini App—in Telegram it appears as an integrated web view, while in Instagram or other platforms it functions as a mobile-friendly site. This interface allows users to browse recommendations, apply filters, compare products, and proceed to checkout—features that go beyond what typical messaging bots can offer.

The architecture is built to be modular and adaptable, allowing for quick integration with new clients regardless of their existing systems or platforms.

CatalogIQ screenshots

Tech Stack

Here’s what powers this intelligent assistant:

  • Backend Framework: Spring Boot (OpenAI integration)
  • AI/NLP Models: ChatGPT (gpt-4o, gpt-4o-mini, gpt-4.1)
  • Search Engine: Elasticsearch
  • Data Store: MongoDB
  • Logging & Monitoring: ELK Stack (Elasticsearch + Logstash + Kibana)
  • Prompt & Config Management: Spring Cloud Config Server
  • Hosting: AWS (t3 instances)
  • Frontend (Mini App): React + PrimeReact
  • Communication Platform: Telegram Bot API

Workflow: From Catalog to Conversation

1. Catalog Intake & Labeling

The shop catalog is first ingested and labeled using AI. We apply a combination of GPT models to extract categories like taste, origin, cultivar, price, and effects. This structured metadata fuels later recommendations.

2. Real-time Interaction

Once a user initiates a conversation, the bot evaluates intent using short prompts and a chat history window. It asks clarifying questions with suggested labels as needed.

3. Recommendation Logic

Based on the enriched catalog and user input, we filter and rank matching products using a hybrid approach:

  • ⁃ AI for label-based scoring;
  • ⁃ Elasticsearch for full-text relevance and fuzziness.

4. Mini App Hand-off

After receiving recommendations, the user can click into a Telegram web view (Mini App) for richer interaction: visual filtering, product comparison, checkout.

5. Post-Interaction Storage & Monitoring

All communication history and user selections are saved to MongoDB. Metrics and logs are streamed into ELK for performance monitoring, prompt tuning, and UX adjustments.

Pitfalls & Hard Lessons

1. Prompt Engineering Is the Heart of the System

You might think the AI part is just plugging in a model. Not even close. Prompt design is critical. It must:

  • ⁃ Be short enough to avoid model overload and token cost spikes;
  • ⁃ Be detailed enough to support complex logic and edge cases;
  • ⁃ Handle multi-language scenarios (users may speak Bulgarian, English, or others);
  • ⁃ Translate tea-specific vocabulary correctly;

We’ve learned to:

  • ⁃ Break logic into small independent prompt modules;
  • ⁃ Match the detailed enough (gpt-4o-mini for most real-time use, gpt-4o or gpt-4.1 for heavy catalog operations);
  • ⁃ Dynamically adjust the user message window sent to the model (too little = no context; too much = inefficiency and errors).

Prompt development experience has also taught us to build dynamic prompt templates stored in a cloud config server, so they can be adjusted in real-time without deployments.

2. Catalog Scraping Isn’t Always Pretty

Before you even get to AI, you need the product data. For clients lacking REST APIs (which is common), you have to:

  • ⁃ Analyze browser dev tools for network requests;
  • ⁃ Reverse-engineer HTML or JavaScript responses;
  • ⁃ Parse product data manually or with heuristics;
  • ⁃ Eventually convince the client to expose a proper API or provide a CSV-based product catalog.

This fragile setup made us build fallback data scrapers early in the project lifecycle.

3. Tea Is Complex (More Than You Think)

Tea products evolve over time: flavor changes, packaging updates, harvest variation. This isn’t just a product catalog – it’s a living inventory.

That meant:

  • ⁃ Creating custom filters (e.g., storage year, taste profile, leaf grade);
  • ⁃ Involving the shop owner in label verification;
  • ⁃ Scheduling re-labeling tasks for aging stock.

Even human tea sellers argue about flavor evolution. Getting an AI to track and reflect that? A whole other level.

Conclusion

This AI-powered Telegram bot has been an effective blend of natural language understanding, elastic search relevance, and domain-specific knowledge—all built to serve something as nuanced as premium tea.

But the broader lesson here? Any vertical with a rich catalog and poor UX is ripe for conversational AI. With the right modular prompt design, intelligent fallback logic, and well-selected infrastructure, you can build personalized shopping experiences that feel genuinely human—even inside a chat window.

Want to know more about the story behind CatalogIQ? Have a look at this page.

Support the brave people of Ukraine

Support Ukraine