AutomationFlowsAI & RAG › AI Chatbot Query to Qdrant & Postgres

AI Chatbot Query to Qdrant & Postgres

Original n8n title: Chatbot Query Qdrant

Chatbot-Query-Qdrant. Uses httpRequest, postgres. Webhook trigger; 7 nodes.

Webhook trigger★★★★☆ complexity7 nodesHTTP RequestPostgres
AI & RAG Trigger: Webhook Nodes: 7 Complexity: ★★★★☆ Added:

This workflow follows the HTTP Request → Postgres 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": "Chatbot-Query-Qdrant",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "chatbot-rag",
        "options": {}
      },
      "id": "webhook-trigger",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        200,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=http://ollama:11434/api/embeddings",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "model",
              "value": "nomic-embed-text"
            },
            {
              "name": "prompt",
              "value": "={{ $json.body.pregunta || $json.body.question }}"
            }
          ]
        },
        "options": {}
      },
      "id": "query-embedding",
      "name": "Query Embedding",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://qdrant:6333/collections/reglamento_taekwondo/points/search",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"vector\": {{ JSON.stringify($json.embedding) }},\n  \"limit\": 3,\n  \"with_payload\": true\n}",
        "options": {}
      },
      "id": "qdrant-search",
      "name": "Qdrant Search",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        700,
        300
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "context-val",
              "name": "context",
              "value": "={{ $json.result.map(r => r.payload.text).join('\\n---\\n') }}",
              "type": "string"
            },
            {
              "id": "question-val",
              "name": "question",
              "value": "={{ $('Webhook').item.json.body.pregunta || $('Webhook').item.json.body.question }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "format-context",
      "name": "Format Context",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.2,
      "position": [
        950,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://ollama:11434/api/generate",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "model",
              "value": "smollm2:1.7b"
            },
            {
              "name": "prompt",
              "value": "=Eres un asistente experto en el reglamento de Taekwondo. Responde a la pregunta bas\u00e1ndote \u00fanicamente en el contexto proporcionado.\n\nContexto:\n{{ $json.context }}\n\nPregunta: {{ $json.question }}\n\nRespuesta corta y precisa:"
            },
            {
              "name": "stream",
              "value": "false"
            }
          ]
        },
        "options": {}
      },
      "id": "ollama-generate",
      "name": "Ollama Generate",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        1200,
        300
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "=INSERT INTO consultas_rag (pregunta, respuesta, documentos_usados) VALUES ('{{ $('Webhook').item.json.body.pregunta || $('Webhook').item.json.body.question }}', '{{ $json.response }}', ARRAY['reglamento_taekwondo']);",
        "options": {}
      },
      "id": "postgres-save",
      "name": "PostgreSQL Save",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.2,
      "position": [
        1450,
        300
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "respond-to-webhook",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1700,
        300
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Query Embedding",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Query Embedding": {
      "main": [
        [
          {
            "node": "Qdrant Search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Qdrant Search": {
      "main": [
        [
          {
            "node": "Format Context",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Context": {
      "main": [
        [
          {
            "node": "Ollama Generate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ollama Generate": {
      "main": [
        [
          {
            "node": "PostgreSQL Save",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PostgreSQL Save": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  }
}

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

Chatbot-Query-Qdrant. Uses httpRequest, postgres. Webhook trigger; 7 nodes.

Source: https://github.com/Diana27106/tfg-taekwondo/blob/68e897cda1e408b67ddc4261ce4854b6e9229820/n8n-workflows/query-workflow.json — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

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

AI & RAG

Kreativ: RAG Ingestion Pipeline. Uses httpRequest, postgres. Webhook trigger; 5 nodes.

HTTP Request, Postgres
AI & RAG

Camila IA. Uses postgres, crypto, redis, agent. Webhook trigger; 92 nodes.

Postgres, Crypto, Redis +13
AI & RAG

HeyDinastia. Uses executeCommand, httpRequest, youTube, postgres. Webhook trigger; 66 nodes.

Execute Command, HTTP Request, YouTube +15
AI & RAG

Corvus 3.2 Beta. Uses httpRequest, agent, lmChatOpenAi, vectorStoreSupabase. Webhook trigger; 48 nodes.

HTTP Request, Agent, OpenAI Chat +5
AI & RAG

This workflow automates business intelligence reporting by aggregating data from multiple sources, processing it through AI models, and delivering formatted dashboards via email. Designed for business

HTTP Request, Postgres, Google Drive +5