n8n + n8n: RAG Sales Chatbot + CRM for E-commerce: Product Q&A, Live Stock Check & Lead Capture
Your e-commerce store loses sales at 2 AM. A shopper lands on a product page, has one question — "Does this ship to Canada?" or "Is the medium in stock?" — and there's no one to answer. They don't ema
Your e-commerce store loses sales at 2 AM. A shopper lands on a product page, has one question — "Does this ship to Canada?" or "Is the medium in stock?" — and there's no one to answer. They don't email. They don't wait. They close the tab and buy from a competitor. Live chat staffed by humans doesn't scale, and generic chatbots hallucinate answers about products they've never seen. This template solves the exact gap: a RAG-powered sales assistant that answers from your catalog, checks real Shopify stock, and drops every qualified conversation into HubSpot as a lead — fully automated in n8n.
The Problem: Pre-Sale Questions Have No Owner
Most stores have three broken options for pre-sale questions. Human live chat is expensive and only covers business hours. FAQ pages force the shopper to hunt and rarely match the exact question. Off-the-shelf AI chatbots sound confident but invent specs, quote wrong prices, and promise stock that sold out yesterday — which is worse than silence because it erodes trust and generates support tickets.
The core technical failure is grounding. A raw LLM has no idea what's in your catalog. Ask it about "the waterproof rating on the X200 jacket" and it will confidently guess. It also has no idea what's actually on the shelf — inventory changes hourly, but a static prompt is frozen at deploy time. And even when a bot has a great conversation, the intent evaporates the moment the tab closes because nothing captures the lead. You get the cost of AI without the two things that drive revenue: accuracy and follow-up.
The Solution: Retrieval-Grounded Answers + Live Stock + Lead Capture
This template stitches three capabilities into one n8n workflow. RAG (Retrieval-Augmented Generation) grounds every answer in your product catalog, so the bot quotes real specs, prices, and descriptions instead of guessing. A live Shopify lookup hits the Admin API at question time, so "in stock?" reflects the inventory count this second, not a nightly export. And a HubSpot capture step writes the shopper's email, the products discussed, and the conversation summary into your CRM the moment intent appears.
The flow is straightforward: a message arrives via webhook → the workflow embeds the question and retrieves the most relevant catalog chunks from a vector store → an AI Agent node composes an answer grounded in those chunks → if the shopper asks about availability, a tool call queries Shopify for the current inventory level → if the shopper shares contact details or shows buying intent, a HubSpot node upserts the contact. The AI never answers stock or price from memory; it always defers to the retrieval and API tools. That single design rule is what separates a reliable sales assistant from a liability.
Step-by-Step Setup in n8n
1. Ingest your catalog into a vector store. Run a one-time indexing workflow: an HTTP Request or Shopify node pulls all products, a Default Data Loader chunks each product's title, description, variants, and metafields, an Embeddings OpenAI node (model text-embedding-3-small) vectorizes them, and a Vector Store (Pinecone / Supabase / Qdrant) node in insert mode writes them. Store the product handle and price in the metadata so you can cite the source and link back.
2. Build the chat entry point. Use a Webhook node (or the Chat Trigger if you're embedding n8n's hosted widget) to receive { sessionId, message }. Wire a Window Buffer Memory node keyed on sessionId so the assistant remembers the thread across turns.
3. Configure the AI Agent. Drop an AI Agent node (Tools Agent type) with an OpenAI Chat Model sub-node (gpt-4o-mini is enough and cheap). In the system prompt, pin the rules: "Answer only from the provided catalog tool. Never state price or stock without calling a tool. If information isn't retrieved, say you'll connect them to a human." This is your hallucination firewall.
4. Attach the tools. Give the agent three tools. First, a Vector Store Tool pointed at your index for product Q&A and recommendations. Second, an HTTP Request Tool named check_stock that calls the Shopify Admin API GET /admin/api/2024-01/products/{id}/variants.json (or the GraphQL inventoryLevel query) and returns available. Third, a HubSpot Tool configured to create/update a contact. Describe each tool clearly in its description field — the agent decides when to call it based on that text.
5. Wire lead capture and response. When the agent calls the HubSpot tool, map the shopper's email, the products discussed, and a conversation summary into a Create or Update Contact operation, tagging lifecyclestage = lead and a source property like chatbot_ecommerce. Finish with a Respond to Webhook node returning the agent's reply to your storefront widget.
6. Test with the pinned execution view. Send test questions — a spec question, a stock question, a "can I get 10% off" question — and confirm the agent calls the right tool each time. Watch for the agent answering stock from the vector store instead of the live API; if it does, tighten the tool description and system prompt.
Benefits: Where the Revenue Actually Comes From
The payoff is measurable across three lines. Recovered sales: questions get answered instantly, 24/7, in the buyer's language, so the 2 AM shopper converts instead of bouncing. Accurate answers reduce returns and tickets: because every spec and stock figure is grounded, you stop promising things you can't deliver, which cuts refund requests and post-purchase support load. A growing lead pipeline: every conversation that shows intent becomes a HubSpot contact you can retarget with email flows and abandoned-cart sequences — turning a support cost center into a top-of-funnel engine.
Because it's n8n, you own the whole thing. No per-seat SaaS chatbot fees, no vendor lock-in, and you can extend it in an afternoon — add a returns-policy tool, plug in WhatsApp as a second channel, or route high-value carts to a human. The marginal cost per conversation is a few cents of OpenAI tokens plus one Shopify API call.
Common Pitfalls (and How to Avoid Them)
Stale index. If you embed your catalog once and forget it, the bot recommends discontinued products. Schedule the ingestion workflow nightly with a Cron node, and upsert by product ID so changed descriptions overwrite instead of duplicating.
Letting the LLM answer stock or price. The most dangerous failure is a confident wrong answer. Enforce the tool-only rule in the system prompt and keep price/inventory out of the vector metadata that gets injected verbatim — force those through the live tool every time.
Shopify rate limits. The Admin REST API caps at 2 requests/second on standard plans. If your chat volume spikes, batch stock checks or switch the check_stock tool to the GraphQL API, which has a more forgiving cost-based limit. Add a Retry On Fail setting to the HTTP node.
Capturing junk leads. Don't upsert every anonymous visitor to HubSpot — you'll pollute your CRM. Only fire the HubSpot tool when the shopper actually provides an email or explicitly asks to be contacted, and dedupe on email so repeat visitors update one record.
No human fallback. Some questions genuinely need a person. Add a branch: if the agent's confidence is low or the retrieval returns nothing, respond with a handoff message and post the transcript to a Slack channel via the Slack node. A graceful "let me get someone" beats a fabricated answer every time.
Set up correctly, this is not a novelty widget — it's a salesperson that never sleeps, never guesses, and never forgets to follow up. Ground it in your catalog, wire it to live stock, and let HubSpot catch every lead it earns.
Ja construimos isso pra voce
Nao comece do zero. O RAG Sales Chatbot + CRM for E-commerce: Product Q&A, Live Stock Check & Lead Capture e um workflow n8n pronto para instalar — conecta suas ferramentas em minutos, sem codigo.
Instalar por $79.0 →