{
  "name": "Vorlux AI | Discord Onboarding Flow",
  "active": false,
  "nodes": [
    {
      "parameters": { "httpMethod": "POST", "path": "discord-onboarding", "options": { "responseMode": "lastNode" } },
      "id": "webhook-trigger", "name": "Onboarding Webhook", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [220, 300]
    },
    {
      "parameters": { "mode": "runOnceForAllItems", "jsCode": "const data = $input.first().json.body || $input.first().json;\nconst userId = data.userId || data.user_id;\nconst username = data.username || 'New Member';\nconst joinedAt = data.joinedAt || new Date().toISOString();\nconst welcomeMessage = 'Welcome to the Vorlux AI community, **' + username + '**! Check #rules, pick roles in #role-select, and introduce yourself in #introductions.';\nreturn [{ json: { userId, username, joinedAt, welcomeMessage } }];" },
      "id": "prepare-onboarding", "name": "Prepare Onboarding", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [460, 300]
    },
    {
      "parameters": { "url": "http://host.docker.internal:3010/api/discord/welcome", "method": "POST", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify({ userId: $json.userId, username: $json.username, message: $json.welcomeMessage }) }}", "options": { "timeout": 15000 } },
      "id": "send-welcome", "name": "Send Welcome Message", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [700, 200]
    },
    {
      "parameters": { "url": "http://host.docker.internal:3010/api/discord/roles", "method": "POST", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify({ userId: $json.userId, action: 'add', role: 'community-member' }) }}", "options": { "timeout": 10000 } },
      "id": "assign-role", "name": "Assign Default Role", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [700, 400]
    },
    {
      "parameters": { "url": "http://host.docker.internal:3010/api/community/members", "method": "POST", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify({ discordId: $('Prepare Onboarding').first().json.userId, username: $('Prepare Onboarding').first().json.username, source: 'discord' }) }}", "options": { "timeout": 10000 } },
      "id": "create-profile", "name": "Create Member Profile", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [960, 300]
    },
    {
      "parameters": { "method": "POST", "url": "={{$env.DISCORD_OPS_WEBHOOK}}", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify({ content: '👋 New Member Onboarded: ' + $('Prepare Onboarding').first().json.username }) }}" },
      "id": "discord-notify", "name": "Discord Notify", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [1200, 300]
    }
  ],
  "connections": {
    "Onboarding Webhook": { "main": [[{ "node": "Prepare Onboarding", "type": "main", "index": 0 }]] },
    "Prepare Onboarding": { "main": [[{ "node": "Send Welcome Message", "type": "main", "index": 0 }, { "node": "Assign Default Role", "type": "main", "index": 0 }]] },
    "Send Welcome Message": { "main": [[{ "node": "Create Member Profile", "type": "main", "index": 0 }]] },
    "Assign Default Role": { "main": [[{ "node": "Create Member Profile", "type": "main", "index": 0 }]] },
    "Create Member Profile": { "main": [[{ "node": "Discord Notify", "type": "main", "index": 0 }]] }
  },
  "settings": { "executionOrder": "v1" }
}
