{
  "name": "Auto-reply to Telegram messages using BrowserAct and Google Gemini",
  "nodes": [
    {
      "id": "6b2a7654-3d7d-4b93-ac03-0cceb7351369",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -848,
        384
      ]
    },
    {
      "id": "bd8d3616-6bdb-451e-8aa7-330fcb3d58e0",
      "name": "Structured Output",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -496,
        304
      ]
    },
    {
      "id": "304fd4f9-7381-475a-af67-7152c89b8421",
      "name": "Human Verification Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        -1824,
        400
      ]
    },
    {
      "id": "fb70f68d-fae9-41dd-932f-ea33a366097f",
      "name": "Every 15 minutes",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -2224,
        400
      ]
    },
    {
      "id": "4de3aa32-c759-4c4d-8b3b-623652d22373",
      "name": "Read Telegram Message",
      "type": "n8n-nodes-browseract.browserAct",
      "position": [
        -2048,
        400
      ]
    },
    {
      "id": "5ec5dde5-f00f-409c-8eed-72d6be43f1b1",
      "name": "Give Time to Complete Verification",
      "type": "n8n-nodes-base.wait",
      "position": [
        -1600,
        288
      ]
    },
    {
      "id": "8a63c0b3-4564-401c-a91d-3de73cc31e3a",
      "name": "Get Data From BrowserAct",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1376,
        288
      ]
    },
    {
      "id": "c35ac544-95f4-4a40-aa03-4794aa6bf261",
      "name": "Splitting Extracted Items",
      "type": "n8n-nodes-base.code",
      "position": [
        -1152,
        384
      ]
    },
    {
      "id": "89f4899a-ed8a-47fd-911e-1df12f6c25f7",
      "name": "Generate Answers for Messages",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -576,
        80
      ]
    },
    {
      "id": "41d3dd95-d1c9-49e5-819d-ed342283cd8d",
      "name": "Check If Message Requires Response",
      "type": "n8n-nodes-base.if",
      "position": [
        -224,
        80
      ]
    },
    {
      "id": "2e396381-b0fe-43f7-9cf6-907a7264ea3e",
      "name": "Run Answering Workflow",
      "type": "n8n-nodes-browseract.browserAct",
      "position": [
        320,
        112
      ]
    },
    {
      "id": "1d597160-9bb9-42e4-81dc-5c335a99b85b",
      "name": "Human Verification Switch2",
      "type": "n8n-nodes-base.switch",
      "position": [
        528,
        112
      ]
    },
    {
      "id": "51fe8b67-ed5a-4f61-bad8-992f41ad8c75",
      "name": "Give Time to Complete Verification2",
      "type": "n8n-nodes-base.wait",
      "position": [
        784,
        0
      ]
    },
    {
      "id": "57d26f4f-644d-41ed-a46a-5b74c21af963",
      "name": "Get Data From BrowserAct2",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1008,
        0
      ]
    },
    {
      "id": "35949fa1-894d-44a6-8da5-1baa58b633b4",
      "name": "Wait for Workflow Completion",
      "type": "n8n-nodes-base.wait",
      "position": [
        1360,
        96
      ]
    },
    {
      "id": "411d2ba6-b510-45ce-b707-d659d39185e5",
      "name": "Google Gemini",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -624,
        304
      ]
    },
    {
      "id": "9aea2505-df97-4a68-b905-df2ef274097e",
      "name": "Cleaning Output Text",
      "type": "n8n-nodes-base.code",
      "position": [
        0,
        112
      ]
    },
    {
      "id": "bc5a2d3b-0b3e-43df-9fd8-4320c7047401",
      "name": "Documentation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2592,
        -272
      ],
      "parameters": {
        "width": 380,
        "height": 520,
        "content": "## ⚡ Workflow Overview & Setup\n\n**Summary:** This automation acts as an always-on customer support agent for Telegram. It checks for new messages every 15 minutes, uses AI to draft personalized respon"
      }
    },
    {
      "id": "2b8d1463-bf34-4baf-a28f-65393da1099c",
      "name": "Step 1 Explanation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2176,
        128
      ],
      "parameters": {
        "width": 1132,
        "height": 124,
        "content": "### 📩 Step 1: Message Retrieval\n\nThe workflow triggers every 15 minutes to fetch the latest messages from Telegram via BrowserAct. It scrapes the chat history to understand the context of each user in"
      }
    },
    {
      "id": "81769b9a-722e-4606-831b-557272c03f62",
      "name": "Step 2 Explanation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        -64
      ],
      "parameters": {
        "width": 1004,
        "height": 108,
        "content": "### 🧠 Step 2: AI Response Drafting\n\nAn AI agent analyzes the retrieved messages to determine if a response is needed. If the user asked a question, it drafts a personalized, helpful reply, ensuring to"
      }
    },
    {
      "id": "ed5b3990-a679-4648-9dd7-eebdef8984ce",
      "name": "Step 3 Explanation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        -144
      ],
      "parameters": {
        "width": 1180,
        "height": 108,
        "content": "### 🤖 Step 3: Automated Reply\n\nOnce a response is drafted and cleaned, BrowserAct is triggered again to type and send the message directly in the Telegram web interface, simulating a human agent's beh"
      }
    },
    {
      "id": "811257f4-8b38-4526-b7f2-32b27a82a395",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2176,
        -272
      ],
      "parameters": {
        "width": 640,
        "height": 368,
        "content": "@[youtube](iTp4LhhjCiQ)"
      }
    }
  ],
  "connections": {
    "Google Gemini": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Answers for Messages",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Structured Output",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Generate Answers for Messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Every 15 minutes": {
      "main": [
        [
          {
            "node": "Read Telegram Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output": {
      "ai_outputParser": [
        [
          {
            "node": "Generate Answers for Messages",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Cleaning Output Text": {
      "main": [
        [
          {
            "node": "Run Answering Workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Telegram Message": {
      "main": [
        [
          {
            "node": "Human Verification Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Answering Workflow": {
      "main": [
        [
          {
            "node": "Human Verification Switch2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Data From BrowserAct": {
      "main": [
        [
          {
            "node": "Splitting Extracted Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Data From BrowserAct2": {
      "main": [
        [
          {
            "node": "Wait for Workflow Completion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Human Verification Switch": {
      "main": [
        [
          {
            "node": "Splitting Extracted Items",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Give Time to Complete Verification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Splitting Extracted Items": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Human Verification Switch2": {
      "main": [
        [
          {
            "node": "Wait for Workflow Completion",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Give Time to Complete Verification2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Workflow Completion": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Answers for Messages": {
      "main": [
        [
          {
            "node": "Check If Message Requires Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check If Message Requires Response": {
      "main": [
        [
          {
            "node": "Cleaning Output Text",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Give Time to Complete Verification": {
      "main": [
        [
          {
            "node": "Get Data From BrowserAct",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Give Time to Complete Verification2": {
      "main": [
        [
          {
            "node": "Get Data From BrowserAct2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}