AutomationFlowsGeneral › PDF Q&A with Pinecone RAG

PDF Q&A with Pinecone RAG

Original n8n title: PDF Q&a System with Pinecone RAG

PDF Q&A System with Pinecone RAG. Uses openAi, httpRequest. Webhook trigger; 7 nodes.

Webhook trigger★★★★☆ complexityAI-powered7 nodesOpenAIHTTP Request
General Trigger: Webhook Nodes: 7 Complexity: ★★★★☆ AI nodes: yes Added:

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 →

Download .json
{
  "name": "PDF Q&A System with Pinecone RAG",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "pdf-qa",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "f6a7b8c9-6666-4000-8000-000000000001",
      "name": "Question Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "set-query",
              "name": "query",
              "value": "={{ $json.body.question }}",
              "type": "string"
            },
            {
              "id": "set-top-k",
              "name": "topK",
              "value": "={{ $json.body.topK || 5 }}",
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "id": "f6a7b8c9-6666-4000-8000-000000000002",
      "name": "Parse Query",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "resource": "embedding",
        "operation": "create",
        "model": "text-embedding-3-small",
        "input": "={{ $json.query }}"
      },
      "id": "f6a7b8c9-6666-4000-8000-000000000003",
      "name": "Create Query Embedding",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.6,
      "position": [
        680,
        300
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://your-index-xxxxxxx.svc.pinecone.io/query",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ vector: $json.data[0].embedding, topK: $('Parse Query').item.json.topK, includeMetadata: true, namespace: 'pdf-documents' }) }}",
        "options": {}
      },
      "id": "f6a7b8c9-6666-4000-8000-000000000004",
      "name": "Pinecone Vector Search",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        900,
        300
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "set-context",
              "name": "context",
              "value": "={{ $json.matches.map(m => m.metadata.text).join('\\n\\n---\\n\\n') }}",
              "type": "string"
            },
            {
              "id": "set-sources",
              "name": "sources",
              "value": "={{ $json.matches.map(m => ({ source: m.metadata.source, page: m.metadata.page, score: m.score })) }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "f6a7b8c9-6666-4000-8000-000000000005",
      "name": "Build Context",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1120,
        300
      ]
    },
    {
      "parameters": {
        "resource": "chat",
        "operation": "message",
        "model": "gpt-4o",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are a precise Q&A assistant that answers questions based ONLY on the provided context from PDF documents. If the context doesn't contain enough information to answer, say so. Always cite which document and page number your answer comes from. Be concise and accurate."
            },
            {
              "role": "user",
              "content": "=Context from PDF documents:\n{{ $json.context }}\n\n---\n\nQuestion: {{ $('Parse Query').item.json.query }}"
            }
          ]
        },
        "options": {
          "temperature": 0.2,
          "maxTokens": 1000
        }
      },
      "id": "f6a7b8c9-6666-4000-8000-000000000006",
      "name": "OpenAI Answer",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.6,
      "position": [
        1340,
        300
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ answer: $json.message.content, sources: JSON.parse($('Build Context').item.json.sources), query: $('Parse Query').item.json.query }) }}",
        "options": {
          "responseCode": 200
        }
      },
      "id": "f6a7b8c9-6666-4000-8000-000000000007",
      "name": "Respond with Answer",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1560,
        300
      ]
    }
  ],
  "connections": {
    "Question Webhook": {
      "main": [
        [
          {
            "node": "Parse Query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Query": {
      "main": [
        [
          {
            "node": "Create Query Embedding",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Query Embedding": {
      "main": [
        [
          {
            "node": "Pinecone Vector Search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pinecone Vector Search": {
      "main": [
        [
          {
            "node": "Build Context",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Context": {
      "main": [
        [
          {
            "node": "OpenAI Answer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Answer": {
      "main": [
        [
          {
            "node": "Respond with Answer",
            "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.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

PDF Q&A System with Pinecone RAG. Uses openAi, httpRequest. Webhook trigger; 7 nodes.

Source: https://github.com/mlnjsh/n8n-workflows-mega/blob/main/workflows/ai-rag/01-pdf-qa-system.json — original creator credit. Request a take-down →

More General workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

General

Main: Submit Assignment. Uses readBinaryFile, httpRequest, openAi. Webhook trigger; 22 nodes.

Read Binary File, HTTP Request, OpenAI
General

Contact-Us. Uses emailSend, httpRequest, nocoDb, openAi. Webhook trigger; 7 nodes.

Email Send, HTTP Request, Noco Db +1
General

AI Blog Post Generator. Uses openAi, httpRequest. Webhook trigger; 6 nodes.

OpenAI, HTTP Request
General

AI SEO Meta Tag Generator. Uses httpRequest, openAi. Webhook trigger; 6 nodes.

HTTP Request, OpenAI
General

RoboNuggets - Faceless POV AI Machine (R24). Uses scheduleTrigger, googleSheets, chainLlm, lmChatOpenAi. Scheduled trigger; 31 nodes.

Google Sheets, Chain Llm, OpenAI Chat +5