{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "e709b90b-ffaa-4b3d-b0b5-971e35e7c7fc",
      "name": "Format Task",
      "type": "n8n-nodes-base.set",
      "position": [
        18800,
        4736
      ],
      "parameters": {
        "values": {
          "number": [
            {
              "name": "Priority",
              "value": "{{ JSON.parse($json.output[0].content[0].text).priority }}"
            },
            {
              "name": "Estimate",
              "value": "{{ JSON.parse($json.output[0].content[0].text).estimate_hours }}"
            }
          ],
          "string": [
            {
              "name": "taskName",
              "value": "Support - {{ JSON.parse($json.output[0].content[0].text).task_title }}"
            },
            {
              "name": "taskDescription",
              "value": "User: {{ $('Loop Over Items').item.json.author.username }}\n\nMessage:{{ $json.output[0].content[0].text }}\n\nTimestamp:\n{{ $('Get many messages').item.json.timestamp }}\n\nDiscord Message ID:{{ $('Insert row').item.json.message_id }}"
            },
            {
              "name": "assignee",
              "value": "{{ [ JSON.parse($json.output[0].content[0].text).assignee ] }}"
            },
            {
              "name": "Start Date",
              "value": "{{ JSON.parse($json.output[0].content[0].text).start_date }}"
            },
            {
              "name": "Due Date",
              "value": "{{ JSON.parse($json.output[0].content[0].text).due_date }}"
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 2
    },
    {
      "id": "5dbaabe0-5b2e-48eb-99d3-5a105c43b7a5",
      "name": "Create ClickUp Task",
      "type": "n8n-nodes-base.clickUp",
      "position": [
        19008,
        4736
      ],
      "parameters": {
        "name": "={{$json[\"taskName\"]}}",
        "folderless": true,
        "additionalFields": {
          "status": "",
          "content": "={{ $('Loop Over Items').item.json.content }}",
          "dueDate": "={{ new Date(JSON.parse($json.output[0].content[0].text).due_date).getTime() }}",
          "priority": "={{ $json.Priority }}",
          "assignees": "={{ $json.assignee }}",
          "startDate": "={{ new Date(JSON.parse($json.output[0].content[0].text).start_date).getTime() }}",
          "timeEstimate": "={{ $json.Estimate }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b87bc567-2fed-4f1c-b918-b5484ff39f90",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        16880,
        4848
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 1
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "37163e49-dfd2-42ba-9a80-f0e127074a7a",
      "name": "Get many messages",
      "type": "n8n-nodes-base.discord",
      "position": [
        17088,
        4848
      ],
      "parameters": {
        "limit": 10,
        "guildId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        },
        "options": {
          "simplify": false
        },
        "resource": "message",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        },
        "operation": "getAll"
      },
      "typeVersion": 2
    },
    {
      "id": "9f1b2eda-1376-49a1-89e2-5e8883e3ce57",
      "name": "Message a model",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        18368,
        4736
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "GPT-4.1-MINI"
        },
        "options": {},
        "responses": {
          "values": [
            {
              "role": "system",
              "content": "=You are a support ticket router for a development agency.\n\nYour job is to analyze the user support message and generate task metadata for a ClickUp ticket.\n\nTeam responsibilities:\n\n100948176 \u2192 Jay Gemawat \u2192 n8n automation workflows\n100927404 \u2192 Yagnik Ramani \u2192 Jitsi, MERN stack\n156216794 \u2192 Het Patel \u2192 digital marketing, social media\n194615214 \u2192 Dwij Chawla \u2192 python backend\n95045458 \u2192 Dev Doshi \u2192 n8n automation\n\nReturn ONLY a valid JSON object in this format:\n\n{\n \"assignee\": NUMBER,\n \"priority\": NUMBER,\n \"estimate_hours\": NUMBER,\n \"task_title\": STRING,\n \"start_date\": STRING,\n \"due_date\": STRING\n}\n\nDate format:\nUse ISO 8601 format.\n\nExample:\n2026-03-11T10:30:00Z\n\nRules for dates:\n\nstart_date\n- Always set start_date to the current time.\n\ndue_date\n- Do NOT base due_date on estimate_hours.\n- Instead assume developer workload.\n\nSet due_date based on issue complexity:\n\nSimple issue \u2192 24 hours from start_date  \nMedium issue \u2192 48 hours from start_date  \nComplex issue \u2192 72 hours from start_date  \n\nMinimum due date: 24 hours from start_date  \nMaximum due date: 7 days from start_date  \n\nPriority levels:\n\n1 = urgent  \n2 = high  \n3 = normal  \n4 = low  \n\nEstimate_hours guideline:\n\nSmall bug = 1  \nMedium issue = 2  \nComplex issue = 4+  \n\ntask_title:\nGenerate a short clear technical title for the ticket.\n\nIMPORTANT RULES:\n\n- Output must be valid JSON\n- No explanation\n- No text outside JSON\n- Return ONLY minified JSON in one line\n- No line breaks\n- No markdown"
            },
            {
              "content": "={{$json[\"content\"]}}"
            }
          ]
        },
        "builtInTools": {}
      },
      "typeVersion": 2.1
    },
    {
      "id": "cd09b3a3-7a7b-43ea-855c-5aa0d79e9b03",
      "name": "Insert row",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        18080,
        4800
      ],
      "parameters": {
        "columns": {
          "value": {
            "author": "={{ $('Loop Over Items').item.json.author.global_name }}",
            "content": "={{ $('Loop Over Items').item.json.content }}",
            "channel_id": "={{ $('Loop Over Items').item.json.channel_id }}",
            "message_id": "={{ $('Loop Over Items').item.json.id }}"
          },
          "schema": [
            {
              "id": "message_id",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "message_id",
              "defaultMatch": false
            },
            {
              "id": "channel_id",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "channel_id",
              "defaultMatch": false
            },
            {
              "id": "author",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "author",
              "defaultMatch": false
            },
            {
              "id": "content",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "content",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        }
      },
      "typeVersion": 1
    },
    {
      "id": "933e921a-09fa-4270-96f5-e6263f0c2d8b",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        17312,
        4752
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "a7247e6b-0a05-40d1-9f1b-7388382e5828",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        17792,
        4816
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "3d75eb03-9d24-4d39-89aa-afb45d5302b9",
              "operator": {
                "type": "string",
                "operation": "empty",
                "singleValue": true
              },
              "leftValue": "={{ $json.message_id }}",
              "rightValue": "0"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "8a217583-9043-43e1-bc9f-2491d9f6026d",
      "name": "Get row(s)",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        17600,
        4816
      ],
      "parameters": {
        "limit": 1,
        "filters": {
          "conditions": [
            {
              "keyName": "message_id",
              "keyValue": "={{$json.id}}"
            }
          ]
        },
        "matchType": "allConditions",
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "f75fb739-f312-4b06-862c-9876fb5cf415",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16256,
        4480
      ],
      "parameters": {
        "width": 512,
        "height": 720,
        "content": "## AI Discord \u2192 ClickUp Support Automation\n\n### How it works\nThis workflow automatically converts Discord support messages into structured ClickUp tasks using AI.\n\nIt runs on a schedule, fetches recent Discord messages, and processes them one by one. Each message is checked against a data table to prevent duplicates. New messages are stored and then sent to an AI model, which extracts structured task data like assignee, priority, estimate, and title.\n\nThe formatted output is then used to create a ClickUp task with all relevant context from the original message.\n\n### Setup steps\n1. Connect your Discord Bot credentials  \n2. Select your Discord server and support channel  \n3. Configure Data Table for message tracking  \n4. Connect OpenAI credentials  \n5. Set your ClickUp workspace, list, and team  \n6. Test with a sample Discord message  \n\n### Customization tips\n- Adjust AI prompt for team roles  \n- Modify priority and SLA logic  \n- Add filters for specific message types"
      },
      "typeVersion": 1
    },
    {
      "id": "43c71f4c-4ee0-4446-a005-4938ecd9f52f",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16784,
        4480
      ],
      "parameters": {
        "color": 7,
        "width": 464,
        "height": 720,
        "content": "## Step 1 - Trigger & Fetch\n\nRuns on schedule and fetches recent Discord messages."
      },
      "typeVersion": 1
    },
    {
      "id": "0ded10c2-af0e-4a9a-a040-ae388b050254",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        17264,
        4480
      ],
      "parameters": {
        "color": 7,
        "height": 720,
        "content": "## Step 2 - Process Messages\n\nLoops through messages one-by-one for controlled execution."
      },
      "typeVersion": 1
    },
    {
      "id": "eb6f82d2-940a-4b33-9c5c-301828342065",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        17520,
        4480
      ],
      "parameters": {
        "color": 7,
        "width": 464,
        "height": 720,
        "content": "## Step 3 - Check Duplicates\n\nLooks up message ID in table to avoid reprocessing."
      },
      "typeVersion": 1
    },
    {
      "id": "1360c5f7-c36b-4ccd-a21b-9d91d613bfb4",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        18000,
        4480
      ],
      "parameters": {
        "color": 7,
        "width": 288,
        "height": 720,
        "content": "## Step 4 - Store Messages\n\nSaves new messages to ensure idempotent workflow runs."
      },
      "typeVersion": 1
    },
    {
      "id": "c6506d84-2a7d-41dc-a1f0-69e3c7264b3f",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        18320,
        4480
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 720,
        "content": "## Step 5 - AI Classification\n\nGenerates assignee, priority, estimate, and title using AI."
      },
      "typeVersion": 1
    },
    {
      "id": "cff8ca6e-6438-49df-ba20-c6ff19c97460",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        18688,
        4480
      ],
      "parameters": {
        "color": 7,
        "height": 720,
        "content": "## Step 6 - Format Task\n\nTransforms AI output into ClickUp-compatible structure."
      },
      "typeVersion": 1
    },
    {
      "id": "beb0b9bc-8113-46d4-b698-3a529ba183f1",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        18960,
        4480
      ],
      "parameters": {
        "color": 7,
        "height": 720,
        "content": "## Step 7 - Create Task\n\nCreates ClickUp task with message context and metadata."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Insert row",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s)": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert row": {
      "main": [
        [
          {
            "node": "Message a model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Task": {
      "main": [
        [
          {
            "node": "Create ClickUp Task",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Get row(s)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message a model": {
      "main": [
        [
          {
            "node": "Format Task",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get many messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get many messages": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create ClickUp Task": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}