{
  "name": "Vorlux AI | Content Translate (Bilingual)",
  "active": false,
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "content-translate",
        "options": { "responseMode": "lastNode" }
      },
      "id": "webhook-trigger",
      "name": "Translate Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [220, 300]
    },
    {
      "parameters": {
        "url": "http://host.docker.internal:3010/api/ai/completion",
        "method": "POST",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ prompt: 'Translate the following content to Spanish. Maintain the tone, formatting, and any technical terms. Return ONLY the translated text:\\n\\n' + ($input.first().json.body?.content || $input.first().json.content || ''), model: 'gpt-4o-mini' }) }}",
        "options": { "timeout": 60000 }
      },
      "id": "translate-content",
      "name": "Translate to Spanish",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [460, 300]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const original = $('Translate Webhook').first().json.body || $('Translate Webhook').first().json;\nconst translated = $input.first().json.text || $input.first().json.content || $input.first().json.result || '';\nreturn [{ json: { original: { title: original.title, content: original.content, language: 'en' }, translated: { title: original.title + ' (ES)', content: translated, language: 'es' }, contentId: original.contentId || null } }];"
      },
      "id": "format-output",
      "name": "Format Bilingual Output",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [700, 300]
    },
    {
      "parameters": {
        "url": "http://host.docker.internal:3010/api/content/library",
        "method": "POST",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ type: 'translation', language: 'es', title: $json.translated.title, content: $json.translated.content, sourceId: $json.contentId }) }}",
        "options": { "timeout": 15000 }
      },
      "id": "save-translation",
      "name": "Save Translation",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [940, 300]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{$env.DISCORD_CONTENT_WEBHOOK}}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ content: '🌐 **Content Translated** (EN → ES)\\nTitle: ' + $('Format Bilingual Output').first().json.translated.title }) }}"
      },
      "id": "discord-notify",
      "name": "Discord Notify",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [1180, 300]
    }
  ],
  "connections": {
    "Translate Webhook": { "main": [[{ "node": "Translate to Spanish", "type": "main", "index": 0 }]] },
    "Translate to Spanish": { "main": [[{ "node": "Format Bilingual Output", "type": "main", "index": 0 }]] },
    "Format Bilingual Output": { "main": [[{ "node": "Save Translation", "type": "main", "index": 0 }]] },
    "Save Translation": { "main": [[{ "node": "Discord Notify", "type": "main", "index": 0 }]] }
  },
  "settings": { "executionOrder": "v1" }
}
