AutomationFlowsAI & RAG › AI Chatbot with RAG Memory

AI Chatbot with RAG Memory

Original n8n title: Ragbook - Chat

RagBook - Chat. Uses agent, memoryPostgresChat, vectorStoreSupabase, embeddingsOpenAi. Webhook trigger; 11 nodes.

Webhook trigger★★★☆☆ complexityAI-powered11 nodesAgentMemory Postgres ChatSupabase Vector StoreOpenAI EmbeddingsOutput Parser StructuredGoogle Gemini ChatAnthropic ChatOpenAI Chat
AI & RAG Trigger: Webhook Nodes: 11 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": "RagBook - Chat",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "2fabf43f-6e6e-424b-8e93-9150e9ce7d6c",
        "authentication": "headerAuth",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        32,
        400
      ],
      "id": "14c9e2d7-57f1-46bb-a708-be12cebdd5d7",
      "name": "Webhook",
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.body.message }}",
        "hasOutputParser": true,
        "options": {
          "systemMessage": "=You are tasked with answering a question using provided chunks of information. \n\nYour goal is to provide an accurate answer from these chunks while citing your sources. When you use information from a specific chunk in your answer, you must cite it using the specified JSON output format.\n\nThe citation should appear at the end of the sentence or paragraph where the information is used.\n\nTake note of the index of the chunk returned from the vector store, the source_id of the chunk as well as the lines from and lines to... that way we can trace back the cited source.\n\nIf you cannot answer the question using the provided chunks, say \"Sorry I don't know\".\n\nImportant: You MUST trigger the \"Supabase Vector Store\" tool\nImportant: Only based your answers on information in the provided chunks from the vector store"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.9,
      "position": [
        288,
        320
      ],
      "id": "37e1758f-633c-475c-9358-919dd3babe51",
      "name": "AI Agent",
      "retryOnFail": true,
      "waitBetweenTries": 5000,
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $json.body.session_id }}",
        "contextWindowLength": 20
      },
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "typeVersion": 1.3,
      "position": [
        400,
        704
      ],
      "id": "979c2e58-502d-4ede-9c3d-4cdc3d73eec6",
      "name": "Postgres Chat Memory",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "mode": "retrieve-as-tool",
        "toolName": "retrieve_knowledge",
        "toolDescription": "Retrieve releveant information",
        "tableName": {
          "__rl": true,
          "value": "documents",
          "mode": "list",
          "cachedResultName": "documents"
        },
        "topK": 10,
        "options": {
          "metadata": {
            "metadataValues": [
              {
                "name": "notebook_id",
                "value": "={{ $json.body.session_id }}"
              }
            ]
          }
        }
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "typeVersion": 1.1,
      "position": [
        560,
        640
      ],
      "id": "5af4fbba-0d6e-4390-8a93-80f8fd8fa400",
      "name": "Supabase Vector Store",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1.2,
      "position": [
        640,
        832
      ],
      "id": "5569f32d-2f1c-47de-8f8a-2957807a3a8d",
      "name": "Embeddings OpenAI",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n\t\"output\": [\n  {\n    \"text\": \"Formula 1 (also known as Formula One) is a premier motorsport championship organized by the FIA...\",\n    \"citations\": [\n      {\n        \"chunk_index\": 0,\n        \"chunk_source_id\": \"701bd18c-2531-48e5-8d09-df22e7cc3d21\",\n        \"chunk_lines_from\": 25,\n        \"chunk_lines_to\": 50\n      }\n    ]\n  },\n  {\n    \"text\": \"Formula 1 (also known as Formula One) is a premier motorsport championship organized by the FIA...\",\n    \"citations\": [\n      {\n        \"chunk_index\": 0,\n        \"chunk_source_id\": \"701bd18c-2531-48e5-8d09-df22e7cc3d21\",\n        \"chunk_lines_from\": 25,\n        \"chunk_lines_to\": 50\n      }\n    ]\n  }\n]\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.2,
      "position": [
        864,
        528
      ],
      "id": "9586db41-3eb7-4bf4-8c4f-9671eb63cd52",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "content": "## To Do \n- Configure the Supabase nodes to reference your Project",
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        672,
        0
      ],
      "id": "068ff528-d836-43f0-bdb2-474bb1128277",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "modelName": "models/gemini-2.5-flash-preview-04-17-thinking",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        64,
        704
      ],
      "id": "4282631f-e42c-4fd9-980d-69aa0c066c96",
      "name": "Google Gemini Chat Model",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "claude-3-7-sonnet-20250219",
          "mode": "list",
          "cachedResultName": "Claude Sonnet 3.7"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "typeVersion": 1.3,
      "position": [
        -96,
        704
      ],
      "id": "e5d9cea8-ad20-422a-9092-9cd509bf7e53",
      "name": "Anthropic Chat Model",
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "o3",
          "mode": "list",
          "cachedResultName": "o3"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        224,
        704
      ],
      "id": "a8d7fd87-2664-453c-a7a0-f806b87be8ae",
      "name": "OpenAI Chat Model1",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "[![The AI Automators](https://www.theaiautomators.com/wp-content/uploads/2025/03/gray-logo.png)](https://www.theaiautomators.com/)\n## RagBook\nhttps://github.com/theaiautomators/insights-lm-public",
        "height": 220,
        "width": 280,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "id": "a55b9fa7-9bfa-46b7-b26b-af95b504035f",
      "name": "Sticky Note8"
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [],
        []
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Supabase Vector Store": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "bd3f9517-b2ae-4577-adaf-cf1ed774a9a9",
  "id": "P7Pg2I5giQN6WgIJ",
  "tags": [
    {
      "createdAt": "2025-05-12T13:43:59.783Z",
      "updatedAt": "2025-05-12T13:43:59.783Z",
      "id": "d3ygIhrGjDmzgrW0",
      "name": "TheAIAutomators.com"
    }
  ]
}

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

RagBook - Chat. Uses agent, memoryPostgresChat, vectorStoreSupabase, embeddingsOpenAi. Webhook trigger; 11 nodes.

Source: https://github.com/Sdiabate1337/ragBook/blob/41b1f9c1af78bb3d24a12b9f32acec49895bfca2/n8n/RagBook___Chat.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

Chatbot Webhook. Uses lmChatGoogleGemini, agent, outputParserStructured, memoryPostgresChat. Webhook trigger; 14 nodes.

Google Gemini Chat, Agent, Output Parser Structured +4
AI & RAG

InsightsLM - Chat. Uses agent, memoryPostgresChat, vectorStoreSupabase, embeddingsOpenAi. Webhook trigger; 11 nodes.

Agent, Memory Postgres Chat, Supabase Vector Store +5
AI & RAG

Indoor Farming Agent. Uses lmChatOpenAi, documentDefaultDataLoader, embeddingsOpenAi, toolVectorStore. Webhook trigger; 36 nodes.

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

AI-powered n8n workflow that creates viral LinkedIn posts by learning from successful content. Features two modules: (1) Telegram-based scraper that builds a vector database of viral LinkedIn posts, a

Telegram Trigger, Telegram, HTTP Request +9
AI & RAG

RAG_AI_Agent_PDFs_Excel. Uses lmChatOpenAi, documentDefaultDataLoader, embeddingsOpenAi, toolVectorStore. Webhook trigger; 28 nodes.

OpenAI Chat, Document Default Data Loader, OpenAI Embeddings +7