AutomationFlowsAI & RAG › AI Chatbot with Google Gemini

AI Chatbot with Google Gemini

Original n8n title: Chat

Chat. Uses chatTrigger, agent, lmChatGoogleGemini, memoryBufferWindow. Chat trigger; 6 nodes.

Chat trigger trigger★★☆☆☆ complexityAI-powered6 nodesChat TriggerAgentGoogle Gemini ChatMemory Buffer WindowTool Workflow
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": "Chat",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "2fabf43f-6e6e-424b-8e93-9150e9ce7d6c",
        "authentication": "headerAuth",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -40,
        -100
      ],
      "id": "d74f0275-ed31-49eb-af44-2ff2bf95571b",
      "name": "Webhook",
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.body.message }}",
        "hasOutputParser": true,
        "options": {
          "systemMessage": "=You are an assistant whose task is to answer questions using only the information retrieved from the Supabase Vector Store.\n\nYour objective is to provide accurate, concise answers based solely on the retrieved chunks.\n\nInstructions:\n1. You MUST call and use the \"Supabase Vector Store\" tool to retrieve relevant chunks based on the user's question.\n2. You MUST base your answer exclusively on the content from the returned chunks.\n3. DO NOT use prior knowledge, assumptions, or memory. Only use what is provided by the vector store.\n4. If the information needed is not found in the retrieved chunks, respond with: \"Sorry, I don't know.\"\n\n"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.9,
      "position": [
        220,
        -180
      ],
      "id": "c905f3d9-51bc-4997-983d-ce73be6912cc",
      "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": [
        340,
        200
      ],
      "id": "01be19ed-3504-463f-9552-b975883dbefd",
      "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": [
        500,
        140
      ],
      "id": "8b967622-2bc1-4bf0-8ff1-d02826c2249d",
      "name": "Supabase Vector Store",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1.2,
      "position": [
        580,
        320
      ],
      "id": "e7eae8b9-3647-4e2b-be7e-6c3f2fc80c7b",
      "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": [
        1020,
        180
      ],
      "id": "5d0dbc4f-50d1-4287-92c8-c917674350c8",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "tableId": "n8n_chat_histories",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "session_id",
              "fieldValue": "={{ $('Webhook').item.json.body.session_id }}"
            },
            {
              "fieldId": "message",
              "fieldValue": "{\"type\": \"ai\", \"content\": \"{\\\"output\\\":[{\\\"text\\\":\\\"Sorry, I encountered an error creating a response. Please check the error log.\\\",\\\"citations\\\":[]}]}\", \"tool_calls\": [], \"additional_kwargs\": {}, \"response_metadata\": {}, \"invalid_tool_calls\": []}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        1120,
        -40
      ],
      "id": "5326f44f-8702-4bfe-8771-c316fcdb3cfd",
      "name": "Supabase",
      "alwaysOutputData": true,
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "## To Do \n- Configure the Supabase nodes to reference your Project",
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        600,
        -500
      ],
      "id": "14b2e53e-f99f-4368-8172-99cd8afa1afb",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "modelName": "models/gemini-2.5-flash-preview-04-17-thinking",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        0,
        200
      ],
      "id": "4a2dc897-d02f-46b8-8c92-71a4af3d486e",
      "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": [
        -160,
        200
      ],
      "id": "fe8982cd-2cc9-407c-a3fd-91bdd3248045",
      "name": "Anthropic Chat Model",
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4",
          "mode": "list",
          "cachedResultName": "gpt-4"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        160,
        200
      ],
      "id": "1797c365-bc21-4de1-9bf1-7a17ff3c0838",
      "name": "OpenAI Chat Model1",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n  item.json.myNewField = 1;\n}\n\nreturn $input.all();"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        880,
        -217.40831862098898
      ],
      "id": "f3501f80-6298-432a-a1d4-206a75193bbc",
      "name": "Code"
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Supabase",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "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
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        []
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "938d390b-0421-4a39-b2dd-253e89f3e953",
  "id": "mrnCkgQsTwcix4Lq",
  "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

Chat. Uses chatTrigger, agent, lmChatGoogleGemini, memoryBufferWindow. Chat trigger; 6 nodes.

Source: https://github.com/neloduka-sobe/ElevenLabs-Hackathon/blob/017ce37fc9b688ab318cef3185298d5c16913bf0/n8n/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

This workflow allows you to integrate the Google Gemini CLI into your n8n AI Agents. It is designed for self-hosted n8n instances and enables you to chat with the Gemini CLI running on your local mach

Chat Trigger, Memory Buffer Window, Google Gemini Chat +4
AI & RAG

This Chatbot automates the process of discovering job openings and generating tailored job application emails.

Chat Trigger, OpenAI Chat, Mcp Client Tool +12
AI & RAG

Job Application PredictLeads & ScrapeGraph AI. Uses chatTrigger, lmChatOpenAi, mcpClientTool, memoryBufferWindow. Chat trigger; 32 nodes.

Chat Trigger, OpenAI Chat, Mcp Client Tool +12
AI & RAG

Job Application PredictLeads & ScrapeGraph AI. Uses chatTrigger, lmChatOpenAi, mcpClientTool, memoryBufferWindow. Chat trigger; 32 nodes.

Chat Trigger, OpenAI Chat, Mcp Client Tool +12
AI & RAG

My Automations. Uses chatTrigger, agent, memoryBufferWindow, toolHttpRequest. Chat trigger; 17 nodes.

Chat Trigger, Agent, Memory Buffer Window +6