Secure Telegram Group Entry with Math CAPTCHA and Data Management - n8n Workflow

Automate Telegram group security using this robust n8n workflow. New members face a math CAPTCHA challenge, storing verification state in Google Sheets to block bots. Explore this n8n template.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Telegram group administrators seeking to combat bot spam.
Users needing a customizable security layer implemented with a powerful n8n node structure.
Automation specialists looking for advanced n8n templates involving stateful logic (using Google Sheets).
Developers who require a reliable n8n trigger to monitor group events.

Overview

Bot protection is crucial for maintaining healthy online communities. This specialized n8n workflow provides an elegant and effective solution for securing Telegram groups against automated joiners. By utilizing the Telegram n8n node and leveraging Google Sheets as a temporary database, every new member is immediately challenged with a randomly generated math CAPTCHA. This specific n8n workflow ensures that only human users who successfully submit the correct answer within the chat are allowed to remain. If verification fails, the user is automatically banned via an HTTP request, providing a robust, self-cleaning solution. This entire automation demonstrates the powerful capabilities of defining complex, stateful flows using an n8n node structure, offering far more than basic n8n templates.

How it Works

The entire process is initiated by the n8n trigger for Telegram events.


  1. Trigger & Setup: The ๐Ÿ“ฑ Telegram Trigger n8n trigger listens for group updates. The โš™๏ธ Bot Configuration n8n node sets necessary variables.

  2. Initial Check: The ๐Ÿ” Check New Member n8n node determines if the event is a user joining the group (Path A) or a message from a current user (Path B).

  3. Path A: New Member Verification:

The ๐ŸŽฒ Generate CAPTCHA Question Code n8n node creates a unique math problem and calculates the answer.
The โ“ Send CAPTCHA Question n8n node sends the challenge to the new member.
Cleanup is performed using the ๐Ÿ—‘๏ธ Delete Join Message n8n node.
The user's ID and the correct answer are stored temporarily via the ๐Ÿ’พ Store User Answer Google Sheets n8n node.

  1. Path B: Response Verification (User attempts CAPTCHA):

The ๐Ÿ“‹ Find Pending CAPTCHA Google Sheets n8n node retrieves the required answer for the user.
The โœ… Verify Answer n8n node compares the user's message content to the stored answer.

  1. Success: If verified, the n8n workflow continues to ๐ŸŽ‰ Welcome New Member, deletes the user's data from Google Sheets using ๐Ÿ—‘๏ธ Clean User Data (Success), and performs message cleanup.

  2. Failure: If the answer is incorrect, the Create URL for banrequest n8n node prepares the API call, and the ๐Ÿšซ Ban User (Failed CAPTCHA) HTTP Request n8n node executes the permanent ban. The associated messages are cleaned up.

Installation Guide

To deploy this comprehensive n8n workflow, follow these steps:


  1. Import: Copy the provided n8n workflow JSON data and paste it into your n8n instance using the 'New' -> 'Import from JSON' option.

  2. Telegram Credentials: Ensure you have configured a Telegram Bot credential. Apply this credential to the ๐Ÿ“ฑ Telegram Trigger and all subsequent Telegram n8n node operations.

  3. Google Sheets Setup: Create a dedicated Google Sheet to store pending CAPTCHA details (User ID, Correct Answer). Configure the required Google Sheets credential and apply it to the ๐Ÿ’พ Store User Answer, ๐Ÿ“‹ Find Pending CAPTCHA, and ๐Ÿ—‘๏ธ Clean User Data (Success) n8n nodes.

  4. Configuration Node: Update the โš™๏ธ Bot Configuration n8n node with your specific Telegram Group Chat ID and other required variables.

  5. Activation: Save the n8n workflow and activate it by toggling the 'Active' switch. The n8n trigger will immediately begin monitoring your specified Telegram group.

Node Details

๐Ÿ“ฑ Telegram Trigger (n8n trigger): The entry point of this n8n workflow. It is configured to listen for new events within the monitored Telegram group, including new member joins and chat messages.
โš™๏ธ Bot Configuration (Set n8n node): Essential for initializing global variables, such as the target chat ID and the base Telegram API URL needed for manual banning requests, enhancing the flexibility of this n8n template.
๐ŸŽฒ Generate CAPTCHA Question (Code n8n node): Executes custom JavaScript to randomly generate two numbers and an arithmetic operation, storing the calculated result for later verification.
๐Ÿ’พ Store User Answer / ๐Ÿ“‹ Find Pending CAPTCHA (Google Sheets n8n node): These nodes manage the state. The first adds the required answer to the sheet; the second retrieves it when the user replies, forming a crucial part of the verification logic in this n8n workflow.
โœ… Verify Answer (If n8n node): The core logic control that compares the input received from the user via the n8n trigger against the correct answer retrieved from Google Sheets. Based on this comparison, the n8n workflow branches.
๐Ÿšซ Ban User (Failed CAPTCHA) (HTTP Request n8n node): Since direct banning might not be exposed easily in the standard Telegram n8n node, this uses a raw HTTP call to the Telegram Bot API to ensure immediate removal of failed users.

Related n8n Workflows

Paid

Nodes: 8 Nodes
Updated: December 26 2025
View all
Created by

Automating what you hate doing.

Featured*