AutomationFlowsAI & RAG › AI Chatbot with WhatsApp & Google Drive

AI Chatbot with WhatsApp & Google Drive

Original n8n title: Chatbot

Chatbot. Uses googleDrive, vectorStoreSupabase, googleDriveTrigger, documentDefaultDataLoader. Event-driven trigger; 23 nodes.

Event trigger★★★★☆ complexityAI-powered23 nodesGoogle DriveSupabase Vector StoreGoogle Drive TriggerDocument Default Data LoaderMemory Buffer WindowGoogle Sheets ToolGoogle Calendar ToolOpenAI Embeddings
AI & RAG Trigger: Event Nodes: 23 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow follows the Agent → Documentdefaultdataloader 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": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Mapped Data').item.json.sessionId }}",
        "tableName": "ChatHistory"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "typeVersion": 1.3,
      "position": [
        0,
        208
      ],
      "id": "eb30c4b3-821f-4a3d-bb14-15386f7fa3d8",
      "name": "Postgres Chat Memory",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "endpointUrl": "https://n8n.safehub-lcup.uk/mcp/ai-tools",
        "include": "selected",
        "includeTools": "={{ $('Mapped Data').item.json.tools }}",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.mcpClientTool",
      "typeVersion": 1.2,
      "position": [
        128,
        208
      ],
      "id": "76301d94-aa26-46fe-9560-06215322c1ea",
      "name": "Tools"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "35c11012-cd29-4dbb-a074-6e2edc4e2514",
              "name": "message",
              "value": "={{ ($('Chatbot Webhook').isExecuted && $('Chatbot Webhook').item.json.body.message) || $('When chat message received').item.json.chatInput }}",
              "type": "string"
            },
            {
              "id": "9c98856e-814c-462f-82ac-f91285823d3d",
              "name": "sessionId",
              "value": "={{ ($('Chatbot Webhook').isExecuted && $('Chatbot Webhook').item.json.jwtPayload.sub) || $('When chat message received').item.json.sessionId }}",
              "type": "string"
            },
            {
              "id": "59aed1da-e32f-4bcc-8964-15466a4c5749",
              "name": "tools",
              "value": "={{\n  $('Get Settings').item.json.isMCPOn\n    ? $('Get Settings').item.json.tools.replace(/[{}]/g, \"\").split(\",\")\n        .map(s => s.trim())\n        .concat(\"Calculator\")\n    : [\"Calculator\"]\n}}",
              "type": "array"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -352,
        -32
      ],
      "id": "183107f5-3c3f-4262-8ae3-1409e2a6cb40",
      "name": "Mapped Data"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "typeVersion": 1,
      "position": [
        480,
        64
      ],
      "id": "0a3e2c1d-89b4-40f6-8f7b-6f0893625173",
      "name": "Calculator"
    },
    {
      "parameters": {
        "description": "Searches the web using the provided query, retrieves the top five results, crawls each page for relevant content. Use SearchResults tool after using this.",
        "workflowId": {
          "__rl": true,
          "value": "hvhjYmXy8JA7r4j2",
          "mode": "list",
          "cachedResultUrl": "/workflow/hvhjYmXy8JA7r4j2",
          "cachedResultName": "Search and Crawl"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {
            "query": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('query', ``, 'string') }}",
            "key_words": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('key_words', `This must be a text separated with spaces if your query is for example current weather in the philippines the keywords must be \"weather philippines\"`, 'string') }}"
          },
          "matchingColumns": [
            "query"
          ],
          "schema": [
            {
              "id": "query",
              "displayName": "query",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string",
              "removed": false
            },
            {
              "id": "key_words",
              "displayName": "key_words",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string",
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2.2,
      "position": [
        592,
        64
      ],
      "id": "2b19cbe6-77b5-4bdf-8452-a67f7efec52d",
      "name": "WebSearch"
    },
    {
      "parameters": {
        "path": "ai-tools"
      },
      "type": "@n8n/n8n-nodes-langchain.mcpTrigger",
      "typeVersion": 2,
      "position": [
        784,
        -160
      ],
      "id": "7556f6c1-350b-4bc4-99de-68116d913f86",
      "name": "Safehub Tools",
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "model": "nomic-embed-text:v1.5"
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOllama",
      "typeVersion": 1,
      "position": [
        1184,
        336
      ],
      "id": "d1d057b3-688c-4ac7-b516-e8d5f512f020",
      "name": "Ollama Embedding1",
      "credentials": {
        "ollamaApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -144,
        208
      ],
      "id": "01460796-2624-4033-8591-88f389c89bce",
      "name": "Google Gemini Chat Model",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "safehub",
        "authentication": "jwtAuth",
        "responseMode": "streaming",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        -992,
        -32
      ],
      "id": "7fff13bc-03e9-4b5a-85b7-98bbe0f22e83",
      "name": "Chatbot Webhook",
      "credentials": {
        "jwtAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.3,
      "position": [
        -992,
        112
      ],
      "id": "2cd5cbe2-b7b3-46d3-adc8-19929e8dc175",
      "name": "When chat message received"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('Mapped Data').item.json.message }}",
        "options": {
          "systemMessage": "={{ $('Get Preset').item.json.prompt }}\n\n---\n\n## Primary Goals\n\n{{ $('Get Preset').item.json.tasks }}\n\n---\n\n## Available Tools\n\nYou are only allowed to use tools that are explicitly listed below.  \nDo **not** use or mention any other tools not included here.\n\n**Available Tools:**\n{{ $('Mapped Data').item.json.tools.map(item => \"- \" + item).join(\"\\n\") }}\n\nIf a user requests something that requires a tool not listed here, respond with:\n> \"Sorry, I don\u2019t have access to that tool right now.\"\n\nAlways follow this rule strictly.\n\n## Tool Usage Rules & Fallback Logic\n\nThe SafeHub AI Assistant should use tools **strategically and hierarchically**.  \nIf one tool fails, the assistant will check others based on context.\n\n---\n\n### 1. General Multi-Tool Rule\n\nIf a user requests multiple types of data (e.g., \u201cshow recent events and give hotline numbers\u201d),  \n\u2192 Call **each relevant tool separately** (e.g., `GetPosts` + `GetHotlines`).  \nDo **not** skip any requested tool.\n\n---\n\n### \ud83d\udcda 2. When to Use Each Tool\n\n| Scenario | Primary Tool | Fallback 1 | Fallback 2 |\n|-----------|---------------|-------------|-------------|\n| **Campus announcements, articles, or tips** | GetPosts | WebSearch | QueryVault |\n| **Events, internal policies, guidelines, documents** | QueryVault | GetPosts | WebSearch |\n| **External, factual, or trending info** | WebSearch | GetPosts | QueryVault |\n| **Emergency help or support numbers** | GetHotlines | (none \u2013 always use) | \u2014 |\n| **Calculations or logical reasoning** | Calculator | \u2014 | \u2014 |\n\n---\n\n### 3. Success Checking Logic\n\nAfter each tool call:\n\n- If the tool returns **clear and relevant** results \u2192 Use them in your answer.  \n- If the tool returns **empty or irrelevant** output \u2192  \n  \u2192 Automatically **fallback** to the next tool in its hierarchy (see table above).  \n- If **all tools fail**, respond compassionately:  \n  > \u201cI couldn\u2019t find specific information on that right now, but I can share some general guidance.\u201d\n\n---\n\n### \ud83d\udca1 4. Context Priority\n\nIf both **WebSearch** and **QueryVault** could apply, **prefer QueryVault** for:\n- Campus events  \n- Uploaded guidelines  \n- Internal documents  \n- School programs or policies  \n\nUse **WebSearch** only if the question refers to something outside SafeHub or the school environment.\n\n---\n\n## General Behavior\n\n{{ $('Get Preset').item.json.rules }}\n{{ $('Get Preset').item.json.limits }}\n\n---\n\n",
          "enableStreaming": true
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3,
      "position": [
        -96,
        -32
      ],
      "id": "765fd691-c99e-4771-990e-c04265f1e306",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "operation": "select",
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "table": {
          "__rl": true,
          "value": "AiSettings",
          "mode": "list",
          "cachedResultName": "AiSettings"
        },
        "limit": 1,
        "where": {
          "values": [
            {
              "column": "id",
              "value": "1"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.6,
      "position": [
        -784,
        -32
      ],
      "id": "379bbabb-b29e-4eaf-bd19-ff092a1f69f3",
      "name": "Get Settings",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "select",
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "table": {
          "__rl": true,
          "value": "AiPreset",
          "mode": "list",
          "cachedResultName": "AiPreset"
        },
        "limit": 1,
        "where": {
          "values": [
            {
              "column": "id",
              "value": "={{ $json.presetId }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.6,
      "position": [
        -560,
        -32
      ],
      "id": "d4f25c5c-e0a5-4df3-b007-88e96f9cd925",
      "name": "Get Preset",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "descriptionType": "manual",
        "toolDescription": "Use this tool to retrieve announcements, articles, tips, wellness resources, or updates from SafeHub\u2019s websites when the user is asking for information hosted on the platform.",
        "operation": "select",
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "table": {
          "__rl": true,
          "value": "Post",
          "mode": "list",
          "cachedResultName": "Post"
        },
        "returnAll": true,
        "options": {}
      },
      "type": "n8n-nodes-base.postgresTool",
      "typeVersion": 2.6,
      "position": [
        768,
        128
      ],
      "id": "c242ca67-8990-4813-8d30-08e7379bfd0c",
      "name": "GetPosts",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "descriptionType": "manual",
        "toolDescription": "Use this tool to fetch hotline contact details from SafeHub\u2019s websites when the user needs emergency support, crisis helplines, or counseling contact information.",
        "operation": "select",
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "table": {
          "__rl": true,
          "value": "Hotline",
          "mode": "list",
          "cachedResultName": "Hotline"
        },
        "returnAll": true,
        "options": {}
      },
      "type": "n8n-nodes-base.postgresTool",
      "typeVersion": 2.6,
      "position": [
        864,
        128
      ],
      "id": "c9336c3a-14b0-4609-8bdc-ab591863e2a3",
      "name": "GetHotlines",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "mode": "retrieve-as-tool",
        "toolDescription": "Use this knowledge base to answer questions from the user",
        "tableName": "documents",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStorePGVector",
      "typeVersion": 1.3,
      "position": [
        1168,
        112
      ],
      "id": "aa60104c-b79b-4f6d-a656-f97ff86aff42",
      "name": "QueryVault",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Tools": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Mapped Data": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculator": {
      "ai_tool": [
        [
          {
            "node": "Safehub Tools",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "WebSearch": {
      "ai_tool": [
        [
          {
            "node": "Safehub Tools",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Ollama Embedding1": {
      "ai_embedding": [
        [
          {
            "node": "QueryVault",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Chatbot Webhook": {
      "main": [
        [
          {
            "node": "Get Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Get Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        []
      ]
    },
    "Get Settings": {
      "main": [
        [
          {
            "node": "Get Preset",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Preset": {
      "main": [
        [
          {
            "node": "Mapped Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GetPosts": {
      "ai_tool": [
        [
          {
            "node": "Safehub Tools",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "GetHotlines": {
      "ai_tool": [
        [
          {
            "node": "Safehub Tools",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "QueryVault": {
      "ai_tool": [
        [
          {
            "node": "Safehub Tools",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "meta": {
    "templateCredsSetupCompleted": true
  }
}

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

How this works

This chatbot workflow delivers instant, intelligent responses to customer queries via WhatsApp, saving time for support teams handling repetitive questions. It suits small businesses or solo entrepreneurs seeking an automated assistant without building from scratch, leveraging integrations like Google Drive for document storage and Google Gemini for natural language processing. The key step involves an AI agent that retrieves relevant information from a Supabase vector store to generate context-aware replies, ensuring conversations feel personalised and efficient.

Use this workflow when you need a simple, event-driven chatbot for WhatsApp interactions, such as answering FAQs from uploaded documents in Google Drive. Avoid it for complex, multi-channel support requiring custom logic or high-volume enterprise needs, where dedicated platforms might be better. Common variations include swapping WhatsApp for Telegram triggers or adding Google Sheets for logging interactions to track query patterns.

About this workflow

Chatbot. Uses googleDrive, vectorStoreSupabase, googleDriveTrigger, documentDefaultDataLoader. Event-driven trigger; 23 nodes.

Source: https://github.com/ChibugoOhanyiri/AI-automation-portfolio/blob/main/ai_agent_chatbot/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

A lightweight, self-hosted AI assistant built entirely in n8n. Multi-channel messaging (Telegram, WhatsApp, Gmail), persistent memory, task management, and autonomous work — all in a single visual wor

Telegram Trigger, OpenRouter Chat, Data Table +20
AI & RAG

This workflow implements an advanced AI automation agent (OpenClaw Agent) that interacts with users through Telegram and integrates multiple AI models, external tools, and cloud services to automate c

Telegram Trigger, Telegram, OpenAI +21
AI & RAG

📌 Overview

Redis, WhatsApp, OpenAI Chat +12
AI & RAG

Alfred (funcional). Uses gmailTool, googleCalendarTool, gmail, embeddingsOpenAi. Event-driven trigger; 83 nodes.

Gmail Tool, Google Calendar Tool, Gmail +24
AI & RAG

Your AI workforce is ready. Are you?

Google Sheets Tool, Mcp Trigger, Google Drive +29