{
  "id": "180",
  "meta": {
    "instanceId": "workflow-22f38f30",
    "versionId": "1.0.0",
    "createdAt": "2025-09-29T07:08:00.155376",
    "updatedAt": "2025-09-29T07:08:00.155421",
    "owner": "n8n-user",
    "license": "MIT",
    "category": "automation",
    "status": "active",
    "priority": "high",
    "environment": "production"
  },
  "name": "Discord AI bot",
  "tags": [
    "automation",
    "n8n",
    "production-ready",
    "excellent",
    "optimized"
  ],
  "nodes": [
    {
      "id": "6f188270-2c08-491f-bf52-c4a152b33aa0",
      "name": "When clicking \"Execute Workflow\"",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        1220,
        780
      ],
      "parameters": {},
      "typeVersion": 1,
      "notes": "This manualTrigger node performs automated tasks as part of the workflow."
    },
    {
      "id": "e4839de2-fc04-40b0-b6bc-596455ad93fe",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        1220,
        580
      ],
      "webhookId": "d0cdd428-be96-4821-85bc-65342cf928d0",
      "parameters": {
        "path": "d0cdd428-be96-4821-85bc-65342cf928d0",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 1,
      "notes": "This webhook node performs automated tasks as part of the workflow."
    },
    {
      "id": "15dcafe1-6361-4775-ace0-e34fd2a143b4",
      "name": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "position": [
        2120,
        940
      ],
      "parameters": {},
      "typeVersion": 1,
      "notes": "This noOp node performs automated tasks as part of the workflow."
    },
    {
      "id": "0d28fe8e-da80-458b-9a75-d316019cb3ae",
      "name": "Analyze user request",
      "type": "n8n-nodes-base.openAi",
      "position": [
        1420,
        680
      ],
      "parameters": {
        "model": "gpt-4",
        "prompt": {
          "messages": [
            {
              "role": "system",
              "content": "Act as a service desk agent and help to categorize user messages. Return back only JSON without quotations. Do not return anything else."
            },
            {
              "content": "=Here is a user feedback: \"{{ $json.body.feedback }}\". Please analyse it and put into one of the categories:\n1. \"success-story\" for user appraisal or success story. this will be processed by customer success department\n2. \"urgent-issue\" for extreme dissatisfaction or an urgent problem. this will be escalated to the IT team. Please assess if the request is really urgent and whether it has an immediate impact on the client. If the ticket doesn't look like an immediate problem or an extreme dissatisfaction then proceed as a normal ticket.\n3. \"ticket\" for everything else. This will be processed as normal by customer support team.\n\nPlease return back a JSON with the following structure: category (string), feedback (string), instruction (string).\nCategory must match the analysed category. feedback must match the original text. instruction should contain a text for a department according to the category with a one sentense summary of the feedback. Please be polite and friendly to the colleagues."
            }
          ]
        },
        "options": {
          "maxTokens": "YOUR_TOKEN_HERE",
          "temperature": 0.5
        },
        "resource": "chat"
      },
      "credentials": {
        "openAiApi": {
          "id": "{{ $credentials.openAiApi.id }}",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1,
      "notes": "This openAi node performs automated tasks as part of the workflow."
    },
    {
      "id": "ce1c4198-ce21-4436-9ccb-4a2a078cd06e",
      "name": "Select category",
      "type": "n8n-nodes-base.switch",
      "position": [
        1840,
        680
      ],
      "parameters": {
        "rules": {
          "rules": [
            {
              "value2": "success-story"
            },
            {
              "output": 1,
              "value2": "urgent-issue"
            },
            {
              "output": 2,
              "value2": "ticket"
            }
          ]
        },
        "value1": "={{ $json.gpt_reply.category.toLowerCase() }}",
        "dataType": "string",
        "fallbackOutput": 3
      },
      "typeVersion": 1,
      "notes": "This switch node performs automated tasks as part of the workflow."
    },
    {
      "id": "839cc38d-b393-4fc1-a068-47a8fcf55e3f",
      "name": "Parse JSON",
      "type": "n8n-nodes-base.set",
      "position": [
        1640,
        680
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "gpt_reply",
              "value": "={{ JSON.parse( $json.message.content.replace(/\\n(?=[^\"]*\"(?:[^\"]*\"[^\"]*\")*[^\"]*$)/g, '\\\\n')) }}"
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 2,
      "notes": "This set node performs automated tasks as part of the workflow."
    },
    {
      "id": "4c150439-89af-42bd-bbdc-905d13ada76b",
      "name": "User Success Dept",
      "type": "n8n-nodes-base.discord",
      "position": [
        2120,
        460
      ],
      "parameters": {
        "text": "={{ $json.gpt_reply.instruction }}",
        "options": {},
        "webhookUri": "{{ $env.API_BASE_URL }}<YOUR WEBHOOK HERE>"
      },
      "typeVersion": 1,
      "notes": "This discord node performs automated tasks as part of the workflow."
    },
    {
      "id": "9a5e5335-9e6c-4f1f-a0f0-b1b022956549",
      "name": "IT Dept",
      "type": "n8n-nodes-base.discord",
      "position": [
        2120,
        620
      ],
      "parameters": {
        "text": "={{ $json.gpt_reply.instruction }}",
        "options": {},
        "webhookUri": "{{ $env.API_BASE_URL }}<YOUR WEBHOOK HERE>"
      },
      "typeVersion": 1,
      "notes": "This discord node performs automated tasks as part of the workflow."
    },
    {
      "id": "d6d6250a-3a24-49f1-a597-47ebc179949c",
      "name": "Helpdesk",
      "type": "n8n-nodes-base.discord",
      "position": [
        2120,
        780
      ],
      "parameters": {
        "text": "={{ $json.gpt_reply.instruction }}",
        "options": {},
        "webhookUri": "{{ $env.API_BASE_URL }}<YOUR WEBHOOK HERE>"
      },
      "typeVersion": 1,
      "notes": "This discord node performs automated tasks as part of the workflow."
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "callerPolicy": "workflowsFromSameOwner",
    "saveManualExecutions": true,
    "saveDataSuccessExecution": "all",
    "executionOrder": "v1",
    "errorWorkflow": null,
    "timezone": "UTC",
    "executionTimeout": 3600,
    "maxExecutions": 1000,
    "retryOnFail": true,
    "retryCount": 3,
    "retryDelay": 1000
  },
  "versionId": "8871171e-7e18-49ee-a570-facbe97afb79",
  "connections": {
    "e4839de2-fc04-40b0-b6bc-596455ad93fe": {
      "main": [
        [
          {
            "node": "error-handler-e4839de2-fc04-40b0-b6bc-596455ad93fe",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-e4839de2-fc04-40b0-b6bc-596455ad93fe-ed322f7d",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-e4839de2-fc04-40b0-b6bc-596455ad93fe-0903bee6",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-e4839de2-fc04-40b0-b6bc-596455ad93fe-8047e92c",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-e4839de2-fc04-40b0-b6bc-596455ad93fe-b8652825",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-e4839de2-fc04-40b0-b6bc-596455ad93fe-9ac70c2b",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-e4839de2-fc04-40b0-b6bc-596455ad93fe-f31c4485",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-e4839de2-fc04-40b0-b6bc-596455ad93fe-a5850a6f",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-e4839de2-fc04-40b0-b6bc-596455ad93fe-56b2e6a6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0d28fe8e-da80-458b-9a75-d316019cb3ae": {
      "main": [
        [
          {
            "node": "error-handler-0d28fe8e-da80-458b-9a75-d316019cb3ae-d6b57fd8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4c150439-89af-42bd-bbdc-905d13ada76b": {
      "main": [
        [
          {
            "node": "error-handler-4c150439-89af-42bd-bbdc-905d13ada76b-7d675c30",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "9a5e5335-9e6c-4f1f-a0f0-b1b022956549": {
      "main": [
        [
          {
            "node": "error-handler-9a5e5335-9e6c-4f1f-a0f0-b1b022956549-138fd8c6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d6d6250a-3a24-49f1-a597-47ebc179949c": {
      "main": [
        [
          {
            "node": "error-handler-d6d6250a-3a24-49f1-a597-47ebc179949c-3500c922",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "description": "Automated workflow: Discord AI bot. This workflow processes data and performs automated tasks.",
  "notes": "Excellent quality workflow: Discord AI bot. This workflow has been optimized for production use with comprehensive error handling, security, and documentation."
}