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
Related Templates
Instagram Full Profile Scraper with Apify and Google Sheets
šø Instagram Full Profile Scraper with Apify and Google Sheets This n8n workflow automates the process of scraping ful...
Technology News Workflow Explanation with Key Services
This workflow contains community nodes that are only compatible with the self-hosted version of n8n. Auto-Publish Techn...
Auto-classify Gmail emails with AI and apply labels for inbox organization
Who is this for? Professionals and individuals who receive high volumes of emails, those who want to automatically organ...
š Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments