{
  "name": "SinoDossier — Global Multilingual UGC Matrix & beehiiv Retention Agent",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "global-ugc-matrix",
        "options": {}
      },
      "id": "ugc-node-webhook",
      "name": "1. Receive Winning Product Brief",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [180, 300],
      "webhookId": "global-ugc-matrix-trigger"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.openai.com/v1/chat/completions",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_OPENAI_API_KEY"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"model\": \"gpt-4o-mini\",\n  \"response_format\": { \"type\": \"json_object\" },\n  \"messages\": [\n    {\n      \"role\": \"system\",\n      \"content\": \"You are the SinoDossier global-ugc-localization Skill. Transcreate the product pitch into culturally native US English (en-US), Spanish (es-ES), and German (de-DE) 35-second UGC scripts (75-95 words each). Also write a 180-word DTC retention email for beehiiv. Output strict JSON with keys: product_name, markets (array of { lang, hook, spoken_script, cta, adspower_profile_tag }), beehiiv_subject, beehiiv_preview, beehiiv_html.\"\n    },\n    {\n      \"role\": \"user\",\n      \"content\": \"Product: {{ $json.body.product_name }}\\nSelling points: {{ $json.body.selling_points }}\\nSource video URL: {{ $json.body.source_video_url || '' }}\"\n    }\n  ]\n}",
        "options": {}
      },
      "id": "ugc-node-llm",
      "name": "2. AI Transcreation Skill (US/ES/DE + Email)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [440, 300]
    },
    {
      "parameters": {
        "jsCode": "const raw = $input.first().json.choices?.[0]?.message?.content || '{}';\nconst parsed = JSON.parse(raw);\nconst sourceVideo = $('1. Receive Winning Product Brief').first().json.body?.source_video_url || '';\n\nreturn [\n  {\n    json: {\n      product_name: parsed.product_name || 'Product',\n      markets: parsed.markets || [],\n      primary_us_script: (parsed.markets?.[0]?.hook || '') + ' ' + (parsed.markets?.[0]?.spoken_script || ''),\n      beehiiv_subject: parsed.beehiiv_subject || 'New Bestseller Drop',\n      beehiiv_preview: parsed.beehiiv_preview || '',\n      beehiiv_html: parsed.beehiiv_html || '<p>Check out our latest drop.</p>',\n      source_video_url: sourceVideo\n    }\n  }\n];"
      },
      "id": "ugc-node-parse",
      "name": "3. Parse Multilingual Scripts & Email",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [700, 300]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.elevenlabs.io/v1/text-to-speech/YOUR_ELEVENLABS_VOICE_ID",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "xi-api-key",
              "value": "YOUR_ELEVENLABS_API_KEY"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"text\": {{ JSON.stringify($json.primary_us_script) }},\n  \"model_id\": \"eleven_multilingual_v2\",\n  \"voice_settings\": {\n    \"stability\": 0.45,\n    \"similarity_boost\": 0.78\n  }\n}",
        "options": {}
      },
      "id": "ugc-node-elevenlabs",
      "name": "4. ElevenLabs Native Voiceover",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [980, 180]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.heygen.com/v2/video_translate",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Api-Key",
              "value": "YOUR_HEYGEN_API_KEY"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"video_url\": \"{{ $('3. Parse Multilingual Scripts & Email').first().json.source_video_url }}\",\n  \"output_language\": \"Spanish\",\n  \"title\": \"{{ $('3. Parse Multilingual Scripts & Email').first().json.product_name }} - ES Dub\"\n}",
        "options": {}
      },
      "id": "ugc-node-heygen",
      "name": "5. HeyGen Lip-Sync Video Translation",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [980, 340]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.beehiiv.com/v2/publications/YOUR_BEEHIIV_PUB_ID/posts",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_BEEHIIV_API_KEY"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"title\": {{ JSON.stringify($('3. Parse Multilingual Scripts & Email').first().json.beehiiv_subject) }},\n  \"subtitle\": {{ JSON.stringify($('3. Parse Multilingual Scripts & Email').first().json.beehiiv_preview) }},\n  \"status\": \"draft\",\n  \"content_tags\": [\"ugc-drop\", \"crossborder-os\"]\n}",
        "options": {}
      },
      "id": "ugc-node-beehiiv",
      "name": "6. Create beehiiv Retention Email Draft",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [980, 500]
    }
  ],
  "connections": {
    "1. Receive Winning Product Brief": {
      "main": [
        [
          {
            "node": "2. AI Transcreation Skill (US/ES/DE + Email)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2. AI Transcreation Skill (US/ES/DE + Email)": {
      "main": [
        [
          {
            "node": "3. Parse Multilingual Scripts & Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3. Parse Multilingual Scripts & Email": {
      "main": [
        [
          {
            "node": "4. ElevenLabs Native Voiceover",
            "type": "main",
            "index": 0
          },
          {
            "node": "5. HeyGen Lip-Sync Video Translation",
            "type": "main",
            "index": 0
          },
          {
            "node": "6. Create beehiiv Retention Email Draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "tags": [
    {
      "name": "SinoDossier"
    },
    {
      "name": "Multilingual-UGC"
    }
  ]
}
