{
  "name": "Soke — Full Content Optimization Pipeline",
  "nodes": [
    {
      "parameters": {},
      "id": "c1b2c3d4-0003-4000-8000-000000000001",
      "name": "When clicking 'Test workflow'",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [180, 300]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.usesoke.ai/api/v1/research/keywords",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"topic\": \"{{ $json.topic || 'productivity tips for developers' }}\",\n  \"platform\": \"youtube\",\n  \"maxResults\": 10\n}",
        "options": {}
      },
      "id": "c1b2c3d4-0003-4000-8000-000000000002",
      "name": "1. Research Keywords",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [420, 300],
      "credentials": {
        "httpHeaderAuth": {
          "id": "CREDENTIAL_ID",
          "name": "Soke API"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.usesoke.ai/api/v1/content/optimize-title",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"draftTitle\": \"{{ $json.topic || 'How to boost your productivity as a developer' }}\",\n  \"platform\": \"youtube\",\n  \"keywords\": {{ JSON.stringify($('1. Research Keywords').item.json.data.keywords.slice(0, 5).map(k => k.keyword)) }},\n  \"keywordsWithScores\": {{ JSON.stringify($('1. Research Keywords').item.json.data.keywords.slice(0, 5).map(k => ({ keyword: k.keyword, competitionScore: k.competitionScore, trendDirection: k.trendDirection }))) }}\n}",
        "options": {}
      },
      "id": "c1b2c3d4-0003-4000-8000-000000000003",
      "name": "2. Optimize Title",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [660, 300],
      "credentials": {
        "httpHeaderAuth": {
          "id": "CREDENTIAL_ID",
          "name": "Soke API"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.usesoke.ai/api/v1/content/generate-description",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"title\": \"{{ $json.data.alternatives[0]?.title || $('1. Research Keywords').item.json.topic }}\",\n  \"platform\": \"youtube\",\n  \"keywords\": {{ JSON.stringify($('1. Research Keywords').item.json.data.keywords.slice(0, 5).map(k => k.keyword)) }},\n  \"niche\": \"tech\",\n  \"tone\": \"casual\"\n}",
        "options": {}
      },
      "id": "c1b2c3d4-0003-4000-8000-000000000004",
      "name": "3. Generate Description",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [900, 300],
      "credentials": {
        "httpHeaderAuth": {
          "id": "CREDENTIAL_ID",
          "name": "Soke API"
        }
      }
    },
    {
      "parameters": {
        "mode": "raw",
        "jsonOutput": "={\n  \"optimizedTitle\": \"{{ $('2. Optimize Title').item.json.data.alternatives[0]?.title }}\",\n  \"titleScore\": {{ $('2. Optimize Title').item.json.data.alternatives[0]?.overallScore || 0 }},\n  \"description\": \"{{ $json.data.description }}\",\n  \"keywords\": {{ JSON.stringify($('1. Research Keywords').item.json.data.keywords.slice(0, 5).map(k => k.keyword)) }},\n  \"creditsUsed\": 8\n}",
        "options": {}
      },
      "id": "c1b2c3d4-0003-4000-8000-000000000005",
      "name": "Combine Results",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [1140, 300]
    }
  ],
  "connections": {
    "When clicking 'Test workflow'": {
      "main": [
        [{ "node": "1. Research Keywords", "type": "main", "index": 0 }]
      ]
    },
    "1. Research Keywords": {
      "main": [
        [{ "node": "2. Optimize Title", "type": "main", "index": 0 }]
      ]
    },
    "2. Optimize Title": {
      "main": [
        [{ "node": "3. Generate Description", "type": "main", "index": 0 }]
      ]
    },
    "3. Generate Description": {
      "main": [
        [{ "node": "Combine Results", "type": "main", "index": 0 }]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false,
    "instanceId": "soke-template"
  },
  "tags": [
    { "name": "Soke", "id": "soke-tag-1" }
  ]
}
