How to Use n8n for Real-World RAG Workflows

Here’s a real n8n RAG workflow you can explain in interviews:

Webhook Trigger
Receive user question
Generate embedding for question
Search vector database
Retrieve top-k relevant chunks
Build prompt with context
Call LLM
Return answer with citations

Example Workflow

1. Webhook Trigger

User sends:

{
"question": "What is our refund policy?"
}

2. OpenAI Embeddings Node

Convert the question into a vector.

Input: "What is our refund policy?"
Output: [0.12, -0.45, 0.88, ...]

3. Vector DB Search Node

Use:

  • Pinecone
  • Qdrant
  • Weaviate
  • Azure AI Search vector index

Search:

top_k = 5
similarity = cosine

Returns chunks like:

[
{
"text": "Refunds are available within 30 days...",
"source": "refund_policy.pdf",
"score": 0.91
}
]

4. Code Node: Build Context

const chunks = items.map(item => item.json.text).join("\n\n");
return [
{
json: {
context: chunks,
question: $json.question
}
}
];

5. OpenAI Chat Node

Prompt:

You are an internal company assistant.
Answer only using the provided context.
If the answer is not in the context, say you don't know.
Include source names.
Context:
{{ $json.context }}
Question:
{{ $json.question }}

6. Respond to Webhook

Return:

{
"answer": "Refunds are available within 30 days...",
"sources": ["refund_policy.pdf"]
}

Interview Explanation

“I used n8n as the orchestration layer for the RAG workflow. A webhook receives the user query, then n8n generates an embedding, searches a vector database for the most relevant document chunks, builds a grounded prompt, sends it to the LLM, and returns the final answer with citations.”

Where Azure Fits

ADLS Gen2 → Databricks → Chunking → Embeddings → Azure AI Search
User Question → n8n → OpenAI Embedding → Vector Search → LLM Answer

n8n is mainly the workflow orchestrator, while Azure handles storage, processing, search, and model calls.

Leave a comment