Can't manually enter multiple Chat ID in Telegram Node

I tried adding multiple Chat ID using , but it’s not working.

But I can manually enter Individual Chat ID.

image

Expected Use Case:

  • Here is the Sample Workflow
  • Get a List of Chat IDs from Google Sheets and put them into the Chat ID field in Telegram Node.

It’ll work as Telegram Broadcast.

image

Problem:

The limit is 30 Messages per second

Refer Docs: https://core.telegram.org/bots/faq#broadcasting-to-users

You can use a Split in Batches Node with a wait to not run into the rate-limiting.

But how can I send it to Multiple Chat IDs bro using Single Telegram Node?

I think Split in Batches works like…
Chat IDs -> Split as 30 -> Wait Node -> Telegram Node

I’m confused. Any workflow example on my use case bro?

Hey @mcnaveen!

Here is the workflow that might help. You can change the wait time by changing the value of the waitTimeSeconds variable in the Wait node. Hope this helps. :slightly_smiling_face:

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        150,
        300
      ]
    },
    {
      "parameters": {
        "chatId": "={{$node[\"SplitInBatches\"].json[\"Chat ID\"]}}",
        "text": "Hello",
        "additionalFields": {}
      },
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1,
      "position": [
        750,
        300
      ],
      "credentials": {
        "telegramApi": "telegram-bot"
      }
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "sheetId": "",
        "range": "A:A",
        "options": {}
      },
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        350,
        300
      ],
      "credentials": {
        "googleSheetsOAuth2Api": "google-sheet"
      }
    },
    {
      "parameters": {
        "batchSize": 30,
        "options": {}
      },
      "name": "SplitInBatches",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 1,
      "position": [
        560,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "const waitTimeSeconds = 30;\n\nreturn new Promise((resolve) => {\n  setTimeout(() => {\n    resolve(items);\n  }, waitTimeSeconds * 1000);\n});\n\n"
      },
      "name": "Wait",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        900,
        150
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets": {
      "main": [
        [
          {
            "node": "SplitInBatches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SplitInBatches": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "SplitInBatches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
1 Like

Let me try and update you soon bro

@harshil1712 But the above code just returns the first value only.

Do others come on loop?

You need to put an if node later and check if there is no more items in SplitInBatches (there is an option in this node to know if no more items are available) .

If no more items are available, you have to finish flow. If more items exist, you need to link true output to SplitInBatches input again.

Hope this helps.

1 Like

Hey @mcnaveen!

Let me try to explain what is happening in this workflow in more detail.

We split the incoming chat IDs in a batch of 30 (due to the limitation by the Telegram API). The Telegram node takes one Chat ID, sends a message, and then takes another Chat ID to send a message. This continues until a message has been sent to all the 30 Chat IDs that the Split In Batches return. Once, this is over, the wait node gets executed and it waits for 30 seconds (or whatever time we have set), and triggers the Split in Batches node to get the next batch of 30 Chat IDs.
This process is repeated until a message is sent to all the Chat IDs.

I hope this clear your doubt.

Also, as @Miquel_Colomer mentioned, you can add the IF node to check if all the values are fetched and execute the workflow accordingly.

1 Like