{
  "id": "RsybQdZr1cZ42ZUS",
  "name": "Automate reactions for Telegram Channel Posts using bots",
  "tags": [],
  "nodes": [
    {
      "id": "34abb54f-61b7-49b9-b310-e344412e7bfa",
      "name": "Sticky Note - Telegram",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -992,
        256
      ],
      "parameters": {
        "color": 4,
        "width": 284,
        "height": 708,
        "content": "## \ud83d\udcf1 Telegram Trigger\n\n**Purpose:** Entry point for the workflow\n\n**What it does:**\n- Listens for incoming Telegram messages\n- Captures user requests like:\n  - \"Give me 5 fire reactions\"\n  - \"https://t.me/channel/123 needs 10 reactions\"\n\n**Outputs:** Message object with text, chat ID, and user info"
      },
      "typeVersion": 1
    },
    {
      "id": "d837ab73-8310-4a77-a223-a1d6e5026f55",
      "name": "Sticky Note - AI",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -688,
        256
      ],
      "parameters": {
        "color": 5,
        "width": 300,
        "height": 704,
        "content": "## \ud83e\udd16 AI Analysis\n\n**Purpose:** Intelligently parse user requests\n\n**What it does:**\n- Analyzes the user's message\n- Extracts:\n  - Number of reactions requested\n  - Specific emoji types (fire, heart, thumbs up, etc.)\n  - Handles natural language (\"5 fire\" \u2192 [\"\ud83d\udd25\",\"\ud83d\udd25\",\"\ud83d\udd25\",\"\ud83d\udd25\",\"\ud83d\udd25\"])\n\n**AI Model:** GPT-5-MINI\n\n**Output:** JSON array of emojis based on request"
      },
      "typeVersion": 1
    },
    {
      "id": "85bedd07-591e-4980-9cee-19b2bb90684b",
      "name": "Sticky Note - Processing",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -368,
        256
      ],
      "parameters": {
        "color": 6,
        "width": 444,
        "height": 712,
        "content": "## \ud83d\udd27 Data Processing\n\n**Purpose:** Transform AI output into API-ready format\n\n**What it does:**\n1. Extracts message ID from Telegram link\n2. Validates emojis against Telegram's allowed list\n3. Handles duplicates intelligently:\n   - Allows duplicates if \u22643 unique emojis requested\n   - Replaces invalid emojis with random valid ones\n4. Assigns bot tokens (rotates through n number of your bots based on the tokens that you provide)\n5. Creates array of reaction objects\n\n**Output Format:**\n```json\n{\n  \"emoji\": \"\ud83d\udd25\",\n  \"botToken\": \"...\",\n  \"chatId\": \"-1003154563293\",\n  \"messageId\": 123\n}\n```\nNOTE:\nReplace lines 15 and 33 of the code prep node with your own channel ID and Bot tokens"
      },
      "typeVersion": 1
    },
    {
      "id": "1372c0e3-7635-475f-a122-43875c00b931",
      "name": "Sticky Note - Debug",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -368,
        992
      ],
      "parameters": {
        "color": 3,
        "width": 444,
        "height": 360,
        "content": "## \ud83d\udd0d Debug Logger\n\n**Purpose:** Monitoring and troubleshooting\n\n**What it does:**\n- Logs total items being processed\n- Shows each reaction's details:\n  - Emoji being sent\n  - Target chat/message IDs\n  - Bot token (partially hidden)\n\n**Useful for:** Debugging failed reactions"
      },
      "typeVersion": 1
    },
    {
      "id": "5a9b74b8-4163-4fb0-8897-bf5174414542",
      "name": "Sticky Note - Loop",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        96,
        256
      ],
      "parameters": {
        "color": 7,
        "width": 260,
        "height": 712,
        "content": "## \ud83d\udd04 Batch Processor\n\n**Purpose:** Send reactions one at a time\n\n**What it does:**\n- Takes array of reaction objects\n- Loops through each item\n- Sends one reaction per iteration\n- Prevents rate limiting by processing sequentially\n\n**Why needed:** Telegram API requires individual requests per reaction"
      },
      "typeVersion": 1
    },
    {
      "id": "40ead69f-71b1-4d77-8529-33366d97eb79",
      "name": "Sticky Note - HTTP",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        464,
        672
      ],
      "parameters": {
        "color": 2,
        "width": 408,
        "height": 552,
        "content": "## \ud83d\ude80 Send Reaction\n\n**Purpose:** Execute Telegram API call\n\n**What it does:**\n- Calls Telegram's `setMessageReaction` endpoint\n- Sends:\n  - Bot token (for authentication)\n  - Chat ID (target channel)\n  - Message ID (specific post)\n  - Emoji (reaction to add)\n\n**API Endpoint:**\n`https://api.telegram.org/bot{token}/setMessageReaction`\n\n**Result:** Reaction appears on the message"
      },
      "typeVersion": 1
    },
    {
      "id": "d7eca245-b056-4319-b54f-dae533dc2c63",
      "name": "Sticky Note - Rate Limit",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        464,
        144
      ],
      "parameters": {
        "width": 408,
        "height": 520,
        "content": "## \u23f1\ufe0f Rate Limiting\n\n**Purpose:** Prevent API throttling\n\n**What it does:**\n- Limits execution rate\n- Adds wait time between batches\n- Ensures workflow doesn't hit Telegram's rate limits\n\n**Components:**\n1. **Limit Node** - Controls flow rate\n2. **Wait Node** - Adds delay between operations"
      },
      "typeVersion": 1
    },
    {
      "id": "b785f071-8a2a-46a7-88de-67e61b94b1e4",
      "name": "Sticky Note - Completion",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        144
      ],
      "parameters": {
        "color": 4,
        "width": 324,
        "height": 528,
        "content": "## \u2705 Completion\n\n**Purpose:** User confirmation\n\n**What it does:**\n- Sends \"All done!\" message back to user\n- Confirms all reactions were added\n- Uses original chat ID from trigger\n\n**User Experience:** User gets immediate feedback that their request completed successfully"
      },
      "typeVersion": 1
    },
    {
      "id": "4d93e8bb-273f-4540-9f5c-67acaf4b5164",
      "name": "Sticky Note - Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1552,
        256
      ],
      "parameters": {
        "color": 5,
        "width": 464,
        "height": 864,
        "content": "## \ud83d\udccb WORKFLOW OVERVIEW\n\n**Telegram Multiple Reactions Army Bot** - Automated Telegram reaction system\n\n**Flow:**\n1. User sends message to bot\n2. AI parses request (emoji type & quantity)\n3. Code processes and validates data\n4. Loop sends reactions one by one\n5. User receives confirmation\n\n**Key Features:**\n- Natural language processing\n- Reiterates through bot token rotation\n- Duplicate emoji handling\n- Rate limit protection\n- Error handling with helpful messages\n\n1st add the bots to the channel that you would want them to react posts to and allow it to manage messages\n\nCredentials needed are:\nTarget Channel ID, Bot tokens, Bot Receiver token\n\n**Example Usage:**\n- \"https://t.me/channel/123 needs 10 hearts and 10 fire reactions\n\n\nPS: To get the ID of a channel in TG\n\nThere are a few ways to find the chat/channel ID of a Telegram channel (public or private). Here are common methods:\n\n\u2705 Method 1: Use a bot\n1. Add a bot like @userinfobot or @getmy_idbot to your channel (or forward a message from the channel to the bot).\n2. The bot will reply with the channel\u2019s numeric ID (for example: -1001234567890) for private channels.\n3. Make sure forwarding is allowed if the channel blocks forwarding."
      },
      "typeVersion": 1
    },
    {
      "id": "5592fc81-7eb0-49a1-bcad-db982a1c403a",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        608,
        1072
      ],
      "parameters": {
        "url": "=https://api.telegram.org/bot{{ $json.botToken }}/setMessageReaction",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"chat_id\": \"{{ $json.chatId }}\",\n  \"message_id\": {{ $json.messageId }},\n  \"reaction\": [\n    {\n      \"type\": \"emoji\",\n      \"emoji\": \"{{ $json.emoji }}\"\n    }\n  ]\n}",
        "sendBody": true,
        "specifyBody": "json"
      },
      "typeVersion": 4.2
    },
    {
      "id": "de82667b-a207-4325-8db6-4b04d44ddaa9",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        176,
        672
      ],
      "parameters": {
        "options": {
          "reset": false
        }
      },
      "typeVersion": 3
    },
    {
      "id": "260abb47-d3da-4115-b585-9e66c743f9d3",
      "name": "Limit",
      "type": "n8n-nodes-base.limit",
      "position": [
        528,
        480
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "195cbb5d-2262-487c-b5e1-aa2591bad249",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        688,
        480
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "1a067cb4-5370-4d0d-b961-35658fa32176",
      "name": "Telegram Chat Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -912,
        672
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "21d9e004-8b32-428f-ad10-a9486bda6652",
      "name": "Reply \"all done\" message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        992,
        480
      ],
      "parameters": {
        "text": "All done!",
        "chatId": "={{ $('Telegram Chat Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "fef6fa46-d0a0-4767-a092-594afd468205",
      "name": "Message a model",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -656,
        672
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5-mini-2025-08-07",
          "cachedResultName": "GPT-5-MINI-2025-08-07"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "={{ $json.message.text }}"
            },
            {
              "role": "system",
              "content": "=You are a Telegram Reaction Army AI assistant. Your job is to analyze incoming Telegram messages and extract reaction requests.\n\nThe user will provide:\n1. A Telegram message link (e.g., https://t.me/channelname/123)\n2. The number and type of reactions they want\n\nTASK:\n1. Read the user's message carefully\n2. Extract the NUMBER of reactions requested\n3. Check if the user specified PARTICULAR emojis or types\n4. Generate the exact emojis based on their request\n\nAVAILABLE EMOJIS:\n\ud83d\udc4d, \ud83d\udc4e, \u2764\ufe0f, \ud83d\udd25, \ud83e\udd70, \ud83d\udc4f, \ud83d\ude01, \ud83e\udd14, \ud83e\udd2f, \ud83d\ude31, \ud83e\udd2c, \ud83d\ude22, \ud83c\udf89, \ud83e\udd29, \ud83e\udd2e, \ud83d\udca9, \ud83d\ude4f, \ud83d\udc4c, \ud83d\udd4a, \ud83e\udd21, \ud83e\udd71, \ud83e\udd74, \ud83d\ude0d, \ud83d\udc33, \u2764\ufe0f\u200d\ud83d\udd25, \ud83c\udf1a, \ud83c\udf2d, \ud83d\udcaf, \ud83e\udd23, \u26a1\ufe0f, \ud83c\udf4c, \ud83c\udfc6, \ud83d\udc94, \ud83e\udd28, \ud83d\ude10, \ud83c\udf53, \ud83c\udf7e, \ud83d\udc8b, \ud83d\udd95, \ud83d\ude08, \ud83d\ude34, \ud83d\ude2d, \ud83e\udd13, \ud83d\udc7b, \ud83d\udc68\u200d\ud83d\udcbb, \ud83d\udc40, \ud83c\udf83, \ud83d\ude48, \ud83d\ude07, \ud83d\ude28, \ud83e\udd1d, \u270d\ufe0f, \ud83e\udd17, \ud83e\udee1, \ud83c\udf85, \ud83c\udf84, \u2603\ufe0f, \ud83d\udc85, \ud83e\udd2a, \ud83d\uddff, \ud83c\udd92, \ud83d\udc98, \ud83d\ude49, \ud83e\udd84, \ud83d\ude18, \ud83d\udc8a, \ud83d\ude4a, \ud83d\ude0e, \ud83d\udc7e, \ud83e\udd37\u200d\u2642\ufe0f, \ud83e\udd37, \ud83e\udd37\u200d\u2640\ufe0f, \ud83d\ude21\n\nEMOJI ALIASES (understand these as the emojis):\n- \"fire\" = \ud83d\udd25\n- \"heart\" or \"love\" = \u2764\ufe0f\n- \"thumbs up\" or \"like\" = \ud83d\udc4d\n- \"party\" or \"celebrate\" = \ud83c\udf89\n- \"clap\" or \"applause\" = \ud83d\udc4f\n- \"thinking\" = \ud83e\udd14\n- \"crying\" or \"sad\" = \ud83d\ude22\n- \"100\" or \"hundred\" = \ud83d\udcaf\n- \"rocket\" or \"lightning\" = \u26a1\ufe0f\n- \"trophy\" or \"winner\" = \ud83c\udfc6\n- \"pray\" or \"please\" = \ud83d\ude4f\n- \"poop\" or \"shit\" = \ud83d\udca9\n- \"angry\" or \"mad\" = \ud83d\ude21\n- \"cool\" or \"sunglasses\" = \ud83d\ude0e\n- \"shocked\" or \"mind blown\" = \ud83e\udd2f\n- \"laugh\" or \"laughing\" = \ud83e\udd23\n\nSPECIFIC REQUEST HANDLING:\n- If user requests specific emojis (e.g., \"5 fire emojis\", \"give me 3 hearts\"), use ONLY that emoji repeated\n- If user mentions multiple specific emojis (e.g., \"2 fire and 3 hearts\"), give exactly what they asked\n- If user says \"random\" or doesn't specify, give random different emojis\n- If the requested emoji is not in the available list, use the closest match or random emojis\n\nOUTPUT FORMAT (CRITICAL):\nYou MUST respond with ONLY a valid JSON array of emoji strings. Nothing else.\n\nExample inputs and outputs:\n\nInput: \"hey reaction army AI i need 5 reactions for my most recent post\"\nOutput: [\"\ud83d\udd25\", \"\u2764\ufe0f\", \"\ud83d\ude02\", \"\ud83d\udc4d\", \"\ud83c\udf89\"]\n\nInput: \"give me 5 fire emojis\"\nOutput: [\"\ud83d\udd25\", \"\ud83d\udd25\", \"\ud83d\udd25\", \"\ud83d\udd25\", \"\ud83d\udd25\"]\n\nInput: \"please give me 3 hearts and 2 fire\"\nOutput: [\"\u2764\ufe0f\", \"\u2764\ufe0f\", \"\u2764\ufe0f\", \"\ud83d\udd25\", \"\ud83d\udd25\"]\n\nInput: \"i need 7 thumbs up reactions\"\nOutput: [\"\ud83d\udc4d\", \"\ud83d\udc4d\", \"\ud83d\udc4d\", \"\ud83d\udc4d\", \"\ud83d\udc4d\", \"\ud83d\udc4d\", \"\ud83d\udc4d\"]\n\nInput: \"reaction army! give me 4 party emojis and 2 claps\"\nOutput: [\"\ud83c\udf89\", \"\ud83c\udf89\", \"\ud83c\udf89\", \"\ud83c\udf89\", \"\ud83d\udc4f\", \"\ud83d\udc4f\"]\n\nInput: \"10 random reactions please\"\nOutput: [\"\ud83d\udd25\", \"\u2764\ufe0f\", \"\ud83d\ude0e\", \"\ud83c\udfc6\", \"\ud83d\udcaf\", \"\ud83e\udd2f\", \"\ud83d\udc4d\", \"\ud83c\udf89\", \"\ud83d\ude01\", \"\u26a1\ufe0f\"]\n\nInput: \"5 fire and 5 hearts\"\nOutput: [\"\ud83d\udd25\", \"\ud83d\udd25\", \"\ud83d\udd25\", \"\ud83d\udd25\", \"\ud83d\udd25\", \"\u2764\ufe0f\", \"\u2764\ufe0f\", \"\u2764\ufe0f\", \"\u2764\ufe0f\", \"\u2764\ufe0f\"]\n\nRULES:\n- Always output valid JSON array format\n- Each emoji must be a separate string in the array\n- For specific emoji requests, repeat the SAME emoji the requested number of times\n- For mixed requests, follow the exact quantities specified\n- Randomly select emojis ONLY when user doesn't specify which ones\n- If the number cannot be determined, default to 5 reactions\n- Output ONLY the JSON array, no explanations or additional text\n- When repeating emojis, it's OK to have duplicates if that's what the user requested"
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "547b3785-236b-4bf9-9cce-8cbe796ea5ba",
      "name": "Code Prep",
      "type": "n8n-nodes-base.code",
      "position": [
        -304,
        832
      ],
      "parameters": {
        "jsCode": "// Get the AI response\nconst aiResponse = $input.first().json;\n\n\n// Try to get Telegram input (handle if not executed yet)\nlet telegramInput;\ntry {\n  telegramInput = $('Telegram Chat Trigger').first().json;\n} catch (e) {\n  throw new Error(\"Please trigger the workflow by sending a message to the Telegram bot first!\");\n}\n\nlet emojis = [];\nlet messageId = null;\nlet chatId = \"-1+1234567890\"; // Your public channel ID\n\n// Valid Telegram reaction emojis\nconst validEmojis = [\n  \"\ud83d\udc4d\", \"\ud83d\udc4e\", \"\u2764\ufe0f\", \"\ud83d\udd25\", \"\ud83e\udd70\", \"\ud83d\udc4f\", \"\ud83d\ude01\", \"\ud83e\udd14\", \n  \"\ud83e\udd2f\", \"\ud83d\ude31\", \"\ud83e\udd2c\", \"\ud83d\ude22\", \"\ud83c\udf89\", \"\ud83e\udd29\", \"\ud83e\udd2e\", \"\ud83d\udca9\",\n  \"\ud83d\ude4f\", \"\ud83d\udc4c\", \"\ud83d\udd4a\", \"\ud83e\udd21\", \"\ud83e\udd71\", \"\ud83e\udd74\", \"\ud83d\ude0d\", \"\ud83d\udc33\",\n  \"\u2764\ufe0f\u200d\ud83d\udd25\", \"\ud83c\udf1a\", \"\ud83c\udf2d\", \"\ud83d\udcaf\", \"\ud83e\udd23\", \"\u26a1\ufe0f\", \"\ud83c\udf4c\", \"\ud83c\udfc6\",\n  \"\ud83d\udc94\", \"\ud83e\udd28\", \"\ud83d\ude10\", \"\ud83c\udf53\", \"\ud83c\udf7e\", \"\ud83d\udc8b\", \"\ud83d\udd95\", \"\ud83d\ude08\",\n  \"\ud83d\ude34\", \"\ud83d\ude2d\", \"\ud83e\udd13\", \"\ud83d\udc7b\", \"\ud83d\udc68\u200d\ud83d\udcbb\", \"\ud83d\udc40\", \"\ud83c\udf83\", \"\ud83d\ude48\",\n  \"\ud83d\ude07\", \"\ud83d\ude28\", \"\ud83e\udd1d\", \"\u270d\ufe0f\", \"\ud83e\udd17\", \"\ud83e\udee1\", \"\ud83c\udf85\", \"\ud83c\udf84\",\n  \"\u2603\ufe0f\", \"\ud83d\udc85\", \"\ud83e\udd2a\", \"\ud83d\uddff\", \"\ud83c\udd92\", \"\ud83d\udc98\", \"\ud83d\ude49\", \"\ud83e\udd84\",\n  \"\ud83d\ude18\", \"\ud83d\udc8a\", \"\ud83d\ude4a\", \"\ud83d\ude0e\", \"\ud83d\udc7e\", \"\ud83e\udd37\u200d\u2642\ufe0f\", \"\ud83e\udd37\", \"\ud83e\udd37\u200d\u2640\ufe0f\",\n  \"\ud83d\ude21\"\n];\n\n// ADD YOUR BOT TOKENS HERE\nconst botTokens = [\n  \"8241237833:AAEbJbNx4-9rTAHJZ_yaShzbqCRwUoD-I3U\",  // replace with your own token\n  \"8339530330:AAG8EYMN1lLKK2yhmxl2fkFlQlKbc-lkuY\",   // replace with your own token\n  \"8333742303:AA1kuLLW1x3WTN2i-9v8xXfjXZ2TSB_i1j\"    // replace with your own token\n];\n\n// Get the original message text from user\nconst userMessage = telegramInput.message?.text || \"\";\n\n// Extract message ID from Telegram link\nconst telegramLinkMatch = userMessage.match(/t\\.me\\/[^\\/]+\\/(\\d+)/i);\nconst messageNumberMatch = userMessage.match(/message\\s+(\\d+)|post\\s+(\\d+)/i);\n\nif (telegramLinkMatch) {\n  messageId = parseInt(telegramLinkMatch[1]);\n} else if (messageNumberMatch) {\n  messageId = parseInt(messageNumberMatch[1] || messageNumberMatch[2]);\n}\n\n// Extract emojis from AI response\nfunction extractArray(str) {\n  if (typeof str !== 'string') return null;\n  const match = str.match(/\\[[\\s\\S]*?\\]/);\n  if (match) {\n    try {\n      return JSON.parse(match[0]);\n    } catch (e) {\n      return null;\n    }\n  }\n  return null;\n}\n\nif (aiResponse.message && aiResponse.message.content) {\n  const content = aiResponse.message.content;\n  emojis = extractArray(content);\n}\nelse if (aiResponse.message && typeof aiResponse.message === 'string') {\n  emojis = extractArray(aiResponse.message);\n}\nelse if (aiResponse.output) {\n  if (typeof aiResponse.output === 'string') {\n    emojis = extractArray(aiResponse.output);\n  } else if (Array.isArray(aiResponse.output)) {\n    emojis = aiResponse.output;\n  }\n}\nelse if (Array.isArray(aiResponse)) {\n  emojis = aiResponse;\n}\nelse if (aiResponse.choices && aiResponse.choices[0]?.message?.content) {\n  const content = aiResponse.choices[0].message.content;\n  emojis = extractArray(content);\n}\n\nif (!Array.isArray(emojis) || emojis.length === 0) {\n  emojis = [\"\ud83d\udc4d\", \"\u2764\ufe0f\", \"\ud83d\udd25\"];\n}\n\n// If no message ID found, throw helpful error\nif (!messageId) {\n  throw new Error(\"\u274c Please provide a Telegram message link!\\n\\nExample:\\nhttps://t.me/n8nTesterChannel/62 needs 5 reactions please\");\n}\n\n// Validate emojis\nfunction getRandomValidEmoji(exclude = []) {\n  const available = validEmojis.filter(e => !exclude.includes(e));\n  return available[Math.floor(Math.random() * available.length)];\n}\n\nconst uniqueEmojis = [...new Set(emojis)];\nconst allowDuplicates = uniqueEmojis.length <= 3;\n\nconst requestedCount = emojis.length;\nconst validatedEmojis = [];\nconst usedEmojis = new Set();\n\nfor (let emoji of emojis) {\n  const cleaned = emoji.trim();\n  \n  if (validEmojis.includes(cleaned)) {\n    if (allowDuplicates) {\n      validatedEmojis.push(cleaned);\n    } \n    else if (!usedEmojis.has(cleaned)) {\n      validatedEmojis.push(cleaned);\n      usedEmojis.add(cleaned);\n    } else {\n      let replacement = getRandomValidEmoji([...usedEmojis]);\n      validatedEmojis.push(replacement);\n      usedEmojis.add(replacement);\n    }\n  } else {\n    let replacement = getRandomValidEmoji([...usedEmojis]);\n    validatedEmojis.push(replacement);\n    if (!allowDuplicates) {\n      usedEmojis.add(replacement);\n    }\n  }\n}\n\nwhile (validatedEmojis.length < requestedCount) {\n  let newEmoji = getRandomValidEmoji([...usedEmojis]);\n  validatedEmojis.push(newEmoji);\n  usedEmojis.add(newEmoji);\n}\n\n// Output with message ID and chat ID\nconst output = validatedEmojis.map((emoji, index) => ({\n  emoji: emoji,\n  botToken: botTokens[index % botTokens.length],\n  chatId: chatId,\n  messageId: messageId\n}));\n\nreturn output;"
      },
      "typeVersion": 2
    },
    {
      "id": "cd448fc1-a9da-4119-b9bd-812cd7d6e521",
      "name": "Debugging",
      "type": "n8n-nodes-base.code",
      "position": [
        -96,
        832
      ],
      "parameters": {
        "jsCode": "// Debug - check what we're sending\nconst items = $input.all();\n\nconsole.log(\"Total items:\", items.length);\nitems.forEach((item, index) => {\n  console.log(`Item ${index}:`, {\n    emoji: item.json.emoji,\n    chatId: item.json.chatId,\n    messageId: item.json.messageId,\n    botToken: item.json.botToken.substring(0, 20) + \"...\" // Don't log full token\n  });\n});\n\nreturn items;"
      },
      "typeVersion": 2
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "18398cb2-0854-4f07-be6c-d78ee911d8c8",
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Reply \"all done\" message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code Prep": {
      "main": [
        [
          {
            "node": "Debugging",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Debugging": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Limit",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message a model": {
      "main": [
        [
          {
            "node": "Code Prep",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Chat Trigger": {
      "main": [
        [
          {
            "node": "Message a model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}