AutomationFlowsAI & RAG › AI RAG Code Assistant Chat

AI RAG Code Assistant Chat

Original n8n title: RAG Code Assistant

RAG Code Assistant. Uses chatTrigger, agent, lmChatOpenAi, toolHttpRequest. Chat trigger; 6 nodes.

Chat trigger trigger★★☆☆☆ complexityAI-powered6 nodesChat TriggerAgentOpenAI ChatTool Http Request
AI & RAG Trigger: Chat trigger Nodes: 6 Complexity: ★★☆☆☆ AI nodes: yes Added:

This workflow follows the Agent → Chat Trigger 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 Code Assistant",
  "nodes": [
    {
      "parameters": {},
      "id": "chat-trigger",
      "name": "When chat message received",
      "type": "n8n-nodes-base.chatTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "options": {
          "systemMessage": "You are a helpful Code Assistant. You have access to a RAG system to search code, explain symbols, and index the codebase.\n\nAlways use the 'search_code' tool to find relevant code before answering questions about the codebase.\nIf the user asks to index a folder, use 'index_code'."
        }
      },
      "id": "ai-agent",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.6,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "options": {
          "temperature": 0.3
        }
      },
      "id": "openai-model",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1,
      "position": [
        220,
        220
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://localhost:8000/query",
        "authentication": "none",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "query",
              "value": "={{ $fromAI(\"query\") }}"
            },
            {
              "name": "k",
              "value": "5"
            }
          ]
        },
        "toolDescription": "Search the codebase for code snippets relevant to the query.",
        "toolName": "search_code"
      },
      "id": "tool-search",
      "name": "Search Code",
      "type": "@n8n/n8n-nodes-langchain.toolHttpRequest",
      "typeVersion": 1,
      "position": [
        500,
        -100
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://localhost:8000/index",
        "authentication": "none",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "path",
              "value": "={{ $fromAI(\"path\") }}"
            },
            {
              "name": "force",
              "value": false
            }
          ]
        },
        "toolDescription": "Index the codebase at a specific path. Use this when the user asks to index or update the code.",
        "toolName": "index_code"
      },
      "id": "tool-index",
      "name": "Index Code",
      "type": "@n8n/n8n-nodes-langchain.toolHttpRequest",
      "typeVersion": 1,
      "position": [
        660,
        -100
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://localhost:8000/mcp",
        "authentication": "none",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "method",
              "value": "rag.explain"
            },
            {
              "name": "params",
              "value": "={{ { \"symbol\": $fromAI(\"symbol\") } }}"
            },
            {
              "name": "id",
              "value": 1
            }
          ]
        },
        "toolDescription": "Get an explanation for a specific code symbol or concept.",
        "toolName": "explain_symbol"
      },
      "id": "tool-explain",
      "name": "Explain Symbol",
      "type": "@n8n/n8n-nodes-langchain.toolHttpRequest",
      "typeVersion": 1,
      "position": [
        820,
        -100
      ]
    }
  ],
  "connections": {
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Search Code": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Index Code": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Explain Symbol": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}

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 Code Assistant. Uses chatTrigger, agent, lmChatOpenAi, toolHttpRequest. Chat trigger; 6 nodes.

Source: https://github.com/dthompsonfl/jules_rag/blob/8e82a4d651bfd0385b8860b013b9452da7b5dcda/n8n/rag_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

Notion Knowledge Base Ai Assistant. Uses lmChatOpenAi, toolHttpRequest, notion, memoryBufferWindow. Chat trigger; 12 nodes.

OpenAI Chat, Tool Http Request, Notion +3
AI & RAG

Integrating AI with Open-Meteo API for Enhanced Weather Forecasting. Uses chatTrigger, lmChatOpenAi, stickyNote, agent. Chat trigger; 12 nodes.

Chat Trigger, OpenAI Chat, Agent +2
AI & RAG

Stickynote Notion. Uses lmChatOpenAi, toolHttpRequest, notion, memoryBufferWindow. Chat trigger; 12 nodes.

OpenAI Chat, Tool Http Request, Notion +3
AI & RAG

This workflow is perfect for teams and individuals who manage extensive data in Notion and need a quick, AI-powered way to interact with their databases. If you're looking to streamline your knowledge

OpenAI Chat, Tool Http Request, Notion +3
AI & RAG

We are using this workflow in our workshops to teach how to use Tools a.k.a functions with artificial intelligence. In this specific case, we will use a generic "AI Agent" node to illustrate that it c

Chat Trigger, OpenAI Chat, Agent +2