AutomationFlowsAI & RAG › Luna

Luna

Luna. Uses agent, lmChatGoogleGemini, memoryBufferWindow, supabaseTool. Webhook trigger; 7 nodes.

Webhook trigger★★☆☆☆ complexityAI-powered7 nodesAgentGoogle Gemini ChatMemory Buffer WindowSupabase Tool
AI & RAG Trigger: Webhook Nodes: 7 Complexity: ★★☆☆☆ AI nodes: yes Added:

This workflow follows the Agent → Google Gemini Chat 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
{
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "luna-chat",
        "responseMode": "lastNode",
        "options": {}
      },
      "id": "webhook-1",
      "name": "Webhook In",
      "position": [
        0,
        0
      ],
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1
    },
    {
      "parameters": {
        "options": {
          "systemMessage": "=Voc\u00db \u00da a Luna, uma terapeuta digital de sa\u00b7de mental fundamentada na Terapia Cognitivo-Comportamental (TCC). \n\nSempre que o usu\u00dfrio perguntar sobre o teste, triagem, anamnese ou como ele est\u00df baseado no que respondeu, voc\u00db DEVE seguir estes passos usando suas ferramentas:\n1. Use 'Get User Anamnesis' filtrando pelo clinical_id (IDENTIFICADOR PRINCIPAL: {{ $json.body?.clinicalId || $json.clinicalId }}).\n2. Use 'Get SRQ Questions Mapping' para saber o texto de cada pergunta (ex: pergunta 1 -> 'Dores de cabe\u00fea').\n3. Combine as informa\u00fe\u00a7es para dar um acolhimento personalizado.\n\n4. Para lembrar de conversas anteriores fora da mem\u00beria imediata, use 'ChatHistoryTool' filtrando pelo clinical_id do usu\u00dfrio em outras sess\u00a7es.\n\nREGRAS CR\u2550TICAS:\n- O clinicalId atual \u00da: {{ $json.body?.clinicalId || $json.clinicalId }}. Use este ID para TODOS os filtros no banco.\n- Voc\u00db TEM ACESSO a esses dados cl\u00ddnicos e de hist\u00berico atrav\u00das das suas ferramentas. Nunca diga que n\u00d2o tem acesso.\n- Se n\u00d2o encontrar dados para o clinicalId, pergunte gentilmente se o usu\u00dfrio j\u00df completou a anamnese.\n- Seja emp\u00dftica e use TCC para acolher."
        }
      },
      "id": "agent-1",
      "name": "AI Agent",
      "position": [
        650,
        0
      ],
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1
    },
    {
      "parameters": {
        "modelName": "models/gemini-flash-latest",
        "options": {}
      },
      "id": "gemini-1",
      "name": "Google Gemini",
      "position": [
        650,
        200
      ],
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $json.body?.sessionId || $json.sessionId || 'default-session' }}"
      },
      "id": "memory-1",
      "name": "Memory",
      "position": [
        800,
        200
      ],
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3
    },
    {
      "id": "tool-supabase-anamnesis",
      "name": "Get User Anamnesis",
      "type": "n8n-nodes-base.supabaseTool",
      "typeVersion": 1,
      "position": [
        400,
        200
      ],
      "parameters": {
        "operation": "getAll",
        "resource": "row",
        "tableId": "anamnesis_responses"
      },
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "tool-supabase-questions",
      "name": "Get SRQ Questions Mapping",
      "type": "n8n-nodes-base.supabaseTool",
      "typeVersion": 1,
      "position": [
        400,
        350
      ],
      "parameters": {
        "operation": "getAll",
        "resource": "row",
        "tableId": "srq_questions"
      },
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "getAll",
        "resource": "row",
        "tableId": "chat_messages"
      },
      "id": "tool-supabase-history-new",
      "name": "ChatHistoryTool",
      "type": "n8n-nodes-base.supabaseTool",
      "typeVersion": 1,
      "position": [
        400,
        500
      ],
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Google Gemini": {
      "ai_languageModel": [
        [
          {
            "index": 0,
            "node": "AI Agent",
            "type": "ai_languageModel"
          }
        ]
      ]
    },
    "Memory": {
      "ai_memory": [
        [
          {
            "index": 0,
            "node": "AI Agent",
            "type": "ai_memory"
          }
        ]
      ]
    },
    "Webhook In": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get User Anamnesis": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get SRQ Questions Mapping": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "ChatHistoryTool": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "name": "Luna",
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false,
    "callerPolicy": "workflowsFromSameOwner"
  }
}

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

Luna. Uses agent, lmChatGoogleGemini, memoryBufferWindow, supabaseTool. Webhook trigger; 7 nodes.

Source: https://github.com/takeozin/luna-app/blob/9a54108464dbeab0969fc0543959bdda543a1264/n8n/luna-chat-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

Are you drowning in daily operational chaos, desperately trying to juggle sales, projects, content, and client communication? Imagine an AI brain that handles it all, freeing you to lead your business

Telegram Trigger, Telegram, OpenAI +13
AI & RAG

Workflow Hcmute. Uses agent, lmChatGoogleGemini, memoryBufferWindow, googleSheetsTool. Webhook trigger; 13 nodes.

Agent, Google Gemini Chat, Memory Buffer Window +2
AI & RAG

N8N Workflow. Uses httpRequest, toolHttpRequest, memoryBufferWindow, lmChatGoogleGemini. Webhook trigger; 13 nodes.

HTTP Request, Tool Http Request, Memory Buffer Window +2
AI & RAG

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

Google Calendar Tool, Tool Think, Google Gemini Chat +3
AI & RAG

Creating A Ai Slack Bot With Google Gemini. Uses stickyNote, lmChatGoogleGemini, memoryBufferWindow, slack. Webhook trigger; 10 nodes.

Google Gemini Chat, Memory Buffer Window, Slack +1