AI DEV CASE STUDY
Vatrina: A Realtime AI Shopping Assistant Powered by RAG and GenAI
How WebSpero built the realtime conversational chatbot and product recommendation engine at the heart of Vatrina, with RAG-backed context retrieval, live inventory sync, and sub-2.5-second AI responses.

< 2.5s
Avg Response Latency
Realtime Conversational
Live
Inventory Sync
Stock-Aware Recommendations
RAG
Vector Retrieval
Context-Aware Responses
NLP
Intent Handling
OpenAI-Powered
Project Context
Client
Vatrina
Niche
Social Commerce · Conversational AI
The Tech Stack
- Ruby on Rails
- PostgreSQL
- pgVector (Vector Database)
- OpenAI (GenAI + Function Calls)
- WebSockets (Realtime Delivery)
"We wanted a realtime conversational shopping assistant that could actually understand a shopper's intent, recommend the right product, and hand off to a human when it mattered."
The brief scoped a chatbot that could act as a conversational AI, a product recommendation engine, and an intelligent router in one. It had to answer complex customer queries in natural language, surface the right product from a live inventory, respect budget and occasion constraints, and know when to bring a human in.

Vatrina Team
A product of Escape Ventures LLC · Doha, Qatar

THE MODULE
The Conversational Chatbot and Product Recommendation Engine at the Heart of Vatrina
Vatrina is a social commerce platform combining live shopping, shoppable videos, AI recommendations, and affiliate marketing tools. WebSpero was engaged to design and build the realtime conversational chatbot and product recommendation engine module: the shopper-facing AI layer that turns a natural-language query into a product recommendation grounded in a live inventory, and knows when a query is worth handing off to a human.
For Shoppers
- Realtime chatbot that understands natural-language queries end to end
- Product recommendations tailored to budget, needs, and occasion
- Instant answers about product availability with live inventory sync
- Sub-2.5-second response latency for back-and-forth conversation
- Never surfaces an out-of-stock product
- Human handoff for special queries that need brand-side attention
For Brands & Merchant Teams
- RAG-powered recommendation engine grounded in live product catalog
- Automated ingestion pipeline for new products and stock updates
- Guardrailed AI that keeps every conversation focused on shopping
- Stock-aware recommendations that route around depleted inventory
- Escalation flow that surfaces qualified queries to human agents
- Reduced human-in-the-loop overhead for routine catalog updates
HOW WE BUILT IT
An Engineering-First Process for a Realtime, Stock-Aware GenAI System
Vatrina’s chatbot has three jobs at once: understand the shopper, recommend the right product from a live catalog, and escalate cleanly when the AI is out of its depth. Every milestone below was built and validated against those three constraints before we moved forward.

DISCOVERY
A working session with the Vatrina team to capture the shopping assistant vision, the shopper journey, and the non-negotiables: realtime, stock-aware, and guardrailed.

REQUIREMENT ANALYSIS
Broke the brief into the chat surface, the recommendation engine, the inventory sync pipeline,and the human handoff layer that ties
them together.

ARCHITECTURE & PLANNING
Chose Ruby on Rails as the service layer, PostgreSQL with pgVector for the vector store, OpenAI for reasoning and function calls,
and WebSockets for realtime delivery to the shopper.

RAG PIPELINE DESIGN
Designed the retrieval-augmented generation flow: how product data is embedded, indexed in pgVector, retrieved on a query, and fed back into the
OpenAI prompt as grounded context.

REALTIME PIPELINE
Built the realtime response loop with WebSockets, OpenAI function calls, and streamed output so a shopper sees an answer forming inside the sub-2.5
-second latency budget.

INVENTORY SYNC AUTOMATION
Automated the RAG data pipeline: new products, product updates, and stock changes flow into embeddings and
pgVector without a human touch, so the AI always reads a current catalog.

GUARDRAILS & HANDOFF
Wrote prompt guardrails that keep conversations to shopping topics, and built the escalation flow that routes queries needing human
attention to a real agent without breaking the chat.

QA, LATENCY & LAUNCH
Measured turn latency, tested recommendation accuracy against the live catalog, verified handoff behaviour, and shipped the module into
the Vatrina platform with monitoring in place.
WHAT WE BUILT
Seven Building Blocks of a Realtime AI Shopping Assistant
The Vatrina chatbot module ships as a set of connected systems: a conversational surface, a RAG-backed recommendation engine, a live inventory pipeline, and the guardrails and handoff logic that keep the experience safe. Below is the module, block by block.
Conversational Shopping Chatbot
The shopper-facing chat surface. Handles natural-language queries about products, occasions, and budgets. Understands intent, keeps context across turns, and returns grounded, catalog-accurate answers rather than generic AI output.

RAG-Powered Recommendation Engine
The recommendation engine is retrieval-augmented from the ground up. Product data is embedded and stored in pgVector. On a query, the system pulls the most semantically relevant products, feeds them to OpenAI as grounded context, and returns recommendations tied to real SKUs, not hallucinations.

Realtime Response Pipeline: WebSockets + OpenAI Function Calls
The response loop is streamed. WebSockets carry each token as it is generated, OpenAI function calls fetch live inventory and product data mid-response, and the whole turn lands inside an average sub-2.5-second latency budget. The shopper sees the answer forming, not a loading spinner.

Automated RAG Ingestion Pipeline
Every new product, every catalog edit, and every stock update flows through an automated pipeline: normalise, embed, upsert into pgVector, and rebuild the retrieval index. There is no manual step. The AI is reading the same catalog the shopper is browsing.

Live Inventory Sync: Stock-Aware Recommendations
OpenAI function calls query the live inventory before a recommendation goes out, so an out-of-stock product never gets recommended. Constraints from the shopper (budget, occasion, category) combine with the current stock state to return only what is actually buyable right now.

Prompt Guardrails: Shopping-Only Enforcement
A structured prompt layer keeps every conversation on shopping topics. Off-topic queries are politely redirected, off-brand tangents never make it through, and the AI is never asked to answer something it should not. The guardrails are the reason the chatbot is trusted on a customer-facing surface.

Human Handoff Flow for Special Queries
When a shopper needs something the AI cannot resolve (a bespoke order, a sensitive complaint, a special request), the module escalates to a human agent inside the same chat. The shopper does not restart. Context, transcript, and intent classification travel with the handoff.

THE CHALLENGES WE SOLVED
Engineering a Realtime, Stock-Aware, Guardrailed GenAI System
The Vatrina chatbot is a realtime product running on top of GenAI services, a live catalog, and a shopper base that expects instant answers. Five engineering problems shaped the build:
Realtime Low-Latency Responses
A conversational chat falls apart above a few seconds of lag. We engineered the response loop around WebSockets, OpenAI realtime APIs, and streamed function calls to land an average response time of under 2.5 seconds.
Syncing Live Inventory in Realtime
A recommendation is only useful if the product is actually available. We built an automated pipeline that flows every catalog and stock change into pgVector, and a function-call layer that verifies stock before a recommendation is returned.
Multi-Parameter Recommendations
Shoppers describe what they want in many dimensions: budget, occasion, needs, style, availability. We built a RAG retrieval layer that combines semantic similarity with hard constraints, so recommendations respect every dimension the shopper mentioned.
Shopping-Only Guardrails
An AI on a customer-facing chat cannot drift off topic. We wrote a prompt guardrail layer that keeps every conversation to shopping and product topics, and rejects anything else politely without breaking the flow.
Clean Human Handoff
Some queries need a human. We built an escalation flow that classifies intent, hands off the full context to a human agent, and does it inside the same chat surface so the shopper never has to repeat themselves.
WHAT WAS DELIVERED
A Production Chatbot Module Grounded in a Live Catalog
Vatrina’s chatbot module shipped as a production system on the Vatrina platform: realtime, stock-aware, guardrailed, and ready for handoff. Every piece the brief called out was engineered rather than approximated.
| VISION | DELIVERED | |
| Conversational AI | “A realtime conversational AI that can do NLP to handle and solve complex customer queries” | Sub-2.5-second responses, streamed via WebSockets, with intent handling and multi-turn context |
| Product Recommendations | “Recommend products based on budget, needs, occasion” | RAG-powered engine on pgVector, combining semantic similarity with hard constraints from the shopper |
| Inventory Awareness | “Recommendations tied to realtime stock availability” | Automated ingestion pipeline plus OpenAI function calls that verify stock before every recommendation |
| Guardrails | “Restrict queries to shopping” | Prompt-level topic constraints that keep the chatbot on-brand and on-topic |
| Human Handoff | “Route queries for human intervention whenever needed” | Intent-classified escalation flow that hands off full context to a human agent inside the same chat |
WHAT TO EXPECT FROM US
Transparent Engineering for Realtime Conversational AI Products
If you are building a conversational AI or a RAG-backed product and weighing engineering partners, here is what working with our team actually looks like.

A plan before a proposal.
We start with a working session to understand what your product needs to do, who it serves, and where the hard parts are. For a conversational AI product, that means surfacing the latency, grounding, and guardrail constraints before we write a line of code.

A live demo every two weeks.
At the end of every sprint, you see the actual product: what is built, what is working, and what we are still figuring out. You always know where your product stands.

Engineering, not prompt tweaking.
GenAI products live or die on the engineering around the model: retrieval, function calls, guardrails, streaming, observability. We treat the model as one component in a real system, not the system itself.

Experience with the hard parts.
Realtime pipelines, vector databases, retrieval-augmented generation, prompt guardrails, and human handoff flows: we have shipped these into production. They are not research projects for us, which means you skip a year of trial and error.

Quality that does not depend on one person.
Every change is tested before it reaches you. Latency, retrieval accuracy, and guardrail behaviour are regression-checked on every release, not by one engineer eyeballing a chat transcript.

Reliability built in from day one.
Third-party AI services will fail. Your product should not. We design retry, fallback, and stateful recovery into the architecture from the first sprint, not as a bolt-on after the first outage.

You own what we build.
At handover you get the full system: source code, prompt libraries, ingestion pipeline, infrastructure, and documentation. Your team can take it forward independently or keep us on; that is your choice.

A founder-friendly working rhythm.
You are in every demo, every trade-off conversation, every milestone. You are not a ticket number to us; you are the product’s first and most important user.
TECHNICAL NOTES
The Architecture and Tooling Powering the Vatrina Chatbot Module
Backend Stack
Ruby on Rails service layer running on PostgreSQL. The Rails app owns the shopper-facing API, the chat state, the ingestion jobs, and the escalation routing to human agents.
Vector Storage: pgVector
pgVector runs inside the same PostgreSQL instance, so product embeddings live next to product data. Retrieval queries and inventory queries share a database, which keeps the RAG loop consistent and low-latency.
GenAI + Function Calls
OpenAI powers the reasoning and response generation. Function calls hit live endpoints for inventory, product details, and pricing mid-conversation, so responses are grounded in current data rather than model memory.
RAG Architecture
Every incoming query is embedded, run through pgVector for top-k retrieval, and the retrieved products are packed into the model prompt as grounded context. Recommendations are tied to real SKUs.
Realtime Delivery
WebSockets stream every token to the shopper as it is generated. Combined with function-call parallelism, the average first-response time lands under 2.5 seconds.
Automated Ingestion Pipeline
New products, product edits, and stock changes flow through a queue-backed pipeline that normalises, embeds, and upserts into pgVector. No human is in the loop for catalog maintenance.
Prompt Guardrails
Structured prompt templates constrain the chatbot to shopping topics and enforce the tone of the brand. Off-topic queries are rejected politely, and the AI never leaves the sandbox the brand approved.
Human Handoff Layer
An intent classifier flags queries that need human attention. When it fires, the module hands the shopper, the transcript, and the intent metadata over to a human agent inside the same chat, no restart required.
