Files
nusquama 9c56f7371e creation
2025-11-12 19:15:45 +01:00

241 lines
15 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Auto-Ticket Maker: Convert Slack Conversations into Structured Project Tickets
https://n8nworkflows.xyz/workflows/auto-ticket-maker--convert-slack-conversations-into-structured-project-tickets-4153
# Auto-Ticket Maker: Convert Slack Conversations into Structured Project Tickets
---
### 1. Workflow Overview
This workflow, titled **Auto-Ticket Maker: Convert Slack Conversations into Structured Project Tickets**, automates the transformation of Slack messages into detailed project management tickets. It is designed for teams that want to streamline task creation by leveraging AI to structure and break down conversations into actionable epics and tickets.
The workflow is logically divided into these blocks:
- **1.1 Input Reception:** Captures incoming Slack messages via webhook and extracts relevant message details.
- **1.2 AI Processing & Memory:** Uses an AI agent integrated with OpenAIs GPT-4 to analyze the message, request clarifications if needed, and break down the project into epics and tickets. It also maintains conversation context using a memory buffer.
- **1.3 Output Posting:** Sends the AI-generated structured tickets back to the designated Slack channel.
- **1.4 Informational Sticky Notes:** Provides user guidance, branding, and support information for users of the workflow.
---
### 2. Block-by-Block Analysis
#### 2.1 Input Reception
**Overview:**
This block receives Slack event payloads through a webhook, processes the incoming data to extract and reformat key information about the Slack message, such as user, channel, text content, and threading details.
**Nodes Involved:**
- Webhook
- Code
**Node Details:**
- **Webhook**
- *Type & Role:* HTTP POST webhook node; entry point receiving Slack event payloads.
- *Configuration:* Listens on path `slack-ticket-maker` with POST method. No authentication or special options configured.
- *Input/Output:* Receives full Slack event JSON from Slacks Events API or webhook integration. Outputs raw payload to next node.
- *Edge Cases:* Missing or malformed payloads may cause failures; no explicit validation. Slack retries may cause duplicates if not idempotent.
- *Version:* v2
- **Code**
- *Type & Role:* JavaScript code node; extracts and restructures Slack event payload to a simplified format for downstream processing.
- *Configuration:*
- Extracts nested Slack event from `body[""]` (likely a placeholder or error in code, see remarks below).
- Builds a new JSON object containing user, channel, cleaned text (removes Slack user mentions), team, timestamp, and threading info.
- *Expressions/Variables:* Uses `$input.all()[0]` to access raw webhook input. Uses `.replace(/<@U.*?>/, "")` regex to strip user mentions from text.
- *Input:* Raw webhook JSON.
- *Output:* Reformatted JSON with clean Slack message details under `slack` key.
- *Edge Cases:* The code references `body[""]` which appears to be an empty string key—this may cause runtime errors if the structure differs; requires validation or fix. Also, if `thread_ts` is missing, sets thread_id to `"main"`.
- *Version:* v2
---
#### 2.2 AI Processing & Memory
**Overview:**
This block uses OpenAIs GPT-4 model via Langchain nodes to analyze the Slack message, maintain conversational state for follow-ups, and generate detailed project tickets structured as markdown code blocks.
**Nodes Involved:**
- OpenAI Chat Model
- Simple Memory
- AI PM Wellington (Agent)
**Node Details:**
- **OpenAI Chat Model**
- *Type & Role:* Language model node interfacing with OpenAIs GPT-4.1 for text generation.
- *Configuration:* Model explicitly set to `gpt-4.1`. No special options enabled.
- *Credentials:* Uses pre-configured OpenAI API credentials.
- *Input:* Receives prompt and context from AI agent.
- *Output:* AI-generated text responses.
- *Edge Cases:* API rate limits, authentication errors, or network failures may interrupt processing. Model versioning requires n8n version supporting `@n8n/n8n-nodes-langchain.lmChatOpenAi` v1.2 or higher.
- **Simple Memory**
- *Type & Role:* Langchain memory buffer node maintaining a sliding window of past conversation exchanges to provide context.
- *Configuration:*
- Uses a custom session key composed of Slack channel and user IDs to isolate conversations by user and channel.
- Session key expression: `"slack_{{$json['slack']['channel']}}_user_{{$json['slack']['user']}}"`
- *Input:* Conversation exchanges from AI agent.
- *Output:* Provides memory context back to AI agent node.
- *Edge Cases:* Memory size limits may truncate older context. If session key is malformed or missing, context may be lost.
- **AI PM Wellington (Agent)**
- *Type & Role:* Langchain agent node orchestrating the AI prompt flow, including interactive questioning and ticket creation logic.
- *Configuration:*
- Prompt instructs the AI to:
- Evaluate task complexity from Slack message text.
- Request project name and up to two rounds of clarification if needed before generating tickets.
- Break down tickets into epics and subtasks with specified sections (title, description, objectives, acceptance criteria, etc.).
- Format output as markdown code blocks for each ticket.
- Always send messages back to Slack channel.
- Prompt includes detailed bullet-point sections to standardize ticket content.
- *Input:* Reformatted Slack message JSON and memory context.
- *Output:* Structured markdown tickets.
- *Edge Cases:* Complex or ambiguous messages may trigger multiple clarification cycles. Misinterpretation by AI could yield incomplete tickets. Network/API failures affect response generation.
- *Version:* Requires Langchain agent support v1.8 or higher.
---
#### 2.3 Output Posting
**Overview:**
Posts the generated tickets back into a specified Slack channel to share with the team.
**Nodes Involved:**
- Slack
**Node Details:**
- **Slack**
- *Type & Role:* Slack API node; posts messages to Slack channel.
- *Configuration:*
- Sends text from AI agent output using expression `={{$json["output"]}}`.
- Target channel hardcoded to ID `C08QXSK7U1H` (presumably a ticketing or project channel).
- No additional options specified.
- *Credentials:* Configured with a Slack OAuth2 account credential.
- *Input:* Receives AI-generated markdown tickets.
- *Output:* Posts message to Slack channel.
- *Edge Cases:* Slack API rate limits, invalid channel ID, or revoked credentials may cause posting failures. Text formatting may not render perfectly if markdown syntax is malformed.
---
#### 2.4 Informational Sticky Notes
**Overview:**
These nodes provide static informational content for end users and administrators to understand workflow usage and support options.
**Nodes Involved:**
- Sticky Note
- Sticky Note1
**Node Details:**
- **Sticky Note**
- *Type & Role:* Visual note node displaying promotional content for free workflows by Varritech.
- *Content Highlights:*
- Describes free workflow offerings and instructions to import and configure.
- Contains link to https://varritech.com for downloads and support.
- **Sticky Note1**
- *Type & Role:* Visual note node offering support and consultancy info for AI workflow optimization.
- *Content Highlights:*
- Promotes expert help with eliminating redundant tasks, accelerating development, and prompt engineering.
- Provides Varritech contact link https://varritech.com.
---
### 3. Summary Table
| Node Name | Node Type | Functional Role | Input Node(s) | Output Node(s) | Sticky Note |
|-------------------|-----------------------------------|------------------------------------|------------------|-------------------|----------------------------------------------------------------------------------------------------|
| Webhook | HTTP Webhook (n8n-nodes-base.webhook) | Entry point receiving Slack events | None | Code | |
| Code | JavaScript Code (n8n-nodes-base.code) | Extracts and reformats Slack payload | Webhook | AI PM Wellington | |
| AI PM Wellington | Langchain Agent (@n8n/n8n-nodes-langchain.agent) | AI agent that analyzes message and creates tickets | Code, Simple Memory | Slack | |
| Simple Memory | Langchain Memory Buffer (@n8n/n8n-nodes-langchain.memoryBufferWindow) | Maintains conversation context for AI agent | None (memory connection from AI PM Wellington) | AI PM Wellington | |
| OpenAI Chat Model | Langchain LLM (@n8n/n8n-nodes-langchain.lmChatOpenAi) | Language model for AI text generation | AI PM Wellington | AI PM Wellington | |
| Slack | Slack API (n8n-nodes-base.slack) | Posts AI-generated tickets back to Slack channel | AI PM Wellington | None | |
| Sticky Note | Sticky Note (n8n-nodes-base.stickyNote) | Provides branding and workflow info | None | None | # Varritech Free Workflows for n8n... See https://varritech.com |
| Sticky Note1 | Sticky Note (n8n-nodes-base.stickyNote) | Provides expert support info and contact | None | None | # Need Help Maximizing Your AI Workflows?... Visit https://varritech.com |
---
### 4. Reproducing the Workflow from Scratch
1. **Create a Webhook Node**
- Type: `Webhook` (HTTP POST)
- Path: `slack-ticket-maker`
- HTTP Method: `POST`
- Purpose: Receive Slack event payloads to trigger the workflow.
2. **Create a Code Node**
- Type: `Code` node (JavaScript)
- Connect input from `Webhook` node output.
- JavaScript logic to extract Slack event nested payload and reformat:
- Extract original payload via `$input.all()[0]`.
- Access Slack event object (ensure correct key, fix `body[""]` if necessary).
- Remove Slack user mentions from the text using regex.
- Build JSON with keys: user, channel, cleaned text, team, timestamp, thread info (thread_id defaults to `"main"` if missing).
- Output reformatted Slack message JSON for downstream nodes.
3. **Configure Langchain OpenAI Chat Model Node**
- Type: `@n8n/n8n-nodes-langchain.lmChatOpenAi`
- Model: Select `gpt-4.1` or latest GPT-4 version available.
- Credentials: Configure OpenAI API credentials.
- No extra options needed.
4. **Configure Langchain Memory Buffer Node**
- Type: `@n8n/n8n-nodes-langchain.memoryBufferWindow`
- Session Key: Use expression `"slack_{{$json['slack']['channel']}}_user_{{$json['slack']['user']}}"`
- Session ID Type: `customKey`
- Purpose: To maintain conversation context per Slack channel and user.
5. **Create Langchain Agent Node**
- Type: `@n8n/n8n-nodes-langchain.agent`
- Connect input from `Code` node output and connect `Simple Memory` node as AI memory.
- Configure prompt:
- Instruct AI to analyze Slack message text, ask for project name and clarifications (up to 2 times), then break down into epics and tickets.
- Define ticket sections with bullet points (title, description, objectives, acceptance criteria, etc.).
- Format tickets as markdown code blocks.
- Emphasize always sending messages to Slack channel.
- Connect AI language model input to `OpenAI Chat Model` node.
6. **Add Slack Node**
- Type: `Slack` node
- Connect input from `AI PM Wellington` output.
- Configure to post message text from AI output expression `={{$json["output"]}}`.
- Set channel ID to the desired Slack channel (e.g., `C08QXSK7U1H`).
- Use valid Slack OAuth2 credentials with posting permissions.
7. **Optional: Add Sticky Note Nodes**
- Add two `Sticky Note` nodes anywhere for informational purposes:
- One with Varritech free workflow branding and download instructions.
- One with expert AI workflow support and contact info including link to https://varritech.com.
8. **Connect Nodes**
- Webhook → Code → AI PM Wellington
- AI PM Wellington → Slack
- Simple Memory → AI PM Wellington (memory connection)
- OpenAI Chat Model → AI PM Wellington (language model connection)
9. **Activate Workflow**
- Enable webhook in Slack app or integration to point to your n8n webhook URL `/webhook/slack-ticket-maker`
- Test by sending Slack messages in monitored channels.
---
### 5. General Notes & Resources
| Note Content | Context or Link |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|
| Collection of free, ready-to-use n8n workflows for automation and data integration offered by Varritech. Instructions to download, import, configure, and start automating immediately. | https://varritech.com |
| Expert consulting services to help organizations eliminate redundancy, accelerate development by 500%, and improve AI prompt engineering, provided by Varritech. | https://varritech.com |
| The workflow depends on Langchain nodes and requires n8n versions supporting Langchain v1.2+ for LLM nodes, v1.3+ for Memory nodes, and v1.8+ for Agent nodes. | n8n documentation |
| Slack channel ID `C08QXSK7U1H` is hardcoded; this should be updated to your target channel ID for posting tickets. | Slack channel configuration |
| The Code nodes JavaScript has a suspicious reference `body[""]` which should be reviewed and corrected to properly extract the Slack event payload from webhook body to avoid runtime errors. | Requires validation/fix |
---
**Disclaimer:**
The text provided is exclusively derived from an automated workflow created with n8n, an integration and automation tool. This processing strictly adheres to content policies and contains no illegal, offensive, or protected elements. All handled data is legal and public.