AutomationFlowsAI & RAG › Run Self-hosted AI Assistant with Claude, Gemini & Gmail

Run Self-hosted AI Assistant with Claude, Gemini & Gmail

Original n8n title: Run a Self-hosted Multi-channel AI Assistant with Claude, Gemini and Gmail

ByShabbir Noor @shabbirun on n8n.io

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 workflow.

Event trigger★★★★★ complexityAI-powered87 nodesTelegram TriggerOpenRouter ChatData TableTelegramAgentData Table ToolMemory Postgres ChatPostgres
AI & RAG Trigger: Event Nodes: 87 Complexity: ★★★★★ AI nodes: yes Added:

This workflow corresponds to n8n.io template #13717 — we link there as the canonical source.

This workflow follows the Agent → Agenttool 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": [
    {
      "id": "c842b3a1-106f-4754-be44-1639aa2ca093",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        128,
        1472
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "0dca07cb-6961-4001-8738-e954dfd20ef1",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        2160,
        1504
      ],
      "parameters": {
        "model": "anthropic/claude-sonnet-4.5",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "58e26956-007d-46d3-b253-c1cd7a104206",
      "name": "Get row(s)",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        1760,
        1536
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "username",
              "keyValue": "YOUR_USERNAME"
            }
          ]
        },
        "operation": "get",
        "returnAll": true,
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_INIT_TABLE_ID",
          "cachedResultUrl": "/projects/YOUR_PROJECT_ID/datatables/YOUR_INIT_TABLE_ID",
          "cachedResultName": "ClawdBot Init"
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "10c194f5-355e-405b-ade2-1d9b569fca1a",
      "name": "Filter",
      "type": "n8n-nodes-base.filter",
      "position": [
        336,
        1472
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "b1b370a8-b981-43ab-b1b0-88853bad298b",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $json.message.chat.id }}",
              "rightValue": "={{ $if($('Telegram Trigger').isExecuted, $('Telegram Trigger').item.json.message.chat.id, YOUR_TELEGRAM_CHAT_ID) }}"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3
    },
    {
      "id": "3c2db2c9-b01d-40da-ad8d-99d5af55a0e2",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        1936,
        1136
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ac8d70f0-59ba-4381-942d-18f7401a4705",
              "name": "user_message",
              "type": "string",
              "value": "={{ $if($('Transcribe a recording').isExecuted, $('Transcribe a recording').item.json.content.parts[0].text, $if($('Analyze document').isExecuted, $('Analyze document').item.json.content.parts[0].text, $if($('Analyze an image').isExecuted, $('Analyze an image').item.json.content.parts[0].text, $('Filter').item.json.message.text))) }}"
            },
            {
              "id": "4ebb8355-2aa2-4af2-8f82-a8c5bc57e0c9",
              "name": "system_prompt_details",
              "type": "string",
              "value": "=username: {{ $json.username || \"[COLLECT and use database tool to upsert] Field: username | Prompt: Ask the user to choose a username. This will be their unique identifier. | Rules: Save exactly as provided, no modifications. | Example: 'shabbir', 'nova_builder'\" }}\nsoul: {{ $json.soul || \"[COLLECT and use database tool to upsert] Field: soul | Prompt: Ask the user to define your soul - give you a name, a vibe, and a general purpose. | Rules: Combine all three elements (name, vibe, purpose) into a single concise description. | Example: 'Nova - warm and curious - helps brainstorm creative projects'\" }}\nuser: {{ $json.user || \"[COLLECT and use database tool to upsert] Field: user | Prompt: Ask the user to tell you about themselves - anything they want you to remember. | Rules: Consolidate their response into a structured profile. Include interests, goals, preferences, and any relevant context. | Example: 'AI automation consultant, prefers direct communication, focused on scaling content workflows'\" }}"
            },
            {
              "id": "f1d7c2a0-d580-4e7a-bc8b-29e1102c03bb",
              "name": "last_channel",
              "type": "string",
              "value": "=telegram"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "fe8ac8fa-48a3-4b28-af31-42f4f99cb2fe",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        3392,
        832
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Telegram",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "39d05258-72cc-4266-86f1-8b2ae9fccd53",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $if($('Edit Fields').isExecuted, $('Edit Fields').item.json.last_channel, $if($('Edit Fields1').isExecuted, $('Edit Fields1').item.json.last_channel, $if($('Edit Fields2').isExecuted, $('Edit Fields2').item.json.last_channel, $('Edit Fields3').item.json.last_channel))) }}",
                    "rightValue": "telegram"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "whatsapp",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "10be5dff-f0cc-496b-aff2-225f66654597",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $if($('Edit Fields').isExecuted, $('Edit Fields').item.json.last_channel, $if($('Edit Fields1').isExecuted, $('Edit Fields1').item.json.last_channel, $if($('Edit Fields2').isExecuted, $('Edit Fields2').item.json.last_channel, $('Edit Fields3').item.json.last_channel))) }}",
                    "rightValue": "whatsapp"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.4
    },
    {
      "id": "0f743b24-166b-47bd-9df7-ff6912a4f056",
      "name": "Send a text message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3680,
        640
      ],
      "parameters": {
        "text": "={{ $('n8nClaw').item.json.output }}",
        "chatId": "={{ $if($('Telegram Trigger').isExecuted, $('Telegram Trigger').item.json.message.chat.id, YOUR_TELEGRAM_CHAT_ID) }}",
        "additionalFields": {
          "parse_mode": "Markdown"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "ed2e7e8f-5a41-4f22-b6e4-dc449be7b32b",
      "name": "n8nClaw",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        3088,
        1232
      ],
      "parameters": {
        "text": "={{ $json.user_message }}",
        "options": {
          "systemMessage": "=You are n8nClaw, an advanced, proactive AI assistant with access to advanced tools. Your functionality is according to the below details.\n\n{{ $json.system_prompt_details }}\n\nThe User field is a living document. Any new and important information that you receive related to the user - that is worth remembering to be useful in future conversations - is to be added there using the update info tool. Any recurring tasks the user expects you to do (manage calendar, etc - should also go into the user field)\n\nYou also have access to read, create, and update tasks and subtasks through two data tables - one for tasks and one for subtasks.\n\nAnything the user asks you to do must be logged to the tasks and subtasks tables. You can then work on those tasks and subtasks, and update them with lots of detail - as necessary.\n\nTask and subtask details should be upserted with any info required. For example, if you completed a task/subtask partially, update the details with whatever you've already done so you can pick up from there in the next iteration.\n\nAdditionally, As you work on a task/subtask, it may require additional tasks/subtasks to be created - do so if needed, adding all relevant details.\n\nOnce a task or subtask is done, mark task_completed or subtask_completed as true. An entire task can only be completed once ALL subtasks are complete.\n\nYou should always search for tasks first, and then search for the subtasks by the task ID, and plan your work accordingly.\n\nIf you require more context about the user or about previous conversations, you can use query the vector store tool(it is trained on past conversations) to pull the relevant information and continue working.\n\nEMAIL\nYou have access to an AI agent tool that manages your gmail inbox. You can use it to read, reply, delete, get, and search for messages. To take any actions on existing messages, you will need to use the google api-friendly message ID (if you received an email directly).\n\nDOING WORK\nYou have access to a research agent to get any information on anything.\n\nYou also have access to multiple worker agents to break tasks up into parts and do more work concurrently. You MUST use these agents.\n\nYou also have access to a document agent for saving work. The document agent is ONLY to receive completed work for saving. You are NOT to send it instructions for what output to produce. this agent has access to google docs create, update, and drive tools. Save the Google Drive URLs to the task info for persistence.\n\n"
        },
        "promptType": "define"
      },
      "typeVersion": 3
    },
    {
      "id": "c483a186-2cdc-4e70-81a8-0893d52de8ab",
      "name": "Get Tasks",
      "type": "n8n-nodes-base.dataTableTool",
      "position": [
        4016,
        1216
      ],
      "parameters": {
        "operation": "get",
        "returnAll": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Return_All', ``, 'boolean') }}",
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_TASKS_TABLE_ID",
          "cachedResultUrl": "/projects/YOUR_PROJECT_ID/datatables/YOUR_TASKS_TABLE_ID",
          "cachedResultName": "ClawdBot Tasks"
        },
        "descriptionType": "manual",
        "toolDescription": "Get pending or completed tasks"
      },
      "typeVersion": 1
    },
    {
      "id": "f4ee32da-6163-4925-a4c0-b84a2c776824",
      "name": "Get Subtasks",
      "type": "n8n-nodes-base.dataTableTool",
      "position": [
        3888,
        1216
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "parent_task_id",
              "keyValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('conditions0_Value', ``, 'string') }}"
            }
          ]
        },
        "operation": "get",
        "returnAll": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Return_All', ``, 'boolean') }}",
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_SUBTASKS_TABLE_ID",
          "cachedResultUrl": "/projects/YOUR_PROJECT_ID/datatables/YOUR_SUBTASKS_TABLE_ID",
          "cachedResultName": "ClawdBot Subtasks"
        },
        "descriptionType": "manual",
        "toolDescription": "Get pending or completed subtasks"
      },
      "typeVersion": 1
    },
    {
      "id": "c9dfc3dc-2bb3-4b1a-b34e-a15d3f8eb037",
      "name": "Upsert Subtask",
      "type": "n8n-nodes-base.dataTableTool",
      "position": [
        3760,
        1216
      ],
      "parameters": {
        "columns": {
          "value": {
            "subtask_name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('subtask_name', ``, 'string') }}",
            "parent_task_id": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parent_task_id', ``, 'string') }}",
            "subtask_details": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('subtask_details', ``, 'string') }}",
            "subtask_complete": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('subtask_complete', ``, 'boolean') }}"
          },
          "schema": [
            {
              "id": "parent_task_id",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "parent_task_id",
              "defaultMatch": false
            },
            {
              "id": "subtask_name",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "subtask_name",
              "defaultMatch": false
            },
            {
              "id": "subtask_details",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "subtask_details",
              "defaultMatch": false
            },
            {
              "id": "subtask_complete",
              "type": "boolean",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "subtask_complete",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "filters": {
          "conditions": [
            {
              "keyName": "parent_task_id",
              "keyValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('conditions0_Value', ``, 'string') }}"
            }
          ]
        },
        "options": {},
        "operation": "upsert",
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_SUBTASKS_TABLE_ID",
          "cachedResultUrl": "/projects/YOUR_PROJECT_ID/datatables/YOUR_SUBTASKS_TABLE_ID",
          "cachedResultName": "ClawdBot Subtasks"
        },
        "descriptionType": "manual",
        "toolDescription": "Upsert Subtask"
      },
      "typeVersion": 1
    },
    {
      "id": "a989b000-afca-450f-b068-e19d38be6ecb",
      "name": "Upsert Task",
      "type": "n8n-nodes-base.dataTableTool",
      "position": [
        3616,
        1216
      ],
      "parameters": {
        "columns": {
          "value": {
            "task_name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('task_name', ``, 'string') }}",
            "Is_recurring": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Is_recurring', ``, 'boolean') }}",
            "task_details": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('task_details', ``, 'string') }}",
            "task_complete": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('task_complete', ``, 'boolean') }}"
          },
          "schema": [
            {
              "id": "task_name",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "task_name",
              "defaultMatch": false
            },
            {
              "id": "task_details",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "task_details",
              "defaultMatch": false
            },
            {
              "id": "task_complete",
              "type": "boolean",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "task_complete",
              "defaultMatch": false
            },
            {
              "id": "Is_recurring",
              "type": "boolean",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Is_recurring",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "filters": {
          "conditions": [
            {
              "keyName": "task_name",
              "keyValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('conditions0_Value', ``, 'string') }}"
            }
          ]
        },
        "options": {},
        "operation": "upsert",
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_TASKS_TABLE_ID",
          "cachedResultUrl": "/projects/YOUR_PROJECT_ID/datatables/YOUR_TASKS_TABLE_ID",
          "cachedResultName": "ClawdBot Tasks"
        },
        "descriptionType": "manual",
        "toolDescription": "Upsert task"
      },
      "typeVersion": 1
    },
    {
      "id": "6976bb1b-7f9f-4624-8a9a-ddceddda7db6",
      "name": "Initialization - Update Info",
      "type": "n8n-nodes-base.dataTableTool",
      "position": [
        4144,
        1216
      ],
      "parameters": {
        "columns": {
          "value": {
            "soul": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('soul', ``, 'string') }}",
            "user": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('user', ``, 'string') }}",
            "username": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('username', `the \"username\" provided by the user as the first answer.`, 'string') }}",
            "heartbeat": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('heartbeat', ``, 'string') }}",
            "last_channel": "={{ $json.last_channel }}"
          },
          "schema": [
            {
              "id": "username",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "username",
              "defaultMatch": false
            },
            {
              "id": "soul",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "soul",
              "defaultMatch": false
            },
            {
              "id": "user",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "user",
              "defaultMatch": false
            },
            {
              "id": "heartbeat",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "heartbeat",
              "defaultMatch": false
            },
            {
              "id": "last_channel",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "last_channel",
              "defaultMatch": false
            },
            {
              "id": "last_vector_id",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "last_vector_id",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "filters": {
          "conditions": [
            {
              "keyName": "username",
              "keyValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('conditions0_Value', ``, 'string') }}"
            }
          ]
        },
        "options": {},
        "operation": "upsert",
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_INIT_TABLE_ID",
          "cachedResultUrl": "/projects/YOUR_PROJECT_ID/datatables/YOUR_INIT_TABLE_ID",
          "cachedResultName": "ClawdBot Init"
        },
        "descriptionType": "manual",
        "toolDescription": "Initialize first usage"
      },
      "typeVersion": 1
    },
    {
      "id": "7aeb2c4e-b40c-4802-a471-5f8af8d4dddc",
      "name": "Postgres Chat Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "position": [
        2304,
        1504
      ],
      "parameters": {
        "sessionKey": "YOUR_USERNAME",
        "sessionIdType": "customKey",
        "contextWindowLength": 15
      },
      "typeVersion": 1.3
    },
    {
      "id": "3a5344cf-8ac9-43e9-83d5-c79bdec4b542",
      "name": "Execute a SQL query",
      "type": "n8n-nodes-base.postgres",
      "position": [
        2448,
        2640
      ],
      "parameters": {
        "query": "SELECT session_id, message, id\nFROM n8n_chat_histories \nWHERE id > '{{ $json.last_vector_id }}'\nORDER BY id ASC\n",
        "options": {},
        "operation": "executeQuery"
      },
      "typeVersion": 2.6
    },
    {
      "id": "009e03b7-35ce-4ad2-b241-e9bcc2e3a837",
      "name": "Get row(s)1",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        2256,
        2640
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "username",
              "keyValue": "YOUR_USERNAME"
            }
          ]
        },
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_INIT_TABLE_ID",
          "cachedResultUrl": "/projects/YOUR_PROJECT_ID/datatables/YOUR_INIT_TABLE_ID",
          "cachedResultName": "ClawdBot Init"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "11e4281a-382a-4edb-827c-79729639bd71",
      "name": "Supabase Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        3296,
        2640
      ],
      "parameters": {
        "mode": "insert",
        "options": {
          "queryName": "match_documents"
        },
        "tableName": {
          "__rl": true,
          "mode": "list",
          "value": "documents",
          "cachedResultName": "documents"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "0acd04e6-c1a1-45e0-8b76-7bdbc4fb26a5",
      "name": "Embeddings OpenAI",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        3344,
        2848
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "50cd8966-ae8d-4672-bc33-25287125525f",
      "name": "Default Data Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        3536,
        2848
      ],
      "parameters": {
        "options": {},
        "jsonData": "={{ $json.output.summary }}",
        "jsonMode": "expressionData"
      },
      "typeVersion": 1.1
    },
    {
      "id": "31c85898-a155-4d75-91c5-3bf9010b0667",
      "name": "Update row(s)",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        3664,
        2640
      ],
      "parameters": {
        "columns": {
          "value": {
            "last_vector_id": "={{ $('Execute a SQL query').last().json.id }}"
          },
          "schema": [
            {
              "id": "username",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "username",
              "defaultMatch": false
            },
            {
              "id": "soul",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "soul",
              "defaultMatch": false
            },
            {
              "id": "user",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "user",
              "defaultMatch": false
            },
            {
              "id": "heartbeat",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "heartbeat",
              "defaultMatch": false
            },
            {
              "id": "last_channel",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "last_channel",
              "defaultMatch": false
            },
            {
              "id": "last_vector_id",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "last_vector_id",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "filters": {
          "conditions": [
            {
              "keyName": "username",
              "keyValue": "YOUR_USERNAME"
            }
          ]
        },
        "options": {},
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_INIT_TABLE_ID",
          "cachedResultUrl": "/projects/YOUR_PROJECT_ID/datatables/YOUR_INIT_TABLE_ID",
          "cachedResultName": "ClawdBot Init"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6b919529-cccf-4905-9276-2c9b27c859c2",
      "name": "Supabase Vector Store1",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        2464,
        1504
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "options": {},
        "tableName": {
          "__rl": true,
          "mode": "list",
          "value": "documents",
          "cachedResultName": "documents"
        },
        "toolDescription": "get info about the user as needed"
      },
      "typeVersion": 1.3
    },
    {
      "id": "b27f5430-9f0b-4179-a515-67f12d28850e",
      "name": "Embeddings OpenAI1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        2592,
        1664
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "649bd16c-a195-44d4-bb6c-b578eb94cd76",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        112,
        928
      ],
      "parameters": {
        "path": "YOUR_WEBHOOK_PATH",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2.1
    },
    {
      "id": "d909173b-1ac9-4d19-9e6f-21b9750c44b0",
      "name": "Get row(s)2",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        528,
        928
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "username",
              "keyValue": "YOUR_USERNAME"
            }
          ]
        },
        "operation": "get",
        "returnAll": true,
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_INIT_TABLE_ID",
          "cachedResultUrl": "/projects/YOUR_PROJECT_ID/datatables/YOUR_INIT_TABLE_ID",
          "cachedResultName": "ClawdBot Init"
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "5b0f22da-403f-4ba5-9601-10194905121f",
      "name": "Filter1",
      "type": "n8n-nodes-base.filter",
      "position": [
        320,
        928
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "b1b370a8-b981-43ab-b1b0-88853bad298b",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.body.data.key.remoteJid }}",
              "rightValue": "=YOUR_PHONE@s.whatsapp.net"
            },
            {
              "id": "4f0a49e8-7a0b-4bcf-8c4c-929d0596e309",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              },
              "leftValue": "={{ $json.body.data.key.fromMe }}",
              "rightValue": false
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3
    },
    {
      "id": "4a8427cc-2d55-4cbb-904e-88f801b92244",
      "name": "Edit Fields1",
      "type": "n8n-nodes-base.set",
      "position": [
        1936,
        928
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ac8d70f0-59ba-4381-942d-18f7401a4705",
              "name": "user_message",
              "type": "string",
              "value": "={{ $('Filter1').item.json.body.data.message.conversation }}"
            },
            {
              "id": "4ebb8355-2aa2-4af2-8f82-a8c5bc57e0c9",
              "name": "system_prompt_details",
              "type": "string",
              "value": "=username: {{ $json.username || \"[COLLECT and use database tool to upsert] Field: username | Prompt: Ask the user to choose a username. This will be their unique identifier. | Rules: Save exactly as provided, no modifications. | Example: 'shabbir', 'nova_builder'\" }}\nsoul: {{ $json.soul || \"[COLLECT and use database tool to upsert] Field: soul | Prompt: Ask the user to define your soul - give you a name, a vibe, and a general purpose. | Rules: Combine all three elements (name, vibe, purpose) into a single concise description. | Example: 'Nova - warm and curious - helps brainstorm creative projects'\" }}\nuser: {{ $json.user || \"[COLLECT and use database tool to upsert] Field: user | Prompt: Ask the user to tell you about themselves - anything they want you to remember. | Rules: Consolidate their response into a structured profile. Include interests, goals, preferences, and any relevant context. | Example: 'AI automation consultant, prefers direct communication, focused on scaling content workflows'\" }}"
            },
            {
              "id": "f1d7c2a0-d580-4e7a-bc8b-29e1102c03bb",
              "name": "last_channel",
              "type": "string",
              "value": "=whatsapp"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "37334f00-a871-419b-ad10-e6cbed1b4ab9",
      "name": "Enviar texto",
      "type": "n8n-nodes-evolution-api.evolutionApi",
      "position": [
        3680,
        816
      ],
      "parameters": {
        "resource": "messages-api",
        "remoteJid": "={{ $if($('Filter1').isExecuted, $('Filter1').item.json.body.data.key.remoteJid, 'YOUR_PHONE@s.whatsapp.net') }}",
        "messageText": "={{ $('n8nClaw').item.json.output }}",
        "instanceName": "YOUR_EVOLUTION_INSTANCE",
        "options_message": {}
      },
      "typeVersion": 1
    },
    {
      "id": "cc6ab49b-a741-4fd3-9789-8cfff6eb681d",
      "name": "OpenRouter Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        2720,
        1712
      ],
      "parameters": {
        "model": "google/gemini-3-flash-preview",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "732d9d3a-1e69-40e0-85d3-881ec08d58c9",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        2864,
        1712
      ],
      "parameters": {
        "sessionKey": "YOUR_USERNAME-research",
        "sessionIdType": "customKey",
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "9adbbdc1-58cf-4e20-9de8-76d70147a71c",
      "name": "Search in Tavily",
      "type": "@tavily/n8n-nodes-tavily.tavilyTool",
      "position": [
        3120,
        1712
      ],
      "parameters": {
        "query": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Query', ``, 'string') }}",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "56b1a92a-19a0-4581-b22e-e22bcd4fe025",
      "name": "Wikipedia",
      "type": "@n8n/n8n-nodes-langchain.toolWikipedia",
      "position": [
        2992,
        1712
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "4b421dc6-f916-44e1-93f4-b848e3144e17",
      "name": "Hourly heartbeat",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        112,
        752
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours"
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "f394841d-a09c-465b-b196-404cf8560812",
      "name": "Get row(s)3",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        528,
        752
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "username",
              "keyValue": "YOUR_USERNAME"
            }
          ]
        },
        "operation": "get",
        "returnAll": true,
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_INIT_TABLE_ID",
          "cachedResultUrl": "/projects/YOUR_PROJECT_ID/datatables/YOUR_INIT_TABLE_ID",
          "cachedResultName": "ClawdBot Init"
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "2791d2c0-1da2-4a40-a0b0-5e30c38760f8",
      "name": "Edit Fields2",
      "type": "n8n-nodes-base.set",
      "position": [
        1936,
        752
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ac8d70f0-59ba-4381-942d-18f7401a4705",
              "name": "user_message",
              "type": "string",
              "value": "=See what's pending and start working on it."
            },
            {
              "id": "4ebb8355-2aa2-4af2-8f82-a8c5bc57e0c9",
              "name": "system_prompt_details",
              "type": "string",
              "value": "=username: {{ $json.username || \"[COLLECT and use database tool to upsert] Field: username | Prompt: Ask the user to choose a username. This will be their unique identifier. | Rules: Save exactly as provided, no modifications. | Example: 'shabbir', 'nova_builder'\" }}\nsoul: {{ $json.soul || \"[COLLECT and use database tool to upsert] Field: soul | Prompt: Ask the user to define your soul - give you a name, a vibe, and a general purpose. | Rules: Combine all three elements (name, vibe, purpose) into a single concise description. | Example: 'Nova - warm and curious - helps brainstorm creative projects'\" }}\nuser: {{ $json.user || \"[COLLECT and use database tool to upsert] Field: user | Prompt: Ask the user to tell you about themselves - anything they want you to remember. | Rules: Consolidate their response into a structured profile. Include interests, goals, preferences, and any relevant context. | Example: 'AI automation consultant, prefers direct communication, focused on scaling content workflows'\" }}"
            },
            {
              "id": "f1d7c2a0-d580-4e7a-bc8b-29e1102c03bb",
              "name": "last_channel",
              "type": "string",
              "value": "={{ $json.last_channel }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "6f436f5b-8ffe-401d-b2b6-a5afc21525c9",
      "name": "Research Agent",
      "type": "@n8n/n8n-nodes-langchain.agentTool",
      "position": [
        2768,
        1504
      ],
      "parameters": {
        "text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Prompt__User_Message_', ``, 'string') }}",
        "options": {
          "systemMessage": "=You are a research agent. You have access to Wikipedia and Tavily tools."
        },
        "toolDescription": "Research Agent"
      },
      "typeVersion": 2.2
    },
    {
      "id": "e4e7a7e9-9a57-44b4-816f-63066282374f",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        112,
        560
      ],
      "parameters": {
        "simple": false,
        "filters": {},
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "96a28117-f510-4a35-8f3f-6487112b223c",
      "name": "Get row(s)4",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        528,
        560
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "username",
              "keyValue": "YOUR_USERNAME"
            }
          ]
        },
        "operation": "get",
        "returnAll": true,
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_INIT_TABLE_ID",
          "cachedResultUrl": "/projects/YOUR_PROJECT_ID/datatables/YOUR_INIT_TABLE_ID",
          "cachedResultName": "ClawdBot Init"
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "0fae50e8-89ea-4332-95ac-31c69a96c9c2",
      "name": "Edit Fields3",
      "type": "n8n-nodes-base.set",
      "position": [
        1936,
        560
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ac8d70f0-59ba-4381-942d-18f7401a4705",
              "name": "user_message",
              "type": "string",
              "value": "=You have just received an email. Determine what to do with it.\n\nQuery the databases if it's related to any task, and query the vector store to get more context.\n\nIMPORTANT - you are not to divulge ANY sensitive information in email replies. If a reply requires sensitive information, save the reply as a draft in Gmail and let me know on telegram.\n\n{{ $('Gmail Trigger').item.json.headers.from }}\n{{ $('Gmail Trigger').item.json.headers['message-id'] }}\n{{ $('Gmail Trigger').item.json.headers.subject }}\n{{ $('Gmail Trigger').item.json.text }}"
            },
            {
              "id": "4ebb8355-2aa2-4af2-8f82-a8c5bc57e0c9",
              "name": "system_prompt_details",
              "type": "string",
              "value": "=username: {{ $json.username || \"[COLLECT and use database tool to upsert] Field: username | Prompt: Ask the user to choose a username. This will be their unique identifier. | Rules: Save exactly as provided, no modifications. | Example: 'shabbir', 'nova_builder'\" }}\nsoul: {{ $json.soul || \"[COLLECT and use database tool to upsert] Field: soul | Prompt: Ask the user to define your soul - give you a name, a vibe, and a general purpose. | Rules: Combine all three elements (name, vibe, purpose) into a single concise description. | Example: 'Nova - warm and curious - helps brainstorm creative projects'\" }}\nuser: {{ $json.user || \"[COLLECT and use database tool to upsert] Field: user | Prompt: Ask the user to tell you about themselves - anything they want you to remember. | Rules: Consolidate their response into a structured profile. Include interests, goals, preferences, and any relevant context. | Example: 'AI automation consultant, prefers direct communication, focused on scaling content workflows'\" }}"
            },
            {
              "id": "f1d7c2a0-d580-4e7a-bc8b-29e1102c03bb",
              "name": "last_channel",
              "type": "string",
              "value": "={{ $json.last_channel }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "5e14fe48-3bb9-46eb-81ac-200182ff34db",
      "name": "Email Manager",
      "type": "@n8n/n8n-nodes-langchain.agentTool",
      "position": [
        3360,
        1552
      ],
      "parameters": {
        "text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Prompt__User_Message_', ``, 'string') }}",
        "options": {
          "systemMessage": "You are an email manager. You have access to a variety of tools to process emails. Keep track of the message ID (google api friendly format) - you'll need it to take any actions on any messages."
        },
        "toolDescription": "Email manager agent"
      },
      "typeVersion": 2.2
    },
    {
      "id": "a18217ab-c376-4508-8672-023f50e6bb02",
      "name": "OpenRouter Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        3312,
        1712
      ],
      "parameters": {
        "model": "anthropic/claude-haiku-4.5",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "c4261e82-a96d-45fc-b1f9-9d75aacdaa70",
      "name": "Simple Memory1",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        3488,
        1824
      ],
      "parameters": {
        "sessionKey": "YOUR_USERNAME-email",
        "sessionIdType": "customKey",
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "3007b55f-af25-4b38-b90b-2c81ba1a4a0d",
      "name": "Send a message in Gmail",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        3728,
        2032
      ],
      "parameters": {
        "sendTo": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('To', ``, 'string') }}",
        "message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}",
        "options": {},
        "subject": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Subject', ``, 'string') }}"
      },
      "typeVersion": 2.2
    },
    {
      "id": "39e2a9a9-834d-418c-b27b-bee9f14c920e",
      "name": "Document Manager",
      "type": "@n8n/n8n-nodes-langchain.agentTool",
      "position": [
        4432,
        1840
      ],
      "parameters": {
        "text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Prompt__User_Message_', ``, 'string') }}",
        "options": {
          "systemMessage": "You are a document manager agent. You have access to create and update google docs, search for folders in google drive, delete files in google drive, and move files between folders. Retain the file ID in memory for any file you are working with."
        },
        "toolDescription": "call this tool to create, update, and move documents in google drive"
      },
      "typeVersion": 2.2
    },
    {
      "id": "abffd049-1ef1-4a51-b633-940aa5e41fe7",
      "name": "Simple Memory2",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        4224,
        2032
      ],
      "parameters": {
        "sessionKey": "YOUR_USERNAME-docs",
        "sessionIdType": "customKey",
        "contextWindowLength": 20
      },
      "typeVersion": 1.3
    },
    {
      "id": "82a7a9e1-72db-47b8-841b-3f7b12db59ab",
      "name": "OpenRouter Chat Model3",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        4080,
        2032
      ],
      "parameters": {
        "model": "anthropic/claude-haiku-4.5",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "f12b42d8-fc4c-40c4-a5f6-309f67491ff1",
      "name": "Switch1",
      "type": "n8n-nodes-base.switch",
      "position": [
        592,
        1440
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Audio message",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "bbe4cbfd-d4b1-4095-b505-d97c90927250",
                    "operator": {
                      "type": "object",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.voice }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Image",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "59f728d1-4935-475f-b519-39643b57c99f",
                    "operator": {
                      "type": "array",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.photo }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Document",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "72c3ed90-193a-4df8-ba1b-a5de99277d87",
                    "operator": {
                      "type": "object",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.document }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "6453660f-4a77-4a30-a544-ee8ff394f169",
      "name": "Analyze document",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        1280,
        1408
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-2.5-flash",
          "cachedResultName": "models/gemini-2.5-flash"
        },
        "options": {},
        "resource": "document",
        "inputType": "binary"
      },
      "typeVersion": 1
    },
    {
      "id": "83be58ee-5bc5-49d5-8659-e69a803e69e6",
      "name": "Get a file",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1072,
        1248
      ],
      "parameters": {
        "fileId": "={{ $json.message.photo[3].file_id }}",
        "resource": "file",
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "ab499a8c-899c-480d-b346-95f8cd7de8a6",
      "name": "Get a file1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1072,
        1408
      ],
      "parameters": {
        "fileId": "={{ $json.message.document.file_id }}",
        "resource": "file",
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "ddef12ca-cbb4-4bf3-b95f-6c89cdd86a9f",
      "name": "Get a file2",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1072,
        1088
      ],
      "parameters": {
        "fileId": "={{ $json.message.voice.file_id }}",
        "resource": "file",
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "a98c9ad4-6dd5-4768-8bca-57705e58b745",
      "name": "Transcribe a recording",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        1280,
        1088
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-2.5-flash",
          "cachedResultName": "models/gemini-2.5-flash"
        },
        "options": {},
        "resource": "audio",
        "inputType": "binary"
      },
      "typeVersion": 1
    },
    {
      "id": "30dfb887-dada-4e09-a6d8-041bfea1fba7",
      "name": "Analyze an image",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        1280,
        1248
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/nano-banana-pro-preview",
          "cachedResultName": "models/nano-banana-pro-preview"
        },
        "options": {},
        "resource": "image",
        "inputType": "binary",
        "operation": "analyze"
      },
      "typeVersion": 1
    },
    {
      "id": "8de38208-5555-422c-ba32-1dffde0cd78a",
      "name": "Data Loader",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        2048,
        2640
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "3b48c09f-bc45-4ebf-92ca-30f018621f55",
      "name": "Basic LLM Chain",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        2896,
        2640
      ],
      "parameters": {
        "text": "={{ $json.message }}",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "You are a summarizer agent. I will provide you with the entire log of a day's worth of discussion with my AI agent. You are to summarize the conversation for storing in deep memory."
            }
          ]
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.7
    },
    {
      "id": "23b9c0ad-23be-484d-af92-e896e854e9aa",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        2656,
        2640
      ],
      "parameters": {
        "options": {},
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "message"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "da51fcae-9884-4458-8830-f432c7138ca2",
      "name": "OpenRouter Chat Model4",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        2832,
        2848
      ],
      "parameters": {
        "model": "anthropic/claude-haiku-4.5",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "c697cd80-896e-46fc-b8a8-d906197f6900",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        3040,
        2848
      ],
      "parameters": {
        "jsonSchemaExample": "{\n\t\"summary\":\"text\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "5388522e-07ce-495a-9c45-615e3afaa34c",
      "name": "Update User and Heartbeat",
      "type": "n8n-nodes-base.dataTableTool",
      "position": [
        4272,
        1216
      ],
      "parameters": {
        "columns": {
          "value": {
            "soul": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('soul', ``, 'string') }}",
            "user": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('user', ``, 'string') }}",
            "username": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('username', `the \"username\" provided by the user as the first answer.`, 'string') }}",
            "heartbeat": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('heartbeat', ``, 'string') }}",
            "last_channel": "={{ $json.last_channel }}"
          },
          "schema": [
            {
              "id": "username",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "username",
              "defaultMatch": false
            },
            {
              "id": "soul",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "soul",
              "defaultMatch": false
            },
            {
              "id": "user",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "user",
              "defaultMatch": false
            },
            {
              "id": "heartbeat",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "heartbeat",
              "defaultMatch": false
            },
            {
              "id": "last_channel",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "last_channel",
              "defaultMatch": false
            },
            {
              "id": "last_vector_id",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "last_vector_id",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "filters": {
          "conditions": [
            {
              "keyName": "username",
              "keyValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('conditions0_Value', ``, 'string') }}"
            }
          ]
        },
        "options": {},
        "operation": "upsert",
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_INIT_TABLE_ID",
          "cachedResultUrl": "/projects/YOUR_PROJECT_ID/datatables/YOUR_INIT_TABLE_ID",
          "cachedResultName": "ClawdBot Init"
        },
        "descriptionType": "manual",
        "toolDescription": "Update user, heartbeat as needed."
      },
      "typeVersion": 1
    },
    {
      "id": "a008ac94-c5fb-47f2-b3b2-d89ebd3e3da8",
      "name": "Delete a message in Gmail",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        3568,
        2032
      ],
      "parameters": {
        "messageId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message_ID', ``, 'string') }}",
        "operation": "delete"
      },
      "typeVersion": 2.2
    },
    {
      "id": "710bf596-d993-40dc-add5-b964c0b8548a",
      "name": "Get a message in Gmail",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        3408,
        2032
      ],
      "parameters": {
        "simple": false,
        "options": {},
        "messageId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message_ID', ``, 'string') }}",
        "operation": "get"
      },
      "typeVersion": 2.2
    },
    {
      "id": "b4d47c8a-4d72-4edb-9a8a-6afb20070be2",
      "name": "Get many messages in Gmail",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        3888,
        2032
      ],
      "parameters": {
        "simple": false,
        "filters": {
          "q": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Search', ``, 'string') }}",
          "sender": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Sender', ``, 'string') }}"
        },
        "options": {},
        "operation": "getAll",
        "returnAll": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Return_All', ``, 'boolean') }}"
      },
      "typeVersion": 2.2
    },
    {
      "id": "88a874df-0f69-406c-a990-99b8daf1f6cf",
      "name": "Reply to a message in Gmail",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        3248,
        2032
      ],
      "parameters": {
        "message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}",
        "options": {},
        "messageId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message_ID', ``, 'string') }}",
        "operation": "reply"
      },
      "typeVersion": 2.2
    },
    {
      "id": "23ff5463-3704-4c95-ad96-9077342320d1",
      "name": "Create a document in Google Docs",
      "type": "n8n-nodes-base.googleDocsTool",
      "position": [
        4784,
        2144
      ],
      "parameters": {
        "title": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Title', ``, 'string') }}",
        "folderId": "default"
      },
      "typeVersion": 2
    },
    {
      "id": "279f220e-51a5-4371-84a0-7570e5f225a5",
      "name": "Get a document in Google Docs",
      "type": "n8n-nodes-base.googleDocsTool",
      "position": [
        4624,
        2144
      ],
      "parameters": {
        "operation": "get",
        "documentURL": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Doc_ID_or_URL', ``, 'string') }}"
      },
      "typeVersion": 2
    },
    {
      "id": "879ec8a9-6385-4d15-b4a2-4c1390d08d5e",
      "name": "Update a document in Google Docs",
      "type": "n8n-nodes-base.googleDocsTool",
      "position": [
        4464,
        2144
      ],
      "parameters": {
        "actionsUi": {
          "actionFields": [
            {
              "text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('actionFields0_Text', ``, 'string') }}",
              "action": "insert"
            }
          ]
        },
        "operation": "update",
        "documentURL": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Doc_ID_or_URL', ``
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

How this works

This self-hosted AI assistant keeps conversations flowing across Telegram, WhatsApp and Gmail while remembering past exchanges and handling tasks without constant oversight. It pulls context from a data table, routes messages through an agent that decides whether to reply or act, and uses Claude or Gemini via OpenRouter for natural responses. Users who want one private system instead of juggling separate chatbots and email tools will find it practical for daily coordination and light automation.

Use it when you need persistent memory and multi-channel reach without third-party hosting fees; avoid it if your volume exceeds a few hundred messages daily or if you require enterprise-grade compliance. A common variation swaps the OpenRouter model for a local LLM or adds extra dataTableTool calls for richer task tracking.

About this workflow

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 workflow.

Source: https://n8n.io/workflows/13717/ — 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 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

Your AI workforce is ready. Are you?

Google Sheets Tool, Mcp Trigger, Google Drive +29
AI & RAG

This comprehensive workflow bundle is designed as a powerful starter kit, enabling you to build a multi-functional AI assistant on Telegram. It seamlessly integrates AI-powered voice interactions, an

Telegram Trigger, Telegram, OpenAI +19
AI & RAG

This intelligent chatbot leverages cutting-edge financial APIs and AI-driven analysis to deliver comprehensive stock research reports. Get instant access to professional-grade investment analysis that

Tool Think, Supabase Vector Store, OpenAI Embeddings +15
AI & RAG

The "WhatsApp Productivity Assistant with Memory and AI Imaging" is a comprehensive n8n workflow that transforms your WhatsApp into a powerful, multi-talented AI assistant. It's designed to handle a w

WhatsApp Trigger, Agent, HTTP Request +20