This commit is contained in:
nusquama
2025-11-12 13:07:12 +01:00
parent 87517ea5fc
commit e60ff0e3ae
@@ -0,0 +1,304 @@
Manage ClickUp Tasks with Natural Language via Telegram Bot and GPT-4.1
https://n8nworkflows.xyz/workflows/manage-clickup-tasks-with-natural-language-via-telegram-bot-and-gpt-4-1-6546
# Manage ClickUp Tasks with Natural Language via Telegram Bot and GPT-4.1
### 1. Workflow Overview
This workflow enables managing ClickUp tasks through natural language commands sent via a Telegram bot, with AI-powered interpretation using GPT-4.1. It is designed for users who want to create, update, find, or delete tasks in ClickUp without leaving Telegram. The AI agent understands user messages and performs corresponding task operations while maintaining conversational context.
The workflow is logically divided into the following blocks:
- **1.1 Input Reception and Filtering**: Receives messages from Telegram and filters out messages sent by the bot itself to prevent loops.
- **1.2 AI Processing and Memory**: Passes the user message to an AI agent powered by GPT-4.1 with memory support, which interprets commands and decides on task-related actions.
- **1.3 ClickUp Integration**: Implements task operations in ClickUp such as creating blank tasks, finding existing tasks, updating tasks, and deleting tasks based on AI agent instructions.
- **1.4 User Communication**: Sends messages back to the user on Telegram to confirm actions or request additional information.
---
### 2. Block-by-Block Analysis
#### 2.1 Input Reception and Filtering
**Overview:**
This block captures incoming messages from users via Telegram and filters out any messages originating from the bot itself to prevent recursive triggering.
**Nodes Involved:**
- Telegram Bot Receives Message
- Ignore Bot Messages
**Node Details:**
- **Telegram Bot Receives Message**
- Type: Telegram Trigger
- Role: Entry point; triggers the workflow on new Telegram messages.
- Configuration: Listens to `"message"` update types only. Uses Telegram Bot API credentials.
- Expressions: N/A
- Input: External webhook from Telegram
- Output: Message JSON payload forwarded to next node
- Failure modes: Webhook connection failures, Telegram API rate limits
- Notes: Requires Telegram Bot API credentials configured.
- **Ignore Bot Messages**
- Type: If (conditional) node
- Role: Filters out messages sent by the bot itself to avoid infinite loops.
- Configuration: Checks if the telegram messages `reply_to_message.from.id` is NOT equal to the bots user ID (must be provided manually).
- Expressions: Compares `{{$json.message.reply_to_message.from.id}}` to the configured bot ID (e.g., `8453959426`).
- Input: Output from Telegram trigger
- Output: Passes only messages not from the bot to the AI agent node
- Edge cases: If bot ID is misconfigured, infinite loops may occur; messages without `reply_to_message` property may cause evaluation issues.
- Notes: Requires manual setup of the bots user ID.
---
#### 2.2 AI Processing and Memory
**Overview:**
This block interprets the user's natural language command using an AI agent enhanced with conversational memory, then selects appropriate task operation tools.
**Nodes Involved:**
- Simple Memory
- OpenAI Chat Model1
- AI Agent: Create Task or Follow Up
**Node Details:**
- **Simple Memory**
- Type: LangChain Memory Buffer (Window)
- Role: Maintains conversational context per Telegram chat session.
- Configuration: Uses the Telegram chat ID (`$json.message.chat.id`) as the session key and ID.
- Input: Message JSON from filter node
- Output: Passes enriched context to AI Agent
- Edge cases: Memory overflow or session key conflicts unlikely but possible.
- **OpenAI Chat Model1**
- Type: LangChain OpenAI Chat Model
- Role: Provides GPT-4.1-mini language model as the AI engine.
- Configuration: Model set to `gpt-4.1-mini`, no additional options configured. Uses OpenAI API credentials.
- Input: Receives prompt and context from Simple Memory, outputs AI-generated text.
- Output: Passed to AI Agent for decision making.
- Failure modes: API quota exceeded, network timeouts, invalid credentials.
- **AI Agent: Create Task or Follow Up**
- Type: LangChain Agent Node
- Role: Core decision node running AI agent logic to parse user commands and orchestrate task operations.
- Configuration:
- Passes current datetime (with timezone America/Toronto, offset by -1 day) and user first name as context.
- System message instructs the agent with detailed instructions on creating, updating, deleting, or finding tasks in ClickUp, plus communicating with the user via Telegram.
- Uses multiple tools including the Telegram communication node and ClickUp tools for task CRUD operations.
- Input: AI model output and memory context
- Output: Triggers ClickUp task nodes and Telegram communication nodes via AI tools interface.
- Edge cases: Misinterpretation of commands, missing task IDs, ambiguous user inputs, API call failures.
- Notes: Critical to keep system message updated for accurate AI behavior.
---
#### 2.3 ClickUp Integration
**Overview:**
This block implements task management CRUD operations in ClickUp based on AI agent instructions.
**Nodes Involved:**
- Create A Blank Task in ClickUp
- Find a Task in ClickUp
- Update a Task in ClickUp
- Delete a task in ClickUp
**Node Details:**
- **Create A Blank Task in ClickUp**
- Type: ClickUp Tool
- Role: Creates a new task with a generic name, returns task ID for updating later.
- Configuration: Uses OAuth2 for authentication; requires workspace IDs (team, space, folder, list). Task name set to `"New Task"` as placeholder.
- Input: Triggered by AI Agent tool command
- Output: Task ID forwarded for subsequent update
- Edge cases: OAuth token expiry, invalid workspace IDs, API rate limits.
- Sticky note: Warns that task name cannot be set at creation time and must be updated separately.
- **Find a Task in ClickUp**
- Type: ClickUp Tool
- Role: Retrieves existing tasks to find task ID by name or filter.
- Configuration: Uses OAuth2 credential and workspace IDs; operation set to get all tasks possibly filtered by AI.
- Input: AI Agent tool command
- Output: Task list JSON for agent use
- Edge cases: API pagination, large result sets, filter misconfiguration.
- **Update a Task in ClickUp**
- Type: ClickUp Tool
- Role: Updates task details such as name, status, content, due date, priority, etc.
- Configuration: Uses OAuth2; task ID and update fields dynamically populated via AI agent outputs.
- Input: AI Agent tool command with task ID and update fields
- Output: Confirmation of update
- Edge cases: Invalid task ID, field validation errors, concurrent updates.
- **Delete a task in ClickUp**
- Type: ClickUp Tool
- Role: Deletes a task permanently from ClickUp.
- Configuration: Uses OAuth2; task ID dynamically provided by AI agent.
- Input: AI Agent tool command
- Output: Confirmation or failure message
- Edge cases: Accidental deletion, lack of confirmation, permission errors.
- Sticky note: Strong caution about permanent deletion, recommends disabling during testing.
---
#### 2.4 User Communication
**Overview:**
This block sends Telegram messages back to the user to confirm task operations or request further details, maintaining an interactive conversational flow.
**Nodes Involved:**
- Communicate with User
- Send User Confirmation Message
**Node Details:**
- **Communicate with User**
- Type: Telegram Tool
- Role: Used by the AI agent to send messages to the user for clarifications or info.
- Configuration: Sends text from AI agent; replies to the original user message; uses Telegram Bot API credential.
- Input: AI agent tool command
- Output: Telegram message sent
- Edge cases: Message delivery failures, rate limits, invalid chat IDs.
- **Send User Confirmation Message**
- Type: Telegram Tool
- Role: Notifies user after task creation or updates are done in ClickUp.
- Configuration: Sends confirmation text generated by AI; replies to the original user message.
- Input: AI agent tool command
- Output: Telegram message sent
- Edge cases: Same as above.
---
### 3. Summary Table
| Node Name | Node Type | Functional Role | Input Node(s) | Output Node(s) | Sticky Note |
|-------------------------------|-----------------------------------------|-----------------------------------------|------------------------------|------------------------------|----------------------------------------------------------------------------------------------|
| Telegram Bot Receives Message | Telegram Trigger | Entry point: receive incoming Telegram messages | N/A | Ignore Bot Messages | |
| Ignore Bot Messages | If | Filter out messages sent by the bot itself | Telegram Bot Receives Message | AI Agent: Create Task or Follow Up | ⚠️ Warning: Prevent infinite loops by configuring bot user ID |
| Simple Memory | LangChain Memory Buffer | Maintain conversational context per chat | Ignore Bot Messages | AI Agent: Create Task or Follow Up | |
| OpenAI Chat Model1 | LangChain OpenAI Chat Model | Provides GPT-4.1-mini AI model | Simple Memory | AI Agent: Create Task or Follow Up | |
| AI Agent: Create Task or Follow Up | LangChain Agent Node | Core AI logic: interpret commands & execute task operations | Ignore Bot Messages, Simple Memory, OpenAI Chat Model1 | Create A Blank Task in ClickUp, Find a Task in ClickUp, Update a Task in ClickUp, Delete a task in ClickUp, Communicate with User, Send User Confirmation Message | |
| Create A Blank Task in ClickUp | ClickUp Tool | Create new task with placeholder name | AI Agent: Create Task or Follow Up | AI Agent: Create Task or Follow Up | 📌 ClickUp Setup: Must configure workspace, folder, list IDs |
| Find a Task in ClickUp | ClickUp Tool | Retrieve tasks to find existing task ID | AI Agent: Create Task or Follow Up | AI Agent: Create Task or Follow Up | 📌 ClickUp Setup: Must configure workspace, folder, list IDs |
| Update a Task in ClickUp | ClickUp Tool | Update task details | AI Agent: Create Task or Follow Up | AI Agent: Create Task or Follow Up | 📌 ClickUp Setup: Must configure workspace, folder, list IDs |
| Delete a task in ClickUp | ClickUp Tool | Permanently delete task | AI Agent: Create Task or Follow Up | AI Agent: Create Task or Follow Up | ⚠️ Caution: Deletion is permanent; disable if unsure or testing |
| Communicate with User | Telegram Tool | Send messages to user for info or clarifications | AI Agent: Create Task or Follow Up | AI Agent: Create Task or Follow Up | |
| Send User Confirmation Message | Telegram Tool | Notify user of task creation or updates | AI Agent: Create Task or Follow Up | N/A | |
| Sticky Note | Sticky Note | Documentation and instructions | N/A | N/A | Contains detailed workflow description and setup instructions |
| Sticky Note1 | Sticky Note | Warning message for Ignore Bot Messages node | N/A | N/A | ⚠️ Warning: Configure bot user ID to prevent infinite loops |
| Sticky Note4 | Sticky Note | ClickUp workspace setup reminder | N/A | N/A | 📌 ClickUp Setup: Configure workspace, folder, list IDs |
| Sticky Note5 | Sticky Note | Caution about Delete node | N/A | N/A | ⚠️ Caution: Delete node permanently deletes tasks; disable during testing |
---
### 4. Reproducing the Workflow from Scratch
1. **Create Telegram Trigger Node**
- Type: Telegram Trigger
- Set `updates` to listen for `"message"` only.
- Add Telegram API credentials (Telegram Bot API token).
- Position: Start of workflow.
2. **Add If Node to Filter Bot Messages**
- Type: If
- Condition: Check that `{{$json.message.reply_to_message.from.id}}` is NOT equal to your Telegram bots user ID (numeric).
- This avoids processing messages sent by the bot itself.
- Connect Telegram Trigger node output to this node input.
3. **Add LangChain Memory Buffer Node**
- Type: LangChain Memory Buffer (Window)
- Set session key and session ID to `{{$json.message.chat.id}}` to track conversation per chat.
- Connect the 'true' output of the If node (messages not from bot) to this node input.
4. **Add LangChain OpenAI Chat Model Node**
- Type: LangChain OpenAI Chat Model
- Select model: `gpt-4.1-mini` or equivalent GPT-4.1 variant.
- Add OpenAI API credentials.
- Connect Memory node output to this model node.
5. **Add LangChain Agent Node**
- Type: LangChain Agent Node
- Configure the prompt with:
- Current datetime in America/Toronto timezone minus 1 day.
- User first name from `{{$json.message.chat.first_name}}`.
- User message text from `{{$json.message.text}}`.
- Add detailed system instructions to:
- Create, update, delete, and find tasks in ClickUp.
- Use Telegram tool to communicate with user.
- Connect OpenAI Chat Model and Memory node outputs as inputs to this node.
- Connect the 'true' output of the If node to this node as well for filtered messages.
6. **Add ClickUp Tool Node to Create Blank Task**
- Type: ClickUp Tool
- Operation: Create task with name `"New Task"` (placeholder).
- Configure team, space, folder, and list IDs matching your ClickUp workspace.
- Add ClickUp OAuth2 credentials.
- Connect this node as an AI tool in the Agent node configuration.
7. **Add ClickUp Tool Node to Find a Task**
- Type: ClickUp Tool
- Operation: Get all tasks for searching.
- Use same workspace IDs and OAuth2 credentials.
- Connect as AI tool in Agent node.
8. **Add ClickUp Tool Node to Update a Task**
- Type: ClickUp Tool
- Operation: Update task fields (name, status, content, due date, priority).
- Use dynamic fields populated by AI agent outputs.
- Use same workspace IDs and OAuth2 credentials.
- Connect as AI tool in Agent node.
9. **Add ClickUp Tool Node to Delete a Task**
- Type: ClickUp Tool
- Operation: Delete task by ID provided by AI agent.
- Use same workspace IDs and OAuth2 credentials.
- Connect as AI tool in Agent node.
- Caution: This node permanently deletes tasks; disable or remove during testing.
10. **Add Telegram Tool Node to Communicate with User**
- Type: Telegram Tool
- Used for sending messages to user (clarifications or info).
- Set `chatId` to `{{$json.message.chat.id}}`.
- Configure to reply to the original message (`reply_to_message_id`).
- Add Telegram API credentials.
- Connect as AI tool in Agent node.
11. **Add Telegram Tool Node to Send User Confirmation Message**
- Type: Telegram Tool
- Used to send confirmation after task creation or update.
- Set `chatId` and reply message as above.
- Add Telegram API credentials.
- Connect as AI tool in Agent node.
12. **Add Connections to AI Agent Node**
- Configure AI tools for the agent node to include all ClickUp nodes and Telegram tool nodes for communication.
- Connect outputs from Telegram filtering and LangChain nodes into the AI agent node.
13. **Add Sticky Notes (Optional)**
- Add sticky notes with key instructions for setup and usage, including:
- Bot ID configuration warning for Ignore Bot Messages node.
- ClickUp workspace and folder ID reminders in task nodes.
- Caution about the delete nodes permanent effect.
---
### 5. General Notes & Resources
| Note Content | Context or Link |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------|
| The workflow enables natural language task management in ClickUp using Telegram and GPT-4.1, streamlining task operations without switching apps. | Workflow purpose description |
| Before first use, add your bots Telegram user ID to the `Ignore Bot Messages` node to prevent infinite loops caused by the bot responding to itself. | Setup instruction in sticky note and node documentation |
| Ensure all ClickUp workspace, folder, list, and team IDs are correctly set in the ClickUp nodes to prevent API errors. | Sticky Note4 content |
| The Delete task node permanently deletes tasks; disable or remove this node during testing phases to avoid data loss. | Sticky Note5 caution |
| Use the AI agents system message to customize or extend supported commands — e.g., adding support for comments or time tracking in ClickUp. | AI Agent prompt configuration |
| For Telegram Bot creation and credentials setup, use BotFather and n8ns credential management interface. | Telegram Bot official docs |
| OpenAI GPT-4.1-mini model powers the natural language understanding, requiring a valid OpenAI API key. | OpenAI API documentation |
| ClickUp OAuth2 credentials require configuring an OAuth2 app in ClickUp and authorizing the n8n workflow accordingly. | ClickUp API and OAuth2 setup guides |
---
**Disclaimer:** The text provided is exclusively derived from an automated workflow created with n8n, an integration and automation tool. This processing strictly respects current content policies and contains no illegal, offensive, or protected elements. All data handled are legal and public.