How to Build a RAG Workflow in n8n for Retail Product Recommendations for Shopify

This workflow enables you to deliver real-time, personalized product recommendations or dynamic content (for email, chatbots, or web) by combining your own business data with the power of large language models.

How to Build a RAG Workflow in n8n for Retail Product Recommendations for Shopify
Photo by Braden Jarvis / Unsplash

Step 1: Data Preparation and Ingestion

But raw data is rarely perfect. So, n8n’s function and set nodes step in, tidying up the information, normalizing text, and ensuring that every piece of data speaks the same language. Now, the magic begins: the cleaned customer profile and product catalog are sent to an embedding service like OpenAI, which transforms them into vectors—a kind of mathematical fingerprint that captures meaning, not just words.

  • Product Catalog Import:
    Use n8n’s HTTP Request or Shopify node to pull product data (including descriptions, images, prices, stock levels) from your e-commerce platform into the workflow.
  • Customer Data Integration:
    Connect to your CRM or database to retrieve user profiles, purchase history, and browsing behaviors.
Tip: Clean and normalize your data using n8n’s Edit Field or Function nodes to ensure consistency.
a close up of a window with a building in the background
Photo by Claudio Schwarz / Unsplash

Step 2: Embedding Creation and Storage

These embeddings are stored in a vector database, such as Pinecone or Qdrant, where they wait patiently for the next query. When a customer’s question arrives, it too is converted into an embedding, and n8n orchestrates a search for the closest matches. The most relevant products, based on both the customer’s needs and your live inventory, are plucked from the database.

  • Generate Embeddings:
    For each product and relevant customer data, call an embeddings API (such as OpenAI’s text-embedding-ada-002 or a Hugging Face model) using n8n’s HTTP Request node.
  • Store in Vector Database:
    Save the resulting vectors to a vector database like Pinecone, Qdrant, or Supabase Vector. This enables fast semantic search and similarity matching later.

Step 3: Real-Time Query Handling

  • Webhook Trigger:
    Set up a Webhook node to receive incoming queries (from a website, chatbot, or API call). The payload should include user context (e.g., current product viewed, customer ID, or free-text query).
  • Query Embedding:
    Generate an embedding for the incoming query using the same model as above.

Step 4: Semantic Search and Retrieval

  • Similarity Search:
    Use an HTTP Request node to query your vector database for the most relevant products or content, based on the query embedding.
  • Context Augmentation:
    Optionally, enrich the retrieved data with customer-specific information (e.g., purchase history, preferences) by merging streams in n8n.

Step 5: Generative AI Response

  • LLM Integration:
    Send the augmented context (retrieved products, user data, query) to a language model API (like OpenAI GPT-4, Claude, or Hugging Face) using an HTTP Request node.
    Prompt example:
    “Given this user’s past purchases and the following product data, generate a personalized recommendation message for email/website/chat.”
  • Format Output:
    Structure the AI’s response for your channel (e.g., JSON for API, HTML for web, or plain text for email).

Step 6: Delivery and Automation

  • Send to Channel:
    • For email: Use n8n’s integration with Omnisend, Mailchimp, or SendGrid to deliver the message.
    • For chatbot: Return the response via webhook or n8n’s built-in chatbot node.
    • For website: Expose the endpoint for your frontend to consume.

Example Use Cases

  • On-Site Product Recommendations: Show “You may also like” or “Complete the look” widgets powered by real-time, AI-driven suggestions.
  • Personalized Email Campaigns: Automatically generate and send individualized product picks to each subscriber.
  • AI Chatbots: Let customers ask for product advice (“I need shoes for winter hiking”) and get context-aware, up-to-date answers.
  • Customer Support: Retrieve order details or troubleshooting guides instantly, based on the customer’s query and history.

Example: Advanced Shopify RAG Workflow with Multi-Channel Orchestration

Below is a working n8n workflow in JSON format. You can import this directly into your n8n instance.

This example demonstrates a simplified RAG pipeline: it receives a user query via webhook, fetches user data, generates embeddings, queries a vector database, and returns a personalized product recommendation.

How This Feels in Action

When you import this workflow into n8n, you’re not just connecting APIs—you’re building a digital concierge. The webhook node stands at the door, greeting each new customer. As soon as someone asks for advice or a recommendation, the workflow springs into motion, gathering everything it needs to know about the customer and your products. It thinks deeply—using embeddings and vector search—to find what truly fits. And then, like a seasoned shop assistant, it crafts a response that’s not just accurate, but genuinely helpful.

This isn’t just automation. It’s empathy at scale, powered by data and AI, but orchestrated by you.

a large pipe in the middle of a field
Photo by Toro Tseleng / Unsplash

Download this RAG

Click the link below and subscribe to the newsletter to download it.


Interested in learning what I can do for you? Speak to me for a free consultation