Gestión dinámica de datos con control de permisos
El sistema recibe mensajes vía webhook de Telegram, extrae el chat ID y consulta Airtable para verificar permisos. Con esta información, genera un *prompt* que incluye el permiso de escritura, el nombre del usuario y su consulta. El agente responde según
Gestión dinámica de datos con control de permisos
🧩 Overview
This workflow automates the process of managing a product database via a Telegram chat interface with dynamic permission control. It receives a user's message via a Telegram webhook, verifies their administrative permissions from an Airtable user database, and then routes their request to an AI agent. The agent, equipped with specific tools, can perform read, create, update, or delete operations on a product Airtable base, but only if the user has the appropriate write permissions. The final response is sent back to the user on Telegram.
⚙️ Main Features
- Processes incoming user requests from a Telegram chat.
- Dynamically checks user permissions from an Airtable database before processing requests.
- Utilizes an AI agent to interpret natural language and execute appropriate database operations (CRUD).
- Enforces a permission-based security model, allowing write actions only for authorized users.
- Sends structured, AI-generated responses back to the user via Telegram.
🔄 Workflow Steps
| Component Name | Role in the Workflow | Key Inputs | Key Outputs |
|---|---|---|---|
| Telegram Webhook | Receives the initial user message and metadata from Telegram. | Incoming Telegram message data. | Structured message data and raw message text. |
| Parse Data (chat id) | Extracts the user's unique chat ID from the incoming webhook data. | Raw webhook data. | Formatted chat ID. |
| Airtable (tabla de usuarios) | Queries the user database to retrieve the user's profile and permissions based on their chat ID. | Chat ID for filtering. | User record data, including admin permissions. |
| Parse Data (permiso de escritura) | Extracts the user's specific write permission flag from the user record data. | User record data. | Formatted write permission status. |
| Parse Data (nombre de usuario) | Extracts the user's name from the user record data. | User record data. | Formatted username. |
| Prompt | Constructs the final instruction for the AI agent by combining the user's permission status, username, and original message. | Write permission, username, and original user message. | A structured prompt for the agent. |
| Google Generative AI Model | Provides the core language model that powers the reasoning and decision-making of the AI agent. | Model configuration (e.g., Gemini 2.5 Flash). | A configured language model instance. |
| Airtable (leer) | Serves as a tool for the agent to read records from the product database. | Configured as a tool. | Tool interface for reading data. |
| Airtable (crear) | Serves as a tool for the agent to create new records in the product database. | Configured as a tool. | Tool interface for creating data. |
| Airtable (actualizar) | Serves as a tool for the agent to update existing records in the product database. | Configured as a tool. | Tool interface for updating data. |
| Airtable (borrar) | Serves as a tool for the agent to delete records from the product database. | Configured as a tool. | Tool interface for deleting data. |
| Advanced Agent | The central AI agent that interprets the user's request, selects the correct tool based on intent and permissions, and formulates a response. | System prompt, user prompt, language model, and available Airtable tools. | A text response answering the user's query or confirming the action taken. |
| Telegram Message | Sends the agent's final response back to the user in the original Telegram chat. | Text response from the agent. | Message sent to the Telegram user. |
🧠 Notes
- The workflow's security is based on the
Permisos de administradorfield in the user Airtable. The agent's system prompt explicitly instructs it to only perform write operations if this permission is granted. - The agent is configured with a specific system prompt that defines its role, the permission rules, and the expected response format.
- All Airtable components are configured in "Tool Mode," making them available for the agent to use dynamically based on the conversation.
- The workflow assumes pre-configured and valid API credentials for Telegram and Airtable services.
- User identification and permission filtering rely on a matching
chatidfield in the Telegram message and the Airtable user table.