{
  "name": "Vorlux AI | Comment & Chat Triage",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 3
            }
          ]
        }
      },
      "id": "wh",
      "name": "Schedule: Every 3 Hours",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        220,
        300
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const d = $input.first().json.body || $input.first().json;\nconst message = d.message || d.content || '';\nconst author = d.author || d.username || 'Unknown';\nconst platform = d.platform || 'discord';\nconst channelId = d.channelId || d.channel_id || '';\nconst toxicPatterns = /\\b(spam|scam|f\\*ck|shit|nazi|kill|die|hate)\\b/i;\nconst questionPatterns = /\\?|how (do|can|to)|what (is|are)|where|when|why|help|anyone know/i;\nconst feedbackPatterns = /\\b(bug|broken|error|crash|fix|issue|problem|feature request|suggestion)\\b/i;\nconst supportPatterns = /\\b(support|help me|can't|won't work|doesn't work|stuck|confused)\\b/i;\nlet category = 'general';\nlet priority = 'low';\nlet action = 'none';\nif (toxicPatterns.test(message)) { category = 'moderation'; priority = 'high'; action = 'flag_moderator'; }\nelse if (supportPatterns.test(message)) { category = 'support'; priority = 'medium'; action = 'create_ticket'; }\nelse if (feedbackPatterns.test(message)) { category = 'feedback'; priority = 'medium'; action = 'log_feedback'; }\nelse if (questionPatterns.test(message)) { category = 'question'; priority = 'low'; action = 'auto_respond'; }\nreturn [{ json: { message, author, platform, channelId, category, priority, action, timestamp: new Date().toISOString() } }];"
      },
      "id": "classify",
      "name": "Classify Message",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        460,
        300
      ],
      "notes": "Classifies chat messages by category, priority, and required action"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.category }}",
                    "rightValue": "moderation",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Moderation"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.category }}",
                    "rightValue": "support",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Support"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.category }}",
                    "rightValue": "feedback",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Feedback"
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "id": "route",
      "name": "Route by Category",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.1,
      "position": [
        700,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{$env.DISCORD_MOD_WEBHOOK}}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"embeds\": [{\n    \"title\": \"\ud83d\udea8 Moderation Flag\",\n    \"description\": \"**Author:** {{ $json.author }}\\n**Platform:** {{ $json.platform }}\\n**Message:** {{ $json.message.substring(0, 500) }}\",\n    \"color\": 15158332,\n    \"timestamp\": \"{{ $json.timestamp }}\"\n  }]\n}",
        "options": {
          "timeout": 10000
        }
      },
      "id": "mod-alert",
      "name": "Alert Moderators",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        960,
        100
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{$env.VORLUX_HUB_URL}}/api/support/tickets",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"title\": \"Support: {{ $json.author }}\",\n  \"description\": \"{{ $json.message }}\",\n  \"source\": \"{{ $json.platform }}\",\n  \"priority\": \"{{ $json.priority }}\"\n}",
        "options": {
          "timeout": 10000
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Cookie",
              "value": "vorlux_hub={\"v\":3,\"ts\":1774181154534,\"uid\":\"admin\",\"role\":\"super_admin\",\"tier\":\"partner\",\"exp\":1805717154534,\"authMethod\":\"api\"}.a2d82bd0cfaaee6babff9174193f0fbce06fab372a741e7ad96b59655090a92f"
            }
          ]
        }
      },
      "id": "create-ticket",
      "name": "Create Ticket",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        960,
        260
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{$env.VORLUX_HUB_URL}}/api/feedback",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"message\": \"{{ $json.message }}\",\n  \"author\": \"{{ $json.author }}\",\n  \"platform\": \"{{ $json.platform }}\",\n  \"category\": \"user_feedback\"\n}",
        "options": {
          "timeout": 10000
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Cookie",
              "value": "vorlux_hub={\"v\":3,\"ts\":1774181154534,\"uid\":\"admin\",\"role\":\"super_admin\",\"tier\":\"partner\",\"exp\":1805717154534,\"authMethod\":\"api\"}.a2d82bd0cfaaee6babff9174193f0fbce06fab372a741e7ad96b59655090a92f"
            }
          ]
        }
      },
      "id": "log-feedback",
      "name": "Log Feedback",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        960,
        420
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{$env.VORLUX_HUB_URL}}/api/activity",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"type\": \"chat_triage\",\n  \"action\": \"{{ $json.action }}\",\n  \"metadata\": { \"category\": \"{{ $json.category }}\", \"platform\": \"{{ $json.platform }}\" }\n}",
        "options": {
          "timeout": 10000
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Cookie",
              "value": "vorlux_hub={\"v\":3,\"ts\":1774181154534,\"uid\":\"admin\",\"role\":\"super_admin\",\"tier\":\"partner\",\"exp\":1805717154534,\"authMethod\":\"api\"}.a2d82bd0cfaaee6babff9174193f0fbce06fab372a741e7ad96b59655090a92f"
            }
          ]
        }
      },
      "id": "log",
      "name": "Log Activity",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        960,
        560
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ category: $json.category, action: $json.action, priority: $json.priority }) }}"
      },
      "id": "resp",
      "name": "Respond",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1200,
        300
      ]
    }
  ],
  "connections": {
    "Chat Event Webhook": {
      "main": [
        [
          {
            "node": "Classify Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Classify Message": {
      "main": [
        [
          {
            "node": "Route by Category",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Category": {
      "main": [
        [
          {
            "node": "Alert Moderators",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create Ticket",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log Feedback",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log Activity",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Alert Moderators": {
      "main": [
        [
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Ticket": {
      "main": [
        [
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Feedback": {
      "main": [
        [
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Activity": {
      "main": [
        [
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "callerPolicy": "workflowsFromSameOwner",
    "availableInMCP": false
  }
}