n8n-workflow-railway.json•5.13 kB
{
  "name": "Human Design Calculator (Railway)",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "human-design",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "webhook-trigger",
      "name": "Webhook Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [240, 300],
      "webhookId": "human-design-railway",
      "notes": "Trigger для входящих запросов"
    },
    {
      "parameters": {
        "url": "={{ $env.RAILWAY_API_URL || 'https://your-project.up.railway.app' }}/api/human-design",
        "authentication": "none",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "birthDate",
              "value": "={{ $json.birthDate }}"
            },
            {
              "name": "birthTime",
              "value": "={{ $json.birthTime }}"
            },
            {
              "name": "birthLocation",
              "value": "={{ $json.birthLocation }}"
            }
          ]
        },
        "options": {
          "timeout": 10000
        }
      },
      "id": "railway-api-call",
      "name": "Call Railway API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [460, 300],
      "notes": "Вызов Railway API для расчета Human Design"
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $json.success }}",
              "value2": true
            }
          ]
        }
      },
      "id": "check-success",
      "name": "Check Success",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [680, 300]
    },
    {
      "parameters": {
        "jsCode": "// Извлечь данные из Railway response\nconst hdData = $input.item.json.data;\n\n// Форматировать ответ для пользователя\nconst message = `🎋 **Ваш Human Design:**\n\n` +\n`✨ **Тип:** ${hdData.type.ru_name || hdData.type.name}\n` +\n`📝 ${hdData.type.description || ''}\n\n` +\n`🎯 **Стратегия:** ${hdData.strategy}\n\n` +\n`💪 **Авторитет:** ${hdData.authority.ru_name || hdData.authority.name}\n` +\n`📝 ${hdData.authority.description || ''}\n\n` +\n`📊 **Профиль:** ${hdData.profile.number}\n` +\n`📝 ${hdData.profile.description || ''}\n\n` +\n`🔮 **Активированные ворота:**\n` +\nhdData.gates.map(gate => \n  `• **${gate.planet}**: Ворота ${gate.gate} (${gate.ru_name || gate.name}), Линия ${gate.line}`\n).join('\\n') +\n`\n\n---\n*Расчет: ${hdData.calculationSource || 'Упрощенная версия'}*`;\n\nreturn {\n  json: {\n    success: true,\n    message: message,\n    rawData: hdData\n  }\n};"
      },
      "id": "format-response",
      "name": "Format Response",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [900, 200]
    },
    {
      "parameters": {
        "jsCode": "// Обработка ошибки\nconst error = $input.item.json.error || 'Unknown error';\n\nreturn {\n  json: {\n    success: false,\n    message: `❌ Ошибка: ${error}`,\n    error: error\n  }\n};"
      },
      "id": "format-error",
      "name": "Format Error",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [900, 400]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ $json }}"
      },
      "id": "respond-to-webhook",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [1120, 300],
      "notes": "Отправить результат клиенту"
    }
  ],
  "connections": {
    "Webhook Trigger": {
      "main": [
        [
          {
            "node": "Call Railway API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call Railway API": {
      "main": [
        [
          {
            "node": "Check Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Success": {
      "main": [
        [
          {
            "node": "Format Response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Format Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Response": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Error": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [],
  "triggerCount": 1,
  "updatedAt": "2024-01-01T00:00:00.000Z",
  "versionId": "1"
}