AutomationFlowsAI & RAG › Telegram AI Agent with OpenAI and Gemini

Telegram AI Agent with OpenAI and Gemini

Original n8n title: Openclaw Clone 🦞: Expandable Personal Telegram AI Agent Template

ByDavide Boizza @n3witalia on n8n.io

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 complex tasks.

Event trigger★★★★★ complexityAI-powered86 nodesTelegram TriggerTelegramOpenAIFtpGoogle Gemini ChatMemory Postgres ChatGmail ToolMcp Trigger
AI & RAG Trigger: Event Nodes: 86 Complexity: ★★★★★ AI nodes: yes Added:

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

This workflow follows the Agent → OpenAI Embeddings 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
{
  "id": "Vgb2eeIEZ6UVBgSs",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "OpenClaw n8n Agent",
  "tags": [],
  "nodes": [
    {
      "id": "9aff7c4d-e9b9-4d23-9c27-1c6cc29ac355",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        -240,
        1280
      ],
      "parameters": {
        "jsCode": "if ($input.first().json.message.from.id !== XXX) { // Replace with your Telegram user ID\n    return { unauthorized: true };\n} else {\n    // Return the original data when authorized\n    return $input.all();\n}\n"
      },
      "typeVersion": 2
    },
    {
      "id": "35ecd51a-6a17-4a4b-8268-6c68624367a3",
      "name": "Get Message",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -544,
        1280
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "c5d2318f-b0b0-4b1e-91d0-c099920bd528",
      "name": "Send a text message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2432,
        864
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "={{ $('Get Message').item.json.message.from.id }}",
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "c8fb757e-7954-4a8f-862e-5958346e6b7a",
      "name": "Get Text",
      "type": "n8n-nodes-base.set",
      "position": [
        720,
        1088
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "029f4e7e-b367-4aa9-863e-e372694940fb",
              "name": "chatInput",
              "type": "string",
              "value": "={{ $json.message.text }}"
            },
            {
              "id": "398c1d7f-0c90-4af6-a414-d4d1968855b9",
              "name": "sessionId",
              "type": "number",
              "value": "={{ $json.message.from.id }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "cb7af990-ca72-4167-9da0-63f3fb8ff7f9",
      "name": "Switch2",
      "type": "n8n-nodes-base.switch",
      "position": [
        0,
        1264
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Text",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.text}}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Audio",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "7b2cb4dc-dd9d-43b2-b4db-f0de858f46cc",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.voice.file_id }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Immagine",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "98d80a35-3004-4bad-95b8-e87fc9270083",
                    "operator": {
                      "type": "object",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.photo[0] }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "executeOnce": false,
      "typeVersion": 3.2,
      "alwaysOutputData": false
    },
    {
      "id": "2468465b-020f-4e89-bafb-cc29e0583d07",
      "name": "Get voice message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        272,
        1280
      ],
      "parameters": {
        "fileId": "={{ $('Get Message').item.json.message.voice.file_id }}",
        "resource": "file",
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "4299a579-f361-480e-a97a-01f11a52334b",
      "name": "Transcribe recording",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        496,
        1280
      ],
      "parameters": {
        "options": {
          "language": "it"
        },
        "resource": "audio",
        "operation": "transcribe"
      },
      "typeVersion": 1.7
    },
    {
      "id": "39b99c3f-493a-48b7-921e-ec197d4e44ff",
      "name": "Get image file",
      "type": "n8n-nodes-base.telegram",
      "position": [
        288,
        1520
      ],
      "parameters": {
        "fileId": "={{ $json.message.photo[2].file_id }}",
        "resource": "file",
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "cf8e0a98-488b-4cf3-bd77-10457c49badf",
      "name": "Upload image",
      "type": "n8n-nodes-base.ftp",
      "position": [
        512,
        1520
      ],
      "parameters": {
        "path": "=/XXX/{{ $binary.data.fileName }}",
        "options": {},
        "operation": "upload"
      },
      "typeVersion": 1
    },
    {
      "id": "536bccef-f8c1-4377-b787-2ce3f1e09808",
      "name": "Set Image Url",
      "type": "n8n-nodes-base.set",
      "position": [
        736,
        1520
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "29fbf21e-301d-4a1c-b6c9-723c9c03fb61",
              "name": "image_url",
              "type": "string",
              "value": "=https://XXX/{{ $binary.data.fileName }}"
            },
            {
              "id": "272f6379-55fa-4d36-8da7-0ec1232606fd",
              "name": "chatInput",
              "type": "string",
              "value": "={{ $('Get Message').item.json.message.caption || \"\"}}"
            },
            {
              "id": "aff4f5c4-fe02-4bb8-b923-9c91334124ba",
              "name": "sessionId",
              "type": "string",
              "value": "={{ $('Get Message').item.json.message.from.id }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "6857b57c-68a6-43a0-a040-8d684bfcc0fc",
      "name": "Get input text from voice",
      "type": "n8n-nodes-base.set",
      "position": [
        720,
        1280
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "029f4e7e-b367-4aa9-863e-e372694940fb",
              "name": "chatInput",
              "type": "string",
              "value": "={{ $json.text }}"
            },
            {
              "id": "398c1d7f-0c90-4af6-a414-d4d1968855b9",
              "name": "sessionId",
              "type": "number",
              "value": "={{ $('Get Message').item.json.message.from.id }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "3de555a1-4af4-4270-98f5-da051845290b",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1200,
        1488
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "300752bd-1dfb-4cab-b4f3-cbb9b1d40269",
      "name": "Postgres Chat Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "position": [
        1392,
        1488
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "ff6814ab-52f3-424f-802d-2cfdf3d11b3a",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        304,
        800
      ],
      "parameters": {
        "path": "56c7aeae-eb8a-4d2e-a149-dfe02b586d18",
        "options": {}
      },
      "typeVersion": 2.1
    },
    {
      "id": "a384f159-0790-43be-93d7-f56b174b3765",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        288,
        560
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "6fd754da-1d0f-4fce-9f7a-4b4921db36d6",
      "name": "Get a message in Gmail",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        -512,
        2752
      ],
      "parameters": {
        "messageId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message_ID', ``, 'string') }}",
        "operation": "get"
      },
      "typeVersion": 2.1
    },
    {
      "id": "c0712605-9864-44ab-bc9a-fb41c78f5015",
      "name": "Send a message in Gmail",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        -336,
        2752
      ],
      "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.1
    },
    {
      "id": "0138d005-83e8-432c-b9c6-dd6bc7d3769e",
      "name": "Get many messages in Gmail",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        0,
        2752
      ],
      "parameters": {
        "simple": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Simplify', ``, 'boolean') }}",
        "filters": {
          "q": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Search', ``, 'string') }}",
          "receivedAfter": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Received_After', ``, 'string') }}",
          "receivedBefore": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Received_Before', ``, 'string') }}"
        },
        "options": {
          "downloadAttachments": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Download_Attachments', ``, 'boolean') }}"
        },
        "operation": "getAll",
        "returnAll": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Return_All', ``, 'boolean') }}"
      },
      "typeVersion": 2.1
    },
    {
      "id": "31978220-0742-4a98-a2fc-b9aba56a9074",
      "name": "Reply to a message in Gmail",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        -176,
        2752
      ],
      "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.1
    },
    {
      "id": "08e6a4d5-63e4-48be-bfa2-c45f00f1a115",
      "name": "Create a draft in Gmail",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        176,
        2752
      ],
      "parameters": {
        "message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}",
        "options": {
          "sendTo": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('To_Email', ``, 'string') }}",
          "replyTo": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Send_Replies_To', ``, 'string') }}",
          "threadId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Thread_ID', ``, 'string') }}"
        },
        "subject": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Subject', ``, 'string') }}",
        "resource": "draft"
      },
      "typeVersion": 2.1
    },
    {
      "id": "c8dfaea9-69db-480b-a45d-5deea94d8464",
      "name": "MCP Gmail Trigger",
      "type": "@n8n/n8n-nodes-langchain.mcpTrigger",
      "position": [
        -272,
        2528
      ],
      "parameters": {
        "path": "63975752-0598-4992-9422-165a84c8798c"
      },
      "typeVersion": 2
    },
    {
      "id": "8838423f-0e45-4c90-ba51-4f303fc47779",
      "name": "MCP Calendar Trigger",
      "type": "@n8n/n8n-nodes-langchain.mcpTrigger",
      "position": [
        688,
        2528
      ],
      "parameters": {
        "path": "0f72eb90-2a1c-403e-98e1-901d76c2825c"
      },
      "typeVersion": 2
    },
    {
      "id": "a29ceee3-c210-4212-81d1-9dfbe93ecef4",
      "name": "Create an event in Google Calendar",
      "type": "n8n-nodes-base.googleCalendarTool",
      "position": [
        528,
        2736
      ],
      "parameters": {
        "end": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('End', ``, 'string') }}",
        "start": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Start', ``, 'string') }}",
        "calendar": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Calendar', ``, 'string') }}",
          "__regex": "(^[a-zA-Z0-9.!#$%&\u2019*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*)"
        },
        "additionalFields": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "44293600-bd90-41e3-a591-82ca359fcb1d",
      "name": "Get many events in Google Calendar",
      "type": "n8n-nodes-base.googleCalendarTool",
      "position": [
        688,
        2736
      ],
      "parameters": {
        "options": {},
        "timeMax": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Before', ``, 'string') }}",
        "timeMin": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('After', ``, 'string') }}",
        "calendar": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Calendar', ``, 'string') }}",
          "__regex": "(^[a-zA-Z0-9.!#$%&\u2019*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*)"
        },
        "operation": "getAll",
        "returnAll": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Return_All', ``, 'boolean') }}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "0acf2e56-575f-4de2-8cd4-3f4f3d3cd15e",
      "name": "Get an event in Google Calendar",
      "type": "n8n-nodes-base.googleCalendarTool",
      "position": [
        832,
        2736
      ],
      "parameters": {
        "eventId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Event_ID', ``, 'string') }}",
        "options": {},
        "calendar": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Calendar', ``, 'string') }}",
          "__regex": "(^[a-zA-Z0-9.!#$%&\u2019*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*)"
        },
        "operation": "get"
      },
      "typeVersion": 1.3
    },
    {
      "id": "66c1d8a6-73c4-4be5-8f6d-342ad548bede",
      "name": "Delete an event in Google Calendar",
      "type": "n8n-nodes-base.googleCalendarTool",
      "position": [
        976,
        2736
      ],
      "parameters": {
        "eventId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Event_ID', ``, 'string') }}",
        "options": {},
        "calendar": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Calendar', ``, 'string') }}",
          "__regex": "(^[a-zA-Z0-9.!#$%&\u2019*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*)"
        },
        "operation": "delete"
      },
      "typeVersion": 1.3
    },
    {
      "id": "e1d7ef2d-ab01-4129-a761-2e33abc75882",
      "name": "Get availability in a calendar in Google Calendar",
      "type": "n8n-nodes-base.googleCalendarTool",
      "position": [
        1120,
        2736
      ],
      "parameters": {
        "options": {},
        "timeMax": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('End_Time', ``, 'string') }}",
        "timeMin": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Start_Time', ``, 'string') }}",
        "calendar": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Calendar', ``, 'string') }}",
          "__regex": "(^[a-zA-Z0-9.!#$%&\u2019*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*)"
        },
        "resource": "calendar"
      },
      "typeVersion": 1.3
    },
    {
      "id": "3f1d9d49-d4e6-4a54-b651-533404e3cf94",
      "name": "Download file in Google Drive",
      "type": "n8n-nodes-base.googleDriveTool",
      "position": [
        1328,
        2672
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('File', ``, 'string') }}"
        },
        "options": {},
        "operation": "download"
      },
      "typeVersion": 3
    },
    {
      "id": "5ddd6c81-b65b-4c9b-bd63-c8b1bb91aea2",
      "name": "Search files and folders in Google Drive",
      "type": "n8n-nodes-base.googleDriveTool",
      "position": [
        1488,
        2672
      ],
      "parameters": {
        "limit": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Limit', ``, 'number') }}",
        "filter": {},
        "options": {},
        "resource": "fileFolder",
        "queryString": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Search_Query', ``, 'string') }}"
      },
      "typeVersion": 3
    },
    {
      "id": "cdc2a8ca-278c-4403-ab35-b1db04ee00b1",
      "name": "Get many shared drives in Google Drive",
      "type": "n8n-nodes-base.googleDriveTool",
      "position": [
        1632,
        2672
      ],
      "parameters": {
        "limit": 50,
        "options": {},
        "resource": "drive",
        "operation": "list",
        "returnAll": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Return_All', ``, 'boolean') }}"
      },
      "typeVersion": 3
    },
    {
      "id": "6cfa0b3a-bd5f-442e-b857-ebd76eaf1c21",
      "name": "Create file from text in Google Drive",
      "type": "n8n-nodes-base.googleDriveTool",
      "position": [
        1792,
        2672
      ],
      "parameters": {
        "name": "={{$now.format('yyyyLLdd')}}",
        "content": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('File_Content', ``, 'string') }}",
        "driveId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Parent_Drive', ``, 'string') }}"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Parent_Folder', ``, 'string') }}"
        },
        "operation": "createFromText"
      },
      "typeVersion": 3
    },
    {
      "id": "7bdad212-4128-4a48-80e2-79f29ff42c21",
      "name": "Move file in Google Drive",
      "type": "n8n-nodes-base.googleDriveTool",
      "position": [
        1984,
        2672
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('File', ``, 'string') }}"
        },
        "driveId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Parent_Drive', ``, 'string') }}"
        },
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Parent_Folder', ``, 'string') }}"
        },
        "operation": "move"
      },
      "typeVersion": 3
    },
    {
      "id": "93436800-ea48-4a7d-a581-6212646be140",
      "name": "Create a document in Google Docs",
      "type": "n8n-nodes-base.googleDocsTool",
      "position": [
        1632,
        3488
      ],
      "parameters": {
        "title": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Title', ``, 'string') }}",
        "folderId": "default"
      },
      "typeVersion": 2
    },
    {
      "id": "f7182e80-1b8c-4d44-b423-ac87977fe874",
      "name": "Get a document in Google Docs",
      "type": "n8n-nodes-base.googleDocsTool",
      "position": [
        1808,
        3488
      ],
      "parameters": {
        "operation": "get",
        "documentURL": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Doc_ID_or_URL', ``, 'string') }}"
      },
      "typeVersion": 2
    },
    {
      "id": "68f36c9a-2fd9-4c23-9d54-0fb2b0cbc046",
      "name": "Update a document in Google Docs",
      "type": "n8n-nodes-base.googleDocsTool",
      "position": [
        2016,
        3488
      ],
      "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', ``, 'string') }}"
      },
      "typeVersion": 2
    },
    {
      "id": "f05f575a-6808-4879-b767-f796e4ea6065",
      "name": "MCP Docs Trigger",
      "type": "@n8n/n8n-nodes-langchain.mcpTrigger",
      "position": [
        1712,
        3328
      ],
      "parameters": {
        "path": "1f35317d-7b8e-48b9-a419-936ea5b63ae6"
      },
      "typeVersion": 2
    },
    {
      "id": "eab0bd78-74ba-4b93-a91e-650ca05a9887",
      "name": "MCP Drive Trigger",
      "type": "@n8n/n8n-nodes-langchain.mcpTrigger",
      "position": [
        1536,
        2528
      ],
      "parameters": {
        "path": "031809b0-c277-4ff1-b65a-9e72294b1ff1"
      },
      "typeVersion": 2
    },
    {
      "id": "31367f91-bb19-42de-bce6-4a2af35bfd0a",
      "name": "MCP Sheet Trigger",
      "type": "@n8n/n8n-nodes-langchain.mcpTrigger",
      "position": [
        -256,
        3312
      ],
      "parameters": {
        "path": "1f35317d-7b8e-48b9-a419-936ea5b63ae6"
      },
      "typeVersion": 2
    },
    {
      "id": "e9bffc25-264c-4dea-a37b-c84bfd6d042f",
      "name": "Get row(s) in sheet in Google Sheets",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        -528,
        3504
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Sheet', ``, 'string') }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Document', ``, 'string') }}"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "f1f4f0a8-fc9a-4f03-a022-653ed4513a6d",
      "name": "Append or update row in sheet in Google Sheets",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        -368,
        3504
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Sheet', ``, 'string') }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Document', ``, 'string') }}"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "0a803d0d-9e80-45bf-9255-312bd607732c",
      "name": "Create sheet in Google Sheets",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        -48,
        3504
      ],
      "parameters": {
        "title": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Title', ``, 'string') }}",
        "options": {},
        "operation": "create",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Document', ``, 'string') }}"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "7dc142a2-9573-4ee3-ba23-d33ec1a430cb",
      "name": "Delete rows or columns from sheet in Google Sheets",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        96,
        3504
      ],
      "parameters": {
        "operation": "delete",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Sheet', ``, 'string') }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Document', ``, 'string') }}"
        },
        "startIndex": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Start_Row_Number', ``, 'number') }}",
        "numberToDelete": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Number_of_Rows_to_Delete', ``, 'number') }}"
      },
      "typeVersion": 4.7
    },
    {
      "id": "4ba9f84f-948e-4c8c-829a-5b9a3f49bb80",
      "name": "Update row in sheet in Google Sheets",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        -224,
        3504
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Sheet', ``, 'string') }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Document', ``, 'string') }}"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "9330110e-2902-4979-826f-fc4028d6e059",
      "name": "Clear sheet in Google Sheets",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        256,
        3488
      ],
      "parameters": {
        "operation": "clear",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Sheet', ``, 'string') }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Document', ``, 'string') }}"
        },
        "keepFirstRow": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Keep_First_Row', ``, 'boolean') }}"
      },
      "typeVersion": 4.7
    },
    {
      "id": "4fe3da3e-56fb-4705-999c-1b8c8b15c7e4",
      "name": "Create a presentation in Google Slides",
      "type": "n8n-nodes-base.googleSlidesTool",
      "position": [
        656,
        3504
      ],
      "parameters": {
        "title": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Title', ``, 'string') }}"
      },
      "typeVersion": 2
    },
    {
      "id": "a086528c-65be-4f0b-bd8d-e37ae94d69d5",
      "name": "MCP Slides Trigger",
      "type": "@n8n/n8n-nodes-langchain.mcpTrigger",
      "position": [
        816,
        3296
      ],
      "parameters": {
        "path": "1f35317d-7b8e-48b9-a419-936ea5b63ae6"
      },
      "typeVersion": 2
    },
    {
      "id": "c789143b-ccb1-4812-9a34-89e16f7a928e",
      "name": "Get a presentation in Google Slides",
      "type": "n8n-nodes-base.googleSlidesTool",
      "position": [
        816,
        3504
      ],
      "parameters": {
        "operation": "get",
        "presentationId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Presentation_ID', ``, 'string') }}"
      },
      "typeVersion": 2
    },
    {
      "id": "2c9be9f2-70a4-4472-85ca-c238f2236285",
      "name": "Get slides from a presentation in Google Slides",
      "type": "n8n-nodes-base.googleSlidesTool",
      "position": [
        976,
        3504
      ],
      "parameters": {
        "operation": "getSlides",
        "returnAll": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Return_All', ``, 'boolean') }}",
        "presentationId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Presentation_ID', ``, 'string') }}"
      },
      "typeVersion": 2
    },
    {
      "id": "10d5d110-f242-46a2-a5a3-6d5f1e2bebdc",
      "name": "Replace text in a presentation in Google Slides",
      "type": "n8n-nodes-base.googleSlidesTool",
      "position": [
        1152,
        3504
      ],
      "parameters": {
        "textUi": {
          "textValues": [
            {
              "text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('textValues0_Search_For', ``, 'string') }}",
              "replaceText": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('textValues0_Replace_With', ``, 'string') }}"
            }
          ]
        },
        "options": {
          "revisionId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Revision_ID', ``, 'string') }}"
        },
        "operation": "replaceText",
        "presentationId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Presentation_ID', ``, 'string') }}"
      },
      "typeVersion": 2
    },
    {
      "id": "ee269946-4fc4-4dcf-9319-8334442a8efa",
      "name": "Delete a draft in Gmail",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        192,
        2944
      ],
      "parameters": {
        "resource": "draft",
        "messageId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Draft_ID', ``, 'string') }}",
        "operation": "delete"
      },
      "typeVersion": 2.1
    },
    {
      "id": "9d9db45e-b11d-4230-b587-c7e4bc165565",
      "name": "Delete a message in Gmail",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        -512,
        2944
      ],
      "parameters": {
        "messageId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Draft_ID', ``, 'string') }}",
        "operation": "delete"
      },
      "typeVersion": 2.1
    },
    {
      "id": "c14ac52c-602d-4a0e-85ed-9dc064a47f3d",
      "name": "Add label to message in Gmail",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        -336,
        2944
      ],
      "parameters": {
        "labelIds": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Label_Names_or_IDs', ``, 'string') }}",
        "messageId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Draft_ID', ``, 'string') }}",
        "operation": "addLabels"
      },
      "typeVersion": 2.1
    },
    {
      "id": "791ba40d-22b8-413a-808d-3c38b8a4b453",
      "name": "Remove label from message in Gmail",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        -160,
        2944
      ],
      "parameters": {
        "labelIds": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Label_Names_or_IDs', ``, 'string') }}",
        "messageId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Draft_ID', ``, 'string') }}",
        "operation": "removeLabels"
      },
      "typeVersion": 2.1
    },
    {
      "id": "92449df8-4258-4509-83e9-a7236ec88c83",
      "name": "Send message and wait for response in Gmail",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        16,
        2944
      ],
      "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') }}",
        "operation": "sendAndWait"
      },
      "typeVersion": 2.1
    },
    {
      "id": "d2bcf517-2763-4fc0-bab0-8f4065f6d7d4",
      "name": "Gmail Agent",
      "type": "@n8n/n8n-nodes-langchain.mcpClientTool",
      "position": [
        1488,
        1856
      ],
      "parameters": {
        "options": {},
        "endpointUrl": "https://n8n.skool.n3witalia.com/mcp-test/63975752-0598-4992-9422-165a84c8798c"
      },
      "typeVersion": 1.2
    },
    {
      "id": "a91d816c-8fb6-401b-b669-d37a3a75558d",
      "name": "Google Drive Agent",
      "type": "@n8n/n8n-nodes-langchain.mcpClientTool",
      "position": [
        1488,
        2016
      ],
      "parameters": {
        "options": {},
        "endpointUrl": "https://n8n.skool.n3witalia.com/mcp-test/63975752-0598-4992-9422-165a84c8798c"
      },
      "typeVersion": 1.2
    },
    {
      "id": "544a8947-8ffd-4685-bdf0-3fd258afd9dd",
      "name": "Google Calendar Agent",
      "type": "@n8n/n8n-nodes-langchain.mcpClientTool",
      "position": [
        1632,
        2000
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "8e6a21cc-1209-4cd5-8237-22563e60563d",
      "name": "Google Slides Agent",
      "type": "@n8n/n8n-nodes-langchain.mcpClientTool",
      "position": [
        1776,
        2016
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "5837e19e-bcc1-41f5-affc-2d3d45304b63",
      "name": "Google Docs Agent",
      "type": "@n8n/n8n-nodes-langchain.mcpClientTool",
      "position": [
        1616,
        1856
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "600d8ff3-0edd-4f64-81e7-d4f556e113f8",
      "name": "Google Sheets Agent",
      "type": "@n8n/n8n-nodes-langchain.mcpClientTool",
      "position": [
        1760,
        1856
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "08f52ac5-4e89-44a7-8c95-e2b15901808e",
      "name": "OpenClaw Agents",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1344,
        1264
      ],
      "parameters": {
        "text": "={{ $json.chatInput ?? '' }}\n\nImage Url (if exist): {{ $json.image_url ?? '' }}",
        "options": {
          "systemMessage": "=# \ud83e\udd16 Universal Orchestrator Agent \u2014 n8n OpenClaw Simulation\n\nYou are an advanced AI orchestrator agent running inside n8n, simulating an OpenClaw-style multi-agent architecture. Your role is to analyze the user's request, decompose it into tasks, and intelligently delegate each task to the most appropriate specialized tool or sub-agent. You operate autonomously, chain tool calls as needed, and synthesize results into a coherent final response.\n\n---\n\n## \ud83e\udde0 CORE BEHAVIOR\n\n- Always reason step-by-step before calling any tool.\n- Select the most appropriate tool(s) based on the nature of the request.\n- Chain multiple tools when a task requires it (e.g., research \u2192 write doc \u2192 send email).\n- Never ask the user for information you can retrieve yourself via tools.\n- If a tool returns insufficient results, try an alternative tool or refine your query.\n- Always summarize what you did and what the outcome was.\n\n---\n\n## \ud83d\udee0\ufe0f AVAILABLE TOOLS & AGENTS\n\n### \ud83d\udd0d 1. Research Agent (`research_agent`)\n- **Provider:** Perplexity AI\n- **Use when:** The user needs deep research, fact-checking, topic analysis, competitor research, industry reports, or any question requiring up-to-date internet knowledge.\n- **Input:** A well-formed research question or topic.\n- **Output:** Structured research summary with sources.\n\n---\n\n### \ud83c\udf10 2. Web Search Agent (`websearch_agent`)\n- **Provider:** Perplexity AI\n- **Use when:** The user needs quick web searches, current news, recent events, prices, or lightweight information retrieval (faster and lighter than full Research Agent).\n- **Input:** A search query string.\n- **Output:** Top results with snippets and URLs.\n\n---\n\n### \ud83d\udd77\ufe0f 3. Scraper Agent (`scraper_agent`)\n- **Provider:** ScrapeGraphAI\n- **Use when:** The user provides a URL or asks to extract structured data from a specific webpage (e.g., product details, article content, table data, contact info).\n- **Input:** URL + extraction instructions (what data to extract).\n- **Output:** Structured JSON or formatted text extracted from the page.\n\n---\n\n### \ud83d\udcc1 4. Google Drive Agent (`googledrive_agent`)\n- **Use when:** The user needs to search, list, upload, download, move, or manage files and folders in Google Drive.\n- **Input:** Action type + file name/ID/folder path.\n- **Output:** File metadata, download links, or confirmation of action performed.\n\n---\n\n### \ud83d\udce7 5. Gmail Agent (`gmail_agent`)\n- **Use when:** The user needs to read, search, send, reply to, or organize emails in Gmail.\n- **Input:** Action type (send/read/search/reply) + relevant parameters (to, subject, body, search query).\n- **Output:** Email content, sent confirmation, or list of matching emails.\n\n---\n\n### \ud83d\udcdd 6. Google Docs Agent (`googledocs_agent`)\n- **Use when:** The user needs to create, read, edit, append content to, or format a Google Doc.\n- **Input:** Action type + document ID or title + content to write/append.\n- **Output:** Document link, content extracted, or confirmation of edit.\n\n---\n\n### \ud83d\udcca 7. Google Sheets Agent (`googlesheets_agent`)\n- **Use when:** The user needs to read, write, update, or analyze data in a Google Sheet (e.g., logging data, pulling reports, updating CRM-like tables).\n- **Input:** Action type + spreadsheet ID/name + sheet/range + data payload.\n- **Output:** Data rows, updated values, or confirmation.\n\n---\n\n### \ud83d\udcd1 8. Google Slides Agent (`googleslides_agent`)\n- **Use when:** The user needs to create a presentation, add/edit slides, or extract content from Google Slides.\n- **Input:** Action type + presentation ID or title + slide content/instructions.\n- **Output:** Presentation link or confirmation of changes.\n\n---\n\n### \ud83d\udcc5 9. Google Calendar Agent (`googlecalendar_agent`)\n- **Use when:** The user needs to create, read, update, or delete calendar events, check availability, or schedule meetings.\n- **Input:** Action type + event details (title, date, time, attendees, description).\n- **Output:** Event link, list of events, or confirmation of action.\n\n---\n\n### \ud83e\udde0 10. RAG Agent (`rag_agent`)\n- **Use when:** The user asks questions about internal documents, company knowledge base, uploaded files, or any private/indexed knowledge that is not publicly available on the web.\n- **Input:** A natural language question or query.\n- **Output:** Answer grounded in retrieved document chunks with source references.\n\n---\n\n### \ud83d\udd0c 11. MCP Agents (`mcp_[service_name]`)\n> **Placeholder \u2014 extend as needed**\n- **Use when:** The user requires integration with an external service connected via Model Context Protocol (MCP).\n- **Available MCP endpoints:** *(to be configured \u2014 replace with actual service names)*\n  - `mcp_placeholder_1` \u2014 [Service Name TBD]\n  - `mcp_placeholder_2` \u2014 [Service Name TBD]\n  - `mcp_placeholder_3` \u2014 [Service Name TBD]\n- **Input:** Service-specific action and parameters.\n- **Output:** Service-specific response.\n\n---\n\n### \u2699\ufe0f 12. Sub-Workflows (`subwf_[workflow_name]`)\n> **Placeholder \u2014 extend as needed**\n- **Use when:** The user's request maps to a predefined automation workflow in n8n.\n- **Available Sub-Workflows:**\n  - `subwf_social_posting` \u2014 **Postiz Integration**: Post content to any social media platform (LinkedIn, Twitter/X, Instagram, Facebook, TikTok, etc.). Input: platform, content text, media URL (optional), scheduled time (optional).\n  - `subwf_placeholder_2` \u2014 [Workflow Name TBD]\n  - `subwf_placeholder_3` \u2014 [Workflow Name TBD]\n  - `subwf_placeholder_4` \u2014 [Workflow Name TBD]\n- **Input:** Workflow-specific parameters.\n- **Output:** Workflow execution result or confirmation.\n\n---\n\n### \ud83d\udea8 13. Escalation Agent (`escalation_agent`)\n- **Use when:**\n  - A task cannot be completed by any available tool after multiple attempts.\n  - The request involves ambiguous, sensitive, or critical decisions requiring human judgment.\n  - An error or unexpected result occurs that blocks task completion.\n  - The user explicitly requests human review or approval.\n- **Input:** Summary of the issue, tools already attempted, reason for escalation.\n- **Output:** Escalation notification sent to the responsible human (via email, Slack, or designated channel), with full context attached.\n\n---\n\n## \ud83d\udd04 ORCHESTRATION LOGIC\n\nFollow this decision flow for every request:\nUNDERSTAND \u2192 Parse the user intent and identify all sub-tasks.\nPLAN \u2192 Map each sub-task to the most suitable tool/agent.\nEXECUTE \u2192 Call tools sequentially or in parallel as needed.\nEVALUATE \u2192 Check if results are complete and accurate.\nCHAIN \u2192 If further steps are needed, call additional tools with previous output as input.\nESCALATE \u2192 If blocked or uncertain, call escalation_agent.\nRESPOND \u2192 Synthesize all results into a clear, structured final answer.\n\n---\n\n## \ud83d\udccb TOOL SELECTION CHEAT SHEET\n\n| User Need | Primary Tool |\n|---|---|\n| Research a topic in depth | `research_agent` |\n| Quick web search / news | `websearch_agent` |\n| Extract data from a URL | `scraper_agent` |\n| Manage files in Drive | `googledrive_agent` |\n| Send / read emails | `gmail_agent` |\n| Write / edit a document | `googledocs_agent` |\n| Work with spreadsheet data | `googlesheets_agent` |\n| Create / edit a presentation | `googleslides_agent` |\n| Schedule / manage events | `googlecalendar_agent` |\n| Query internal knowledge base | `rag_agent` |\n| External service via MCP | `mcp_[service_name]` |\n| Run a predefined automation | `subwf_[workflow_name]` |\n| Post on social media | `subwf_social_posting` |\n| Task failed / needs human | `escalation_agent` |\n\n---\n\n## \u26a0\ufe0f RULES & CONSTRAINTS\n\n- **Never hallucinate tool results.** If a tool is unavailable or returns an error, report it honestly.\n- **Always confirm destructive actions** (delete, send email to many recipients, post publicly) before executing if there is any ambiguity.\n- **Respect data privacy.** Do not expose sensitive data in intermediate steps unnecessarily.\n- **Keep tool calls focused.** Pass precise, minimal inputs \u2014 do not dump large unstructured text into tools.\n- **Log your reasoning.** Before each tool call, briefly state why you are calling it.\n- **If in doubt, escalate.** It is always better to escalate than to take a wrong action autonomously.\n\n---\n\n*Orchestrator ready. Awaiting your instructions.*"
        },
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "c5cb1d06-d651-4cfa-9990-844e22b18439",
      "name": "Websearch Agent",
      "type": "n8n-nodes-base.perplexityTool",
      "position": [
        1568,
        1488
      ],
      "parameters": {
        "options": {},
        "messages": {
          "message": [
            {
              "content": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('message0_Text', ``, 'string') }}"
            }
          ]
        },
        "requestOptions": {}
      },
      "typeVersion": 1
    },
    {
      "id": "d5c5bea8-9873-4791-9e90-aa3237f4cde0",
      "name": "Scraper Agent",
      "type": "n8n-nodes-scrapegraphai.scrapegraphAiTool",
      "position": [
        1680,
        1488
      ],
      "parameters": {
        "userPrompt": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('User_Prompt', ``, 'string') }}",
        "websiteUrl": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Website_URL', ``, 'string') }}",
        "renderHeavyJs": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Render_Heavy_JS', ``, 'boolean') }}",
        "enableScrolling": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Enable_Infinite_Scrolling', ``, 'boolean') }}",
        "useOutputSchema": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Use_Custom_Output_Schema', ``, 'boolean') }}",
        "enablePagination": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Enable_Pagination', ``, 'boolean') }}"
      },
      "typeVersion": 1
    },
    {
      "id": "2abb18cd-1f7b-40d0-bb04-8a309d3f44d5",
      "name": "RAG Agent",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
      "position": [
        2096,
        1472
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "options": {},
        "useReranker": true,
        "toolDescription": "RAG Agent",
        "qdrantCollection": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "b5b46ab6-454c-49be-81ae-1dfa12dc4092",
      "name": "Embeddings OpenAI",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        2112,
        1648
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "407faf5a-c921-4618-9174-aefe633c62d2",
      "name": "Reranker Cohere",
      "type": "@n8n/n8n-nodes-langchain.rerankerCohere",
      "position": [
        2288,
        1648
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "db2c38f7-0f43-4b8e-9883-017c6253e63b",
      "name": "Image and Video Grok Agent",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        2080,
        1856
      ],
      "parameters": {
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "klLje7jNDPINkW4Y",
          "cachedResultUrl": "/workflow/klLje7jNDPINkW4Y",
          "cachedResultName": "Image Grok Agent with Telegram"
        },
        "description": "Create and edit Image and Video",
        "workflowInputs": {
          "value": {
            "query": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('query', ``, 'string') }}",
            "duration": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('duration', ``, 'number') }}",
            "image_url": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('image_url', ``, 'string') }}",
            "tool_name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('tool_name', ``, 'string') }}",
            "video_url": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('video_url', ``, 'string') }}"
          },
          "schema": [
            {
              "id": "tool_name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "tool_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "query",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "query",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "duration",
              "type": "number",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "duration",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "video_url",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "video_url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "image_url",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "image_url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "2dcacdc8-331b-4b96-a843-83c98c9b8a22",
      "name": "Others MCP Client",
      "type": "@n8n/n8n-nodes-langchain.mcpClientTool",
      "position": [
        2240,
        1856
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "433e4917-7b46-4a21-8b81-a8162df3102a",
      "name": "Others SubWF",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        2384,
        1856
      ],
      "parameters": {
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "klLje7jNDPINkW4Y",
          "cachedResultUrl": "/workflow/klLje7jNDPINkW4Y",
          "cachedResultName": "Image Grok Agent with Telegram"
        },
        "description": "Chiama questo tool  solo quando devi modificare un video gi\u00e0 esistente. NON per crearlo",
        "workflowInputs": {
          "value": {
            "query": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('query', ``, 'string') }}",
            "duration": 0,
            "tool_name": "Run text to image"
          },
          "schema": [
            {
              "id": "tool_name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "tool_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "query",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "query",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "duration",
              "type": "number",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "duration",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "video_url",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "video_url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "image_url",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "image_url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "f94deaef-333e-4849-a155-ee54f2d94a99",
      "name": "Fix mimeType for Audio",
      "type": "n8n-nodes-base.code",
      "position": [
        2720,
        624
      ],
      "parameters": {
        "jsCode": "for (const item of $input.all()) {\n  if (item.binary) {\n    const binaryPropertyNames = Object.keys(item.binary);\n    for (const propName of binaryPropertyNames) {\n      if (item.binary[propName].mimeType === 'audio/mp3') {\n        item.binary[propName].mimeType = 'audio/mpeg';\n      }\n    }\n  }\n}\n\nreturn $input.all();"
      },
      "typeVersion": 2
    },
    {
      "id": "a1aebdb1-03c7-4157-b25b-2a0ecaa8a37d",
      "name": "Generate Audio Response",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        2432,
        624
      ],
      "parameters": {
        "input": "={{ $json.output }}",
        "voice": "onyx",
        "options": {},
        "resource": "audio"
      },
      "typeVersion": 1.8
    },
    {
      "id": "0696bb30-ce21-42b8-acf7-6a817c0a3be2",
      "name": "From audio to audio?",
      "type": "n8n-nodes-base.if",
      "position": [
        2096,
        832
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "b9d1d759-f585-4791-a743-b9d72951e77c",
              "operator": {
                "type": "object",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $('Get Message').item.json.message.voice.file_id }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "141f3caa-e3ed-4dd0-8ab0-1fdfcd62b625",
      "name": "Send an audio file",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2992,
        624
      ],
      "parameters": {
        "chatId": "={{ $('Get Message').item.json.message.from.id }}",
        "operation": "sendAudio",
        "binaryData": true,
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "502b6855-e801-424a-9210-07884485df6f",
      "name": "Normalization",
      "type": "n8n-nodes-base.set",
      "position": [
        704,
        800
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "029f4e7e-b367-4aa9-863e-e372694940fb",
              "name": "chatInput",
              "type": "string",
              "value": "={{ $json.message.text }}"
            },
            {
              "id": "398c1d7f-0c90-4af6-a414-d4d1968855b9",
              "name": "sessionId",
              "type": "number",
              "value": "={{ $json.message.from.id }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "697e6ecd-77a1-4b3d-b1ce-975ca6e28252",
      "name": "Calculator",
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "position": [
        1808,
        1488
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "460bf02f-9359-450e-a340-f3e808553e70",
      "name": "Send a text message in Telegram",
      "type": "n8n-nodes-base.telegramTool",
      "position": [
        2688,
        1648
      ],
      "parameters": {
        "text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Text', ``, 'string') }}",
        "chatId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Chat_ID', ``, 'string') }}",
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "e4d78fe6-1915-4e0c-b7ea-7eef9a362d37",
      "name": "Escalation",
      "type": "n8n-nodes-base.telegramHitlTool",
      "position": [
        2656,
        1488
      ],
      "parameters": {
        "chatId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Chat_ID', ``, 'string') }}",
        "options": {},
        "approvalOptions": {
          "values": {
            "approvalType": "double"
          }
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "70495d52-ddfd-4b14-86f1-d4e6bfc43006",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -672,
        368
      ],
      "parameters": {
        "width": 880,
        "height": 608,
        "content": "## My Personal Agent (OpenClaw Clone in n8n and Telegram)\nThis 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 complex tasks.\n\nI've described my basic idea in [this video](https://www.youtube.com/watch?v=DCo_HsLQ1aY).\n\n**VERY IMPORTANT**:\nBy adapting the system prompt, inserting subworkflows or mcp servers and adjusting with webhooks many of the [workflows I have developed on this page](https://n8n.io/creators/n3witalia/) it is possible to potentially extend the template infinitely.\n\n### How it works\n\nThis workflow acts as a Telegram-based AI orchestration layer that receives user messages, verifies access, and routes input by type: text goes directly to the agent, voice is transcribed, and images are converted into usable URLs with captions. The main OpenClaw Agent, powered by Gemini and backed by PostgreSQL memory, then decides which tools or sub-agents to use, including web research, scraping, Google Workspace actions, RAG via Qdrant, calculator functions, media generation, and Telegram utilities. After completing the task, it returns the response in text or converts it to audio for voice replies, with the option to escalate the conversation to a human operator when automation is not enough.\n\n### Setup steps\n\nSet up the Telegram bot first by creating it in BotFather, connecting Telegram credentials in n8n, and adding the authorized user ID in the Code node. Then configure all required credentials and services: OpenAI, Gemini, Google Cloud, Perplexity, ScrapeGraphAI, Cohere, PostgreSQL, Qdrant, and the FTP server used for image handling. After that, review webhook and MCP endpoint settings, replace every placeholder marked `XXX`, adjust language and prompt settings, and confirm tool descriptions align with your use case. Finally, test the workflow with sample text, voice, and image inputs before activating it in production.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "a44f5f58-11ab-433f-8bf8-2a10af81aea1",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        368
      ],
      "parameters": {
        "color": 7,
        "width": 656,
        "height": 608,
        "content": "## STEP 2 - Set up recurrences\nPlease replace xxx with the requested information, in particular the Telegram ID and the prompt to be scheduled periodically, for example every morning \"Send me the latest news on AI\"\n\nAlso add any external input webhooks you want."
      },
      "typeVersion": 1
    },
    {
      "id": "5f7480f3-e122-499d-b3d9-444e39442b41",
      "name": "Set up istruction",
      "type": "n8n-nodes-base.set",
      "position": [
        704,
        560
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "029f4e7e-b367-4aa9-863e-e372694940fb",
              "name": "chatInput",
Pro

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

How this works

This workflow turns your Telegram chats into a capable personal AI assistant that can handle conversations, process voice notes and images, and carry out multi-step tasks by calling on external tools and cloud services. It is designed for users who want a single, always-available agent that can automate daily work or research without switching between apps. The core chain begins with the Telegram trigger capturing incoming messages, then routes them through AI models for understanding and action planning.

Use it when you need a lightweight personal agent that can grow with added tools or data sources; avoid it if you require enterprise-grade security or fixed, high-volume production processes. Common variations include swapping the main language model or adding new memory stores to keep conversation history across sessions.

About this workflow

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 complex tasks.

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

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

Who is this for? This workflow is ideal for HR teams, startups, and enterprises that want to handle employee interactions through WhatsApp and automate responses using LLM (OpenAI) and intelligent rou

WhatsApp Trigger, OpenAI, OpenAI Chat +13