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
Generate Product Ad Copy & CTAs with GPT-4 for Slack and Airtable
ā” AI Copywriter Pro: Instant Ad Copy & CTA Generator Transform product details into compelling marketing copy in second...
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...
Compare Lists and Identify Common Items & Differences Using Custom Keys
This workflow compares two lists of objects (List A and List B) using a user-specified key (e.g. email, id, domain) and ...
š Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments