AutomationFlowsAI & RAG › RAG Answ Sub

RAG Answ Sub

RAG_answ_sub. Uses vectorStorePGVector, embeddingsOpenAi, agent, toolVectorStore. Event-driven trigger; 10 nodes.

Event trigger★★★☆☆ complexityAI-powered10 nodesVector Store PgvectorOpenAI EmbeddingsAgentTool Vector StoreOpenRouter ChatMemory Postgres ChatExecute Workflow Trigger
AI & RAG Trigger: Event Nodes: 10 Complexity: ★★★☆☆ AI nodes: yes Added:

This workflow follows the Agent → OpenAI Embeddings 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": "RAG_answ_sub",
  "nodes": [
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "8a9ac777-5ae2-4c60-9203-33ed9f4a06cb",
              "name": "query",
              "value": "={{ $json.text }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        624,
        0
      ],
      "id": "57803236-2409-4b17-a301-b74db3aff05c",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStorePGVector",
      "typeVersion": 1.3,
      "position": [
        784,
        368
      ],
      "id": "88624535-6167-4ebb-b872-7d2ff4c0419c",
      "name": "Postgres PGVector Store",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1.2,
      "position": [
        752,
        544
      ],
      "id": "19d02c80-05a6-4e03-8cc6-592669c08d6f",
      "name": "Embeddings OpenAI",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=\u0412\u043e\u043f\u0440\u043e\u0441: {{ $json.query }}\n\n\u201c\u0415\u0441\u043b\u0438 \u0432\u043e\u043f\u0440\u043e\u0441 \u043f\u0440\u043e \u0444\u0430\u043a\u0442\u044b/\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0438\u0437 \u0431\u0430\u0437\u044b \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 Answer questions with a vector store.\u201d\n\n\u0415\u0441\u043b\u0438 \u0432\u043e\u043f\u0440\u043e\u0441/\u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 \u043d\u0435\u0442 \u0432 \u0431\u0430\u0437\u0435, \u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0448\u044c: \"\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u043e \u0432\u0430\u0448\u0435\u043c\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u043d\u0435\u0442 \u0432 \u0431\u0430\u0437\u0435, \u043d\u043e\" \u0438 \u0434\u0430\u0435\u0448\u044c \u043e\u0442\u0432\u0435\u0442 \u0441\u0430\u043c.",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        848,
        -16
      ],
      "id": "d3c54431-d7fc-4c23-8406-0029a2c59a0c",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "description": "\u043e\u0442\u0432\u0435\u0447\u0430\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u043c\u0443 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443\n\n\u0435\u0441\u043b\u0438 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u2014 \u201c\u043d\u0435 \u043d\u0430\u0448\u0451\u043b \u0432 \u0431\u0430\u0437\u0435 \u0437\u043d\u0430\u043d\u0438\u0439\u201d"
      },
      "type": "@n8n/n8n-nodes-langchain.toolVectorStore",
      "typeVersion": 1.1,
      "position": [
        1040,
        208
      ],
      "id": "060289d0-6fd3-4f44-b08e-e3db558ecea4",
      "name": "Answer questions with a vector store"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "typeVersion": 1,
      "position": [
        1088,
        368
      ],
      "id": "6f43a859-4140-45e3-9f72-76eb33e0e94f",
      "name": "OpenRouter Chat Model",
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('When Executed by Another Workflow').item.json.chat_id }}"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "typeVersion": 1.3,
      "position": [
        896,
        160
      ],
      "id": "fdb49da0-d297-45d0-8e1e-8e37ed900180",
      "name": "Postgres Chat Memory",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "typeVersion": 1,
      "position": [
        736,
        176
      ],
      "id": "2b18a582-56a5-4a70-89fd-09599d47925e",
      "name": "OpenRouter Chat Model1",
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "text"
            },
            {
              "name": "chat_id"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        -240,
        240
      ],
      "id": "8f55316e-8a52-4de3-9d3d-637b080a0a9b",
      "name": "When Executed by Another Workflow"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a42bb38c-7cf0-41f2-9f63-2d5fa67f0427",
              "name": "output",
              "value": "={{ $json.output }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1200,
        -16
      ],
      "id": "cbdc2854-e61b-48a3-9f8a-9b868bbb50f2",
      "name": "Edit Fields1"
    }
  ],
  "connections": {
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Postgres PGVector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres PGVector Store": {
      "ai_vectorStore": [
        [
          {
            "node": "Answer questions with a vector store",
            "type": "ai_vectorStore",
            "index": 0
          }
        ]
      ]
    },
    "Answer questions with a vector store": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Answer questions with a vector store",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "0b834708-0d73-4450-ac5e-de8eaec6312d",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "pLuhjN9G02wClFf7",
  "tags": []
}

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

RAG_answ_sub. Uses vectorStorePGVector, embeddingsOpenAi, agent, toolVectorStore. Event-driven trigger; 10 nodes.

Source: https://github.com/mdseyam-as/tg-bot-with-RAG/blob/2cb5bc9d33293b64264e4a4d139aec969e1b3636/workflows/RAG_answ_sub.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

Order and Delivery Support. Uses lmChatOpenAi, documentDefaultDataLoader, embeddingsOpenAi, toolVectorStore. Event-driven trigger; 29 nodes.

OpenAI Chat, Document Default Data Loader, OpenAI Embeddings +15
AI & RAG

This powerful AI automation add-on upgrades your Telegram Bot Starter Template by integrating a fully functional AI chatbot and a context-aware AI agent that answers user questions using your internal

OpenAI Chat, Document Default Data Loader, OpenAI Embeddings +10
AI & RAG

HR & IT Helpdesk Chatbot with Audio Transcription. Uses stickyNote, manualTrigger, httpRequest, extractFromFile. Event-driven trigger; 27 nodes.

HTTP Request, Vector Store Pgvector, OpenAI Embeddings +9
AI & RAG

HR & IT Helpdesk Chatbot with Audio Transcription. Uses stickyNote, manualTrigger, httpRequest, extractFromFile. Event-driven trigger; 27 nodes.

HTTP Request, Vector Store Pgvector, OpenAI Embeddings +9
AI & RAG

An intelligent chatbot that assists employees by answering common HR or IT questions, supporting both text and audio messages. This unique feature ensures employees can conveniently ask questions via

HTTP Request, Vector Store Pgvector, OpenAI Embeddings +9