This workflow follows the HTTP Request → OpenAI recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"name": "Document Q&A RAG Pipeline",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "ask",
"responseMode": "responseNode",
"options": {}
},
"id": "a7b8c9d0-7777-4000-8000-000000000001",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
250,
300
]
},
{
"parameters": {
"resource": "chat",
"operation": "message",
"model": "gpt-4o",
"messages": {
"values": [
{
"role": "system",
"content": "Convert the following user question into an optimized search query for a vector database. Return ONLY the search query string, no explanation. Focus on key concepts and remove filler words."
},
{
"role": "user",
"content": "={{ $json.body.question }}"
}
]
},
"options": {
"temperature": 0.1,
"maxTokens": 128
}
},
"id": "a7b8c9d0-7777-4000-8000-000000000002",
"name": "Optimize Query",
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1.6,
"position": [
500,
300
],
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"method": "POST",
"url": "https://api.openai.com/v1/embeddings",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ JSON.stringify({ input: $json.text, model: 'text-embedding-3-small' }) }}",
"options": {}
},
"id": "a7b8c9d0-7777-4000-8000-000000000003",
"name": "Generate Embedding",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
750,
300
],
"credentials": {
"httpHeaderAuth": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"method": "POST",
"url": "https://your-index-name-abc123.svc.pinecone.io/query",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ JSON.stringify({ vector: $json.data[0].embedding, topK: 5, includeMetadata: true, namespace: 'documents' }) }}",
"options": {
"timeout": 10000
}
},
"id": "a7b8c9d0-7777-4000-8000-000000000004",
"name": "Pinecone Vector Search",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
1000,
300
],
"credentials": {
"httpHeaderAuth": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"resource": "chat",
"operation": "message",
"model": "gpt-4o",
"messages": {
"values": [
{
"role": "system",
"content": "You are a knowledgeable document assistant. Answer the user's question using ONLY the provided context from our document database. If the context doesn't contain enough information to answer, say so clearly. Always cite which document(s) you're referencing.\n\nRules:\n1. Only use information from the provided context\n2. If uncertain, indicate your confidence level\n3. Quote relevant passages when helpful\n4. If the question cannot be answered from the context, say: \"I don't have enough information in the available documents to answer this question.\""
},
{
"role": "user",
"content": "=Question: {{ $('Webhook').item.json.body.question }}\n\nRelevant Document Context:\n{{ $json.matches ? $json.matches.map((m, i) => `[Doc ${i+1}] (score: ${m.score.toFixed(3)}) ${m.metadata.source || 'Unknown'}:\\n${m.metadata.text}`).join('\\n\\n') : 'No matching documents found.' }}"
}
]
},
"options": {
"temperature": 0.3,
"maxTokens": 1024
}
},
"id": "a7b8c9d0-7777-4000-8000-000000000005",
"name": "OpenAI Answer",
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1.6,
"position": [
1250,
300
],
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"options": {
"responseCode": 200
},
"respondWith": "json",
"responseBody": "={{ JSON.stringify({ answer: $json.text, question: $('Webhook').item.json.body.question, sources: ($('Pinecone Vector Search').item.json.matches || []).map(m => ({ source: m.metadata.source, score: m.score })) }) }}"
},
"id": "a7b8c9d0-7777-4000-8000-000000000006",
"name": "Respond to Webhook",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.1,
"position": [
1500,
300
]
}
],
"connections": {
"Webhook": {
"main": [
[
{
"node": "Optimize Query",
"type": "main",
"index": 0
}
]
]
},
"Optimize Query": {
"main": [
[
{
"node": "Generate Embedding",
"type": "main",
"index": 0
}
]
]
},
"Generate Embedding": {
"main": [
[
{
"node": "Pinecone Vector Search",
"type": "main",
"index": 0
}
]
]
},
"Pinecone Vector Search": {
"main": [
[
{
"node": "OpenAI Answer",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Answer": {
"main": [
[
{
"node": "Respond to Webhook",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1"
},
"staticData": null
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
httpHeaderAuthopenAiApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Document Q&A RAG Pipeline. Uses openAi, httpRequest. Webhook trigger; 6 nodes.
Source: https://github.com/mlnjsh/n8n-workflows-mega/blob/main/workflows/ai-agents/07-document-qa-rag-pipeline.json — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
This workflow captures new leads via webhook, enriches and scores them with Apollo and Google Gemini, logs everything in Google Sheets, and automates outreach, reply handling, follow-ups, meeting prep
This powerful n8n automation workflow is designed to execute advanced B2B lead enrichment and hyper-personalization for cold email outreach. By orchestrating a complex chain of data scraping, AI analy
Propulsar — Content Engine v3. Uses openAi, httpRequest, googleSheets. Webhook trigger; 73 nodes.
Eu Clara – Funil Kiwify Completo. Uses postgres, openAi, httpRequest, gmail. Webhook trigger; 70 nodes.
Postagem Redes — Portal: Ações. Uses openAi, googleGemini, ollama, httpRequest. Webhook trigger; 58 nodes.