Multi-Model AI Chatbot with Telegram and Usage Limits - n8n Workflow

Use this powerful n8n workflow to create a Telegram chatbot integrating multiple AI models via AIMLAPI, complete with daily usage limits tracked in Google Sheets.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Developers looking for advanced n8n templates to deploy serverless AI chatbots.

  • Bot Administrators needing a simple way to manage and track user usage via Google Sheets.

  • AI Enthusiasts wanting to provide multi-model access (like GPT-4o) through a seamless Telegram interface.

  • Teams that require a controlled, cost-effective way to offer AI generation services.

Overview

Managing AI usage and providing access to various models often requires complex infrastructure. This comprehensive n8n workflow simplifies the entire process. It transforms a standard Telegram bot into a sophisticated AI access point using AIMLAPI, allowing users to select their desired model using a hashtag (e.g., #openai/gpt-4o).

The core value of this specific n8n workflow lies in its built-in governance: it utilizes the Google Sheets node to track daily requests per user and enforces a strict daily limit (default 5). This prevents unexpected costs and ensures fair usage. By analyzing this powerful n8n template, users can customize the daily limits and easily add new functionalities, making it a foundation for many practical AI automation projects.

How it Works

This n8n workflow initiates every time a user sends a message to the integrated Telegram bot, starting with the n8n trigger.


  1. Receive Message: The 📩 Receive Telegram Message n8n trigger captures the incoming text.

  2. Command Check: The Get Models Or Process Message? switch node routes the flow. If the user sends /models, the workflow fetches the current list of available models from the AIMLAPI via the HTTP Request n8n node, processes them, and sends a formatted list back.

  3. Usage Validation: If it’s a standard message, the flow proceeds to usage checking. The 📊 Fetch Usage Logs Google Sheets n8n node retrieves all entries for the current user and current date.

  4. Limit Enforcement: The request count is aggregated, compared against the limit defined in the 🔢 Set Daily Limit n8n node, and the 🚦 Check Limit Exceeded? If n8n node determines if processing can continue.

  5. AI Generation: If the limit is not exceeded, the workflow checks for a custom model selection (e.g., starting with #). If a custom model is found, the 🧠 Generate Msg (AI/ML API | Custom Model) n8n node is used. Otherwise, a default model (GPT-4o in this case) is used.

  6. Response & Logging: The AI response is sent back to the Telegram chat using a Telegram n8n node. Finally, the 📝 Log Successful Generation Google Sheets n8n node logs the user ID, query, and result for future usage tracking, completing the execution of this n8n workflow.

Installation Guide

To deploy this expert n8n workflow, follow these setup steps:


  1. Import: Copy the entire JSON code and import it directly into your n8n instance as a new workflow.

  2. Telegram Credentials: Set up a new Telegram API credential using the token provided by BotFather. Link this credential to the 📩 Receive Telegram Message n8n trigger and all Telegram action nodes.

  3. AIMLAPI Credentials: Create a new AIMLAPI credential within n8n, ensuring you use your API key for secure communication with the AI models.

  4. Google Sheets Setup: Create a new Google Sheet (or use the one referenced in the n8n templates notes) with the headers: user_id, date, query, and result. Ensure the Google Sheets n8n node has the necessary OAuth or Service Account permissions to read and append data to this spreadsheet.

  5. Activate: Save the n8n workflow and activate the 📩 Receive Telegram Message n8n trigger. Ensure the associated webhook is correctly configured in Telegram's settings, linking it to your n8n instance.

Node Details

📩 Receive Telegram Message (n8n trigger): This is the crucial starting point, acting as the primary n8n trigger. It listens for message updates from the configured Telegram bot, initiating the entire n8n workflow.
Get Models Or Process Message? (Switch n8n node): Directs the flow based on message content. It checks if the user requested the /models list or a standard prompt.
📊 Fetch Usage Logs (Google Sheets n8n node): Queries the usage spreadsheet, filtering rows by the user's ID and the current date to determine their generation history for limit checking.
🚦 Check Limit Exceeded? (If n8n node): Compares the user's request count (aggregated by the preceding n8n node) against the limit set in the workflow. It decides whether to proceed with AI generation or send a notification.
Group Models By Providers (Code n8n node): Parses the incoming Telegram message text, extracting the custom model_id (e.g., openai/gpt-4o) specified after the initial # symbol, and separates it from the actual prompt message.
🧠 Generate Msg (AI/ML API | Custom Model/GPT-4o) (AIMLAPI n8n node): The core AI processing n8n node. It sends the parsed prompt to the AIMLAPI service, utilizing either a default or user-specified model, depending on the flow path.


  • 📝 Log Successful Generation1 (Google Sheets n8n node): Appends a new row to the usage sheet upon successful AI generation, recording the user activity and the result to maintain accurate usage statistics for this n8n workflow.

Related n8n Workflows

Free

Nodes: 11 Nodes
Updated: December 26 2025
View all

Featured*