Skip to main content

Telegram AI assistant with rate limiting and auto-reset using Google Sheets

Workflow preview

Workflow preview
100%
Telegram AI assistant with rate limiting and auto-reset using Google Sheets preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Production ready solution for controlling AI agent usage and preventing abuse while managing costs. Problem Solved Unlimited AI interactions → Excessive API costs Service abuse → Uncontrolled re...

Best for

  • AI Chatbot automation workflows
  • Multimodal AI automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

@n8n/n8n-nodes-langchain.agent, n8n-nodes-base.code, n8n-nodes-base.googlesheets, @n8n/n8n-nodes-langchain.lmchatazureopenai, n8n-nodes-base.scheduletrigger, n8n-nodes-base.stickynote, n8n-nodes-base.switch, n8n-nodes-base.noop

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Oussama.

Original n8n.io source

1.1 Workflow description

Title
Telegram AI assistant with rate limiting and auto-reset using Google Sheets
Workflow name
Telegram AI assistant with rate limiting and auto-reset using Google Sheets

Production-ready solution for controlling AI agent usage and preventing abuse while managing costs.

🎯 Problem Solved

Unlimited AI interactions → Excessive API costs Service abuse → Uncontrolled resource consumption No built-in limits → Need for usage quotas

Solution Overview

Two-Part System:

Main Flow: User interaction tracking + AI responses Reset Flow: Automated counter resets

🔄 How It Works

User Message → Track Counter → Check Limit → Allow/Block → AI Response

🛠️ Core Components

Main Workflow

📱 Telegram Trigger - Receives user messages 📊 Google Sheets Counter - Tracks messages per user 🔀 Switch Logic - Checks limits (default: 3 messages) 🤖 AI Agent - Processes allowed interactions 💬 Smart Responses - Delivers AI answers or limit warnings

Auto-Reset System

⏰ Schedule Trigger - Runs every configurable interval 🔄 Bulk Counter Reset - Resets all users to 0

⚙️ Configuration

Message Limits Modify Switch Node conditions:

> 3 messages → Block silently = 3 messages → Send limit warning < 3 messages → Allow AI response

Reset Schedules

Testing: Every 1 minute Hourly: 0 * * * * Daily: 0 0 * * * Weekly: 0 0 * * 0

📋 Setup Requirements

Credentials Needed:

🤖 Telegram Bot Token 📊 Google Sheets API 🧠 AI Model

*Google Sheets Structure: *Column A: User ID (Telegram chat.id) Column B: Message Counter

🎯 Perfect For

💰 Cost Control - Prevent runaway API costs 🛡️ Demo/Trial Bots - Limited interactions 🏢 Customer Service - Usage quotas 🎓 Educational Bots - Daily limits 🚫 Anti-Abuse - Fair usage policies

🚀 Key Benefits ✅ Cost Management - Control AI API expenses ✅ Fair Access - Equal usage for all users ✅ Production Ready - Robust error handling ✅ Flexible Limits - Easy adjustment ✅ Auto-Reset - No manual intervention ✅ User-Friendly - Clear limit messages

📝 Quick Customization

Adjust Limits: Change Switch node values Reset Timing: Modify Schedule Trigger Custom Messages: Edit Telegram response nodes User Tiers: Add columns to Google Sheets

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 1.7

Block 2 - Code

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 3 - Append or update row in sheet

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.6

Block 4 - Get row(s) in sheet

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.6

Block 5 - Append or update row in sheet1

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.6

Block 6 - Azure

Type / Role
@n8n/n8n-nodes-langchain.lmChatAzureOpenAi - lmChatAzureOpenAi
Config choices
Version 1

Block 7 - Schedule Trigger

Type / Role
n8n-nodes-base.scheduleTrigger - scheduleTrigger
Config choices
Version 1.2

Block 8 - Get row(s) in sheet1

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.7

Block 9 - Update row in sheet

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.7

Block 10 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 11 - Switch

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3.2

Block 12 - No Operation

Type / Role
n8n-nodes-base.noOp - noOp
Config choices
Version 1

Block 13 - Limit Message

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 14 - Agent Answer

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 15 - Telegram

Type / Role
n8n-nodes-base.telegramTrigger - telegramTrigger
Config choices
Version 1.2

Block 16 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 17 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 18 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 19 - Memory

Type / Role
@n8n/n8n-nodes-langchain.memoryBufferWindow - memoryBufferWindow
Config choices
Version 1.3

3. Summary Table

Workflow Telegram AI assistant with rate limiting and auto-reset using Google Sheets
Complexity advanced
Nodes 19
Categories AI Chatbot, Multimodal AI
Author Oussama
Published 25 Aug 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/7834/7834.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Telegram AI assistant with rate limiting and auto-reset using Google Sheets do?

Production ready solution for controlling AI agent usage and preventing abuse while managing costs. Problem Solved Unlimited AI interactions → Excessive API costs Service abuse → Uncontrolled re...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your AI Chatbot, Multimodal AI use case.