Block 1 - Agent
- Type / Role
- @n8n/n8n-nodes-langchain.agent - agent
- Config choices
- Version 1.7
This workflow is provided as-is. Please review and test before using in production.
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...
@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
This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Oussama.
Original n8n.io sourceProduction-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
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.
| 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 |
Use the JSON export at /data/workflows/7834/7834.json as the source template for this automation.
Open n8n, import the downloaded JSON, and review each node before activating the workflow.
Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.
Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.
Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.
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.
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...
Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.
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.