{
  "id": "JLfltgKT4ytQsIKW",
  "name": "Automate YouTube SEO and Cross-Platform Promotion",
  "tags": [
    {
      "id": "BozSnIOP0arZwOpu",
      "name": "tuguidragos.com",
      "createdAt": "2025-12-14T19:49:53.386Z",
      "updatedAt": "2025-12-14T19:49:53.386Z"
    }
  ],
  "nodes": [
    {
      "id": "22c6a0e5-ec11-476a-8bf0-dc8deaed1c83",
      "name": "Video Published Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -30656,
        864
      ],
      "parameters": {
        "path": "dffce599-768d-4471-a26e-3da64e7aded0",
        "options": {}
      },
      "typeVersion": 2.1
    },
    {
      "id": "3dee4ac8-1e5e-4edf-a1f2-a2cd6a22c557",
      "name": "Workflow Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        -30480,
        864
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "videoId",
              "type": "string",
              "value": "={{ $json.videoId }}"
            },
            {
              "id": "id-2",
              "name": "channelId",
              "type": "string",
              "value": "={{ $json.channelId }}"
            },
            {
              "id": "id-3",
              "name": "competitorApiUrl",
              "type": "string",
              "value": "={{ $env.COMPETITOR_API_URL }}"
            },
            {
              "id": "id-4",
              "name": "competitorApiKey",
              "type": "string",
              "value": "={{ $env.COMPETITOR_API_KEY }}"
            },
            {
              "id": "id-5",
              "name": "trendingApiUrl",
              "type": "string",
              "value": "={{ $env.TRENDING_API_URL }}"
            },
            {
              "id": "id-6",
              "name": "trendingApiKey",
              "type": "string",
              "value": "={{ $env.TRENDING_API_KEY }}"
            },
            {
              "id": "id-7",
              "name": "thumbnailApiUrl",
              "type": "string",
              "value": "={{ $env.THUMBNAIL_API_URL }}"
            },
            {
              "id": "id-8",
              "name": "thumbnailApiKey",
              "type": "string",
              "value": "={{ $env.THUMBNAIL_API_KEY }}"
            },
            {
              "id": "id-9",
              "name": "clipApiUrl",
              "type": "string",
              "value": "={{ $env.CLIP_API_URL }}"
            },
            {
              "id": "id-10",
              "name": "clipApiKey",
              "type": "string",
              "value": "={{ $env.CLIP_API_KEY }}"
            },
            {
              "id": "id-11",
              "name": "slackChannel",
              "type": "string",
              "value": "={{ $env.SLACK_CHANNEL_ID }}"
            },
            {
              "id": "id-12",
              "name": "linkedinPersonId",
              "type": "string",
              "value": "={{ $env.LINKEDIN_PERSON_ID }}"
            },
            {
              "id": "id-13",
              "name": "instagramAccountId",
              "type": "string",
              "value": "={{ $env.INSTAGRAM_ACCOUNT_ID }}"
            },
            {
              "id": "id-14",
              "name": "facebookGroupId",
              "type": "string",
              "value": "={{ $env.FACEBOOK_GROUP_ID }}"
            },
            {
              "id": "id-15",
              "name": "sendgridFromEmail",
              "type": "string",
              "value": "={{ $env.SENDGRID_FROM_EMAIL }}"
            },
            {
              "id": "id-16",
              "name": "sendgridToEmail",
              "type": "string",
              "value": "={{ $env.SENDGRID_TO_EMAIL }}"
            },
            {
              "id": "id-17",
              "name": "videoDbSheetId",
              "type": "string",
              "value": "={{ $env.VIDEO_DB_SHEET_ID }}"
            },
            {
              "id": "id-18",
              "name": "videoDbSheetName",
              "type": "string",
              "value": "={{ $env.VIDEO_DB_SHEET_NAME }}"
            },
            {
              "id": "id-19",
              "name": "commentsDbSheetId",
              "type": "string",
              "value": "={{ $env.COMMENTS_DB_SHEET_ID }}"
            },
            {
              "id": "id-20",
              "name": "commentsDbSheetName",
              "type": "string",
              "value": "={{ $env.COMMENTS_DB_SHEET_NAME }}"
            },
            {
              "id": "id-21",
              "name": "analyticsDbSheetId",
              "type": "string",
              "value": "={{ $env.ANALYTICS_DB_SHEET_ID }}"
            },
            {
              "id": "id-22",
              "name": "analyticsDbSheetName",
              "type": "string",
              "value": "={{ $env.ANALYTICS_DB_SHEET_NAME }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "fea7a4dd-12e3-4a6a-a001-f6a052f4a33c",
      "name": "Get Video Details",
      "type": "n8n-nodes-base.youTube",
      "position": [
        -30256,
        864
      ],
      "parameters": {
        "part": [
          "snippet",
          "statistics",
          "contentDetails"
        ],
        "options": {},
        "videoId": "={{ $json.videoId }}",
        "resource": "video",
        "operation": "get"
      },
      "typeVersion": 1
    },
    {
      "id": "efb7456f-72c4-45b1-847d-694ad24a7264",
      "name": "Prepare SEO Prompts",
      "type": "n8n-nodes-base.set",
      "position": [
        -30064,
        864
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "videoTitle",
              "type": "string",
              "value": "={{ $json.snippet.title }}"
            },
            {
              "id": "id-2",
              "name": "videoDescription",
              "type": "string",
              "value": "={{ $json.snippet.description }}"
            },
            {
              "id": "id-3",
              "name": "videoTags",
              "type": "array",
              "value": "={{ $json.snippet.tags }}"
            },
            {
              "id": "id-4",
              "name": "viewCount",
              "type": "number",
              "value": "={{ $json.statistics.viewCount }}"
            },
            {
              "id": "id-5",
              "name": "duration",
              "type": "string",
              "value": "={{ $json.contentDetails.duration }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "9347a97c-0e82-4fa3-ba1e-1aa7a9f4a0ad",
      "name": "Fetch Competitor Data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -29744,
        832
      ],
      "parameters": {
        "url": "={{ $('Workflow Configuration').first().json.competitorApiUrl }}",
        "options": {
          "timeout": 30000
        },
        "sendQuery": true,
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "topic",
              "value": "={{ $json.videoTitle }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "={{ 'Bearer ' + $('Workflow Configuration').first().json.competitorApiKey }}"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "1d328d98-a261-468d-a529-26fcbee60860",
      "name": "Fetch Trending Topics",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -29760,
        992
      ],
      "parameters": {
        "url": "={{ $('Workflow Configuration').first().json.trendingApiUrl }}",
        "options": {
          "timeout": 30000
        },
        "sendQuery": true,
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "category",
              "value": "={{ $json.snippet.categoryId }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "={{ 'Bearer ' + $('Workflow Configuration').first().json.trendingApiKey }}"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "b7f2fb0a-1ad3-4958-bf20-ac7232941616",
      "name": "Thumbnail Analysis API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -27024,
        352
      ],
      "parameters": {
        "url": "={{ $('Workflow Configuration').first().json.thumbnailApiUrl }}",
        "method": "POST",
        "options": {
          "timeout": 30000
        },
        "jsonBody": "={\n  \"videoId\": \"={{ $json.videoId }}\",\n  \"thumbnailUrl\": \"={{ $json.snippet.thumbnails.maxres.url }}\"\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "={{ 'Bearer ' + $('Workflow Configuration').first().json.thumbnailApiKey }}"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "dcab7b24-2f38-428c-969b-79ec28aa79a9",
      "name": "Clip Extraction Service",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -27024,
        544
      ],
      "parameters": {
        "url": "={{ $('Workflow Configuration').first().json.clipApiUrl }}",
        "method": "POST",
        "options": {
          "timeout": 30000
        },
        "jsonBody": "={\n  \"videoId\": \"{{ $json.videoId }}\",\n  \"duration\": \"{{ $json.duration }}\"\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "={{ 'Bearer ' + $('Workflow Configuration').first().json.clipApiKey }}"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "00d37079-d54d-42af-b11c-6718c507f7de",
      "name": "Calculate SEO Score",
      "type": "n8n-nodes-base.code",
      "position": [
        -28560,
        896
      ],
      "parameters": {
        "jsCode": "const data = $input.first().json;\n\n// Parse OpenAI JSON responses\nlet titleVariations = [];\nlet seoDescription = '';\nlet seoTags = [];\n\ntry {\n  // Parse title variations from OpenAI JSON response\n  if (data.message && typeof data.message === 'string') {\n    const parsed = JSON.parse(data.message);\n    titleVariations = parsed.titles || [];\n  } else if (data.titles) {\n    titleVariations = data.titles;\n  }\n} catch (e) {\n  titleVariations = [data.videoTitle || 'Untitled'];\n}\n\n// Parse description from OpenAI JSON response\ntry {\n  if (data.seoDescription && typeof data.seoDescription === 'string') {\n    const parsed = JSON.parse(data.seoDescription);\n    seoDescription = parsed.description || data.videoDescription || '';\n  } else if (data.description) {\n    seoDescription = data.description;\n  } else {\n    seoDescription = data.videoDescription || '';\n  }\n} catch (e) {\n  seoDescription = data.videoDescription || '';\n}\n\n// Parse tags from OpenAI JSON response\ntry {\n  if (data.seoTags && typeof data.seoTags === 'string') {\n    const parsed = JSON.parse(data.seoTags);\n    seoTags = parsed.tags || [];\n  } else if (data.tags && Array.isArray(data.tags)) {\n    seoTags = data.tags;\n  } else if (Array.isArray(data.seoTags)) {\n    seoTags = data.seoTags;\n  }\n} catch (e) {\n  seoTags = data.videoTags || [];\n}\n\n// Calculate SEO score\nconst titleScore = titleVariations.length >= 3 ? 30 : 0;\nconst descScore = seoDescription.length >= 150 ? 30 : 0;\nconst tagsScore = seoTags.length >= 10 ? 40 : seoTags.length * 4;\nconst seoScore = titleScore + descScore + tagsScore;\n\nreturn [{\n  json: {\n    videoId: data.videoId,\n    videoTitle: data.videoTitle,\n    videoDescription: data.videoDescription,\n    videoTags: data.videoTags,\n    duration: data.duration,\n    titleVariations,\n    seoDescription,\n    seoTags,\n    seoScore,\n    seoGrade: seoScore >= 80 ? 'A' : seoScore >= 60 ? 'B' : seoScore >= 40 ? 'C' : 'D'\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "91246287-5e99-4ea8-a45b-520595a2f1bf",
      "name": "A/B Title Routing Logic",
      "type": "n8n-nodes-base.code",
      "position": [
        -28368,
        896
      ],
      "parameters": {
        "jsCode": "const data = $input.first().json;\n\n// Assign A/B test variant (50/50 split based on video ID hash)\nconst videoId = data.videoId || '';\nconst hash = videoId.split('').reduce((acc, char) => acc + char.charCodeAt(0), 0);\nconst variant = hash % 2 === 0 ? 'A' : 'B';\n\n// Select title based on variant\nconst selectedTitle = variant === 'A' && data.titleVariations && data.titleVariations.length > 0 \n  ? data.titleVariations[0] \n  : data.videoTitle;\n\nreturn [{\n  json: {\n    ...data,\n    abVariant: variant,\n    selectedTitle: selectedTitle\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "2c87022c-8a19-4201-a821-e72ad71bff60",
      "name": "Aggregate Analytics Data",
      "type": "n8n-nodes-base.code",
      "position": [
        -27120,
        1616
      ],
      "parameters": {
        "jsCode": "const data = $input.first().json;\n\nif (!data || !data.id) {\n  return [{\n    json: {\n      error: 'No analytics data available',\n      videoId: 'unknown',\n      views: 0,\n      likes: 0,\n      comments: 0,\n      duration: 'PT0S',\n      timestamp: new Date().toISOString()\n    }\n  }];\n}\n\nreturn [{\n  json: {\n    videoId: data.id,\n    views: parseInt(data.statistics?.viewCount) || 0,\n    likes: parseInt(data.statistics?.likeCount) || 0,\n    comments: parseInt(data.statistics?.commentCount) || 0,\n    duration: data.contentDetails?.duration || 'PT0S',\n    timestamp: new Date().toISOString()\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "29cc190c-aecf-421e-98dc-f98a8565899a",
      "name": "Calculate Engagement Score",
      "type": "n8n-nodes-base.code",
      "position": [
        -26944,
        1616
      ],
      "parameters": {
        "jsCode": "const data = $input.first().json;\n\nif (data.error) {\n  return [{\n    json: {\n      ...data,\n      engagementScore: 0,\n      engagementGrade: 'N/A'\n    }\n  }];\n}\n\n// Calculate engagement rate\nconst views = data.views || 1;\nconst engagementScore = ((data.likes + data.comments) / views) * 100;\n\nreturn [{\n  json: {\n    ...data,\n    engagementScore: parseFloat(engagementScore.toFixed(2)),\n    engagementGrade: engagementScore >= 5 ? 'High' : engagementScore >= 2 ? 'Medium' : 'Low'\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "09fd99b2-437a-4a56-bfa6-a4d7aef00e58",
      "name": "Competitor Comparison",
      "type": "n8n-nodes-base.code",
      "position": [
        -29472,
        896
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\nconst videoData = items[0].json;\nconst competitorData = items.find(i => i.json.competitors)?.json || {};\nconst trendingData = items.find(i => i.json.trending)?.json || {};\n\nreturn [{\n  json: {\n    videoId: videoData.videoId,\n    channelId: videoData.channelId,\n    videoTitle: videoData.videoTitle,\n    videoDescription: videoData.videoDescription,\n    videoTags: videoData.videoTags || [],\n    viewCount: videoData.viewCount,\n    duration: videoData.duration,\n    competitors: competitorData.competitors || [],\n    trending: trendingData.trending || [],\n    competitorAvgViews: competitorData.avgViews || 0,\n    trendingKeywords: trendingData.keywords || []\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "404981db-18d9-4469-8799-e2c1b007e621",
      "name": "Check Video Length",
      "type": "n8n-nodes-base.if",
      "position": [
        -27312,
        448
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": false,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "id-1",
              "operator": {
                "type": "string",
                "operation": "gt"
              },
              "leftValue": "={{ $('Update Video Metadata').item.json.duration }}",
              "rightValue": "PT10M"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "f94fa92c-4827-403d-98d6-49b779a6362d",
      "name": "Detect High Engagement",
      "type": "n8n-nodes-base.if",
      "position": [
        -26752,
        1616
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": false,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "id-1",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $('Calculate Engagement Score').item.json.engagementGrade }}",
              "rightValue": "High"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "708d7735-f112-48db-af5b-54f197d4e6aa",
      "name": "Check Viral Potential",
      "type": "n8n-nodes-base.if",
      "position": [
        -26496,
        1616
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": false,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "id-1",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $('Calculate Engagement Score').item.json.views }}",
              "rightValue": "10000"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "e2c67fc3-da30-477a-b9d7-b1561d86be7e",
      "name": "Check Platform Availability",
      "type": "n8n-nodes-base.if",
      "position": [
        -25824,
        448
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "id-1",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              },
              "leftValue": "={{ $('Format Platform Posts').item.json.linkedinPost }}"
            },
            {
              "id": "id-2",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              },
              "leftValue": "={{ $('Format Platform Posts').item.json.instagramPost }}"
            },
            {
              "id": "id-3",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              },
              "leftValue": "={{ $('Format Platform Posts').item.json.facebookPost }}"
            },
            {
              "id": "id-4",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              },
              "leftValue": "={{ $('Format Platform Posts').item.json.twitterPost }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "7b2cdbc3-6928-4b29-9e85-c85eea0307ad",
      "name": "A/B Test Variant Selection",
      "type": "n8n-nodes-base.if",
      "position": [
        -28176,
        896
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "id-1",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $('A/B Title Routing Logic').item.json.abVariant }}",
              "rightValue": "A"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "46633b87-c83b-41f7-84ed-963ea4def66b",
      "name": "Detect Negative Comments",
      "type": "n8n-nodes-base.if",
      "position": [
        -26752,
        1024
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": false,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "id-1",
              "operator": {
                "type": "array",
                "operation": "contains"
              },
              "leftValue": "={{ $json.responses }}",
              "rightValue": "true"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "17ede704-1587-423a-b78d-cbce7c16b557",
      "name": "Update Video Metadata",
      "type": "n8n-nodes-base.youTube",
      "position": [
        -27792,
        880
      ],
      "parameters": {
        "title": "={{ $json.selectedTitle }}",
        "videoId": "={{ $json.videoId }}",
        "resource": "video",
        "operation": "update",
        "updateFields": {
          "tags": "={{ $json.seoTags }}",
          "description": "={{ $json.seoDescription }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6f068d5b-dace-42fe-9acf-43643ecb1034",
      "name": "Fetch Video Analytics",
      "type": "n8n-nodes-base.youTube",
      "position": [
        -27296,
        1616
      ],
      "parameters": {
        "part": [
          "statistics",
          "contentDetails"
        ],
        "options": {},
        "videoId": "={{ $('Workflow Configuration').first().json.videoId }}",
        "resource": "video",
        "operation": "get"
      },
      "typeVersion": 1
    },
    {
      "id": "e0034584-e23d-4752-8bc1-aad2650ebf39",
      "name": "Fetch Video Comments",
      "type": "n8n-nodes-base.youTube",
      "position": [
        -27328,
        1024
      ],
      "parameters": {
        "resource": "videoComment"
      },
      "typeVersion": 1
    },
    {
      "id": "65d12f4f-e990-412f-8243-02d03a8137dd",
      "name": "Prepare Cross-Platform Context",
      "type": "n8n-nodes-base.set",
      "position": [
        -26736,
        448
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "videoUrl",
              "type": "string",
              "value": "=https://youtube.com/watch?v={{ $json.videoId }}"
            },
            {
              "id": "id-2",
              "name": "clipUrl",
              "type": "string",
              "value": "={{ $json.clipUrl }}"
            },
            {
              "id": "id-3",
              "name": "thumbnailScore",
              "type": "number",
              "value": "={{ $json.score }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "97981719-e989-466f-9b3e-6299d6393391",
      "name": "Format Platform Posts",
      "type": "n8n-nodes-base.set",
      "position": [
        -26112,
        448
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "linkedinPost",
              "type": "string",
              "value": "={{ typeof $json.message === 'string' ? JSON.parse($json.message).linkedin : ($json.linkedin || '') }}"
            },
            {
              "id": "id-2",
              "name": "twitterPost",
              "type": "string",
              "value": "={{ typeof $json.message === 'string' ? JSON.parse($json.message).twitter : ($json.twitter || '') }}"
            },
            {
              "id": "id-3",
              "name": "instagramPost",
              "type": "string",
              "value": "={{ typeof $json.message === 'string' ? JSON.parse($json.message).instagram : ($json.instagram || '') }}"
            },
            {
              "id": "id-4",
              "name": "tiktokPost",
              "type": "string",
              "value": "={{ typeof $json.message === 'string' ? JSON.parse($json.message).tiktok : ($json.tiktok || '') }}"
            },
            {
              "id": "id-5",
              "name": "facebookPost",
              "type": "string",
              "value": "={{ typeof $json.message === 'string' ? JSON.parse($json.message).facebook : ($json.facebook || '') }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "8b619e95-c405-4582-b5ae-8bc932c661f0",
      "name": "Post to LinkedIn",
      "type": "n8n-nodes-base.linkedIn",
      "position": [
        -25600,
        160
      ],
      "parameters": {
        "text": "={{ $json.linkedinPost }}",
        "person": "={{ $('Workflow Configuration').first().json.linkedinPersonId }}",
        "additionalFields": {}
      },
      "typeVersion": 1
    },
    {
      "id": "e7b1a496-1f8c-4c36-be19-f4c627e48705",
      "name": "Post Twitter Thread",
      "type": "n8n-nodes-base.twitter",
      "position": [
        -25600,
        352
      ],
      "parameters": {
        "text": "={{ $json.twitterPost }}",
        "additionalFields": {}
      },
      "typeVersion": 2
    },
    {
      "id": "a70258df-9d8d-410b-ab9e-9764f03e6ff4",
      "name": "Upload Instagram Reel",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        -25600,
        544
      ],
      "parameters": {
        "edge": "media",
        "node": "={{ $('Workflow Configuration').first().json.instagramAccountId }}",
        "options": {},
        "graphApiVersion": "v18.0",
        "httpRequestMethod": "POST"
      },
      "typeVersion": 1
    },
    {
      "id": "ebde6690-6958-469b-b8f4-b7071879e0d7",
      "name": "Post to Facebook Group",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        -25600,
        736
      ],
      "parameters": {
        "edge": "feed",
        "node": "={{ $('Workflow Configuration').first().json.facebookGroupId }}",
        "options": {},
        "graphApiVersion": "v18.0",
        "httpRequestMethod": "POST"
      },
      "typeVersion": 1
    },
    {
      "id": "3b55c58d-792d-4f04-9220-97af2c39872e",
      "name": "Send Email Newsletter",
      "type": "n8n-nodes-base.sendGrid",
      "position": [
        -25792,
        1616
      ],
      "parameters": {
        "subject": "Weekly YouTube Analytics Report",
        "toEmail": "={{ $('Workflow Configuration').first().json.sendgridToEmail }}",
        "resource": "mail",
        "fromEmail": "={{ $('Workflow Configuration').first().json.sendgridFromEmail }}",
        "contentType": "text/html",
        "contentValue": "={{ $json.report || $json.message || 'Weekly analytics report' }}",
        "additionalFields": {}
      },
      "typeVersion": 1
    },
    {
      "id": "a9e63143-78d1-48d8-af1b-c02533124395",
      "name": "Log to Video Database",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -27872,
        1632
      ],
      "parameters": {
        "columns": {
          "value": {
            "videoId": "={{ $json.videoId }}",
            "seoScore": "={{ $json.seoScore }}",
            "abVariant": "={{ $json.abVariant }}",
            "publishedAt": "={{ $json.publishedAt }}",
            "selectedTitle": "={{ $json.selectedTitle }}"
          },
          "mappingMode": "defineBelow"
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $('Workflow Configuration').first().json.videoDbSheetName }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Workflow Configuration').first().json.videoDbSheetId }}"
        },
        "authentication": "serviceAccount"
      },
      "typeVersion": 4.7
    },
    {
      "id": "ed09dc2c-7acb-4ef0-bf0e-72f3d2aec029",
      "name": "Log Comments",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -26432,
        1184
      ],
      "parameters": {
        "columns": {
          "value": {
            "videoId": "={{ $json.videoId }}",
            "response": "={{ $json.response }}",
            "commentId": "={{ $json.commentId }}",
            "timestamp": "={{ $json.timestamp }}",
            "isNegative": "={{ $json.isNegative }}"
          },
          "mappingMode": "defineBelow"
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $('Workflow Configuration').first().json.commentsDbSheetName }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Workflow Configuration').first().json.commentsDbSheetId }}"
        },
        "authentication": "serviceAccount"
      },
      "typeVersion": 4.7
    },
    {
      "id": "8f8b0751-c007-4f31-9576-f6a512ddf6ac",
      "name": "Log Strategic Insights",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -25968,
        1616
      ],
      "parameters": {
        "columns": {
          "value": {
            "likes": "={{ $json.likes }}",
            "views": "={{ $json.views }}",
            "videoId": "={{ $json.videoId }}",
            "comments": "={{ $json.comments }}",
            "timestamp": "={{ $now }}",
            "viralPotential": "={{ $json.viralPotential }}",
            "engagementScore": "={{ $json.engagementScore }}"
          },
          "mappingMode": "defineBelow"
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $('Workflow Configuration').first().json.analyticsDbSheetName }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Workflow Configuration').first().json.analyticsDbSheetId }}"
        },
        "authentication": "serviceAccount"
      },
      "typeVersion": 4.7
    },
    {
      "id": "9bd3b05b-391d-4a4d-9bb6-36f8c0e143ee",
      "name": "Slack - Video Published Alert",
      "type": "n8n-nodes-base.slack",
      "position": [
        -27792,
        1248
      ],
      "parameters": {
        "text": "=\ud83c\udfa5 New Video Published!\n\nTitle: {{ $json.selectedTitle || $json.videoTitle || 'Untitled' }}\nSEO Score: {{ $json.seoScore || 0 }}/100 ({{ $json.seoGrade || 'N/A' }})\nA/B Variant: {{ $json.abVariant || 'N/A' }}\nVideo URL: https://youtube.com/watch?v={{ $json.videoId }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Workflow Configuration').first().json.slackChannel }}"
        },
        "otherOptions": {}
      },
      "typeVersion": 2.3
    },
    {
      "id": "da20a613-a4f4-4fb1-a534-66ec58ff5ecd",
      "name": "Slack - Viral Potential Alert",
      "type": "n8n-nodes-base.slack",
      "position": [
        -26432,
        1008
      ],
      "parameters": {
        "text": "=\ud83d\udea8 Viral Potential Detected!\n\nVideo: {{ $json.videoId || 'Unknown' }}\nViews: {{ $json.views || 0 }}\nEngagement: {{ $json.engagementScore || 0 }}%\nNegative Comments Detected: Review needed!",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Workflow Configuration').first().json.slackChannel }}"
        },
        "otherOptions": {}
      },
      "typeVersion": 2.3
    },
    {
      "id": "d87340ab-20d6-4aca-aae8-368e9e065b08",
      "name": "Weekly Analytics Schedule",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -27456,
        1616
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                1
              ],
              "triggerAtHour": 9
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "08c2558b-1e40-4c8e-bf63-acb945d43216",
      "name": "Merge SEO Data",
      "type": "n8n-nodes-base.merge",
      "position": [
        -28752,
        880
      ],
      "parameters": {
        "mode": "combine",
        "options": {
          "includeUnpaired": true
        },
        "combineBy": "combineByPosition",
        "numberInputs": 3
      },
      "typeVersion": 3.2
    },
    {
      "id": "2fb4774d-ac28-4c3c-8f75-d5a48cb8ad6f",
      "name": "Generate Cross-Platform Content1",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -26528,
        448
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "id",
          "value": "gpt-4o"
        },
        "options": {},
        "responses": {
          "values": [
            {
              "content": "=Generate platform-specific social media posts to promote this YouTube video.\n\nVideo Title: {{ $json.selectedTitle }}\nVideo URL: {{ $json.videoUrl }}\nClip URL: {{ $json.clipUrl || 'N/A' }}\n\nCreate engaging posts optimized for each platform's character limits and style.\n\nReturn ONLY valid JSON with this exact structure:\n{\"linkedin\": \"post text\", \"twitter\": \"post text\", \"instagram\": \"post text\", \"tiktok\": \"post text\", \"facebook\": \"post text\"}"
            }
          ]
        },
        "builtInTools": {}
      },
      "typeVersion": 2
    },
    {
      "id": "2dcefdd7-4bbd-44d4-a719-c5af4e6edd6c",
      "name": "Generate Comment Responses1",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -27104,
        1024
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "id",
          "value": "gpt-4o"
        },
        "options": {},
        "responses": {
          "values": [
            {
              "content": "=Analyze YouTube comments and generate appropriate responses. Flag negative/toxic comments.\n\nComments: {{ JSON.stringify($json.items) }}\n\nReturn ONLY valid JSON with this exact structure:\n{\"responses\": [{\"commentId\": \"id\", \"response\": \"text\", \"isNegative\": true/false}]}"
            }
          ]
        },
        "builtInTools": {}
      },
      "typeVersion": 2
    },
    {
      "id": "145c5871-c261-41ae-981f-d497a96e4ff4",
      "name": "Generate Weekly Report1",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -26256,
        1616
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "id",
          "value": "gpt-4o"
        },
        "options": {},
        "responses": {
          "values": [
            {
              "content": "=Generate a comprehensive weekly YouTube analytics report with strategic recommendations.\n\nAnalytics Data: {{ JSON.stringify($json) }}\n\nAnalyze: engagement trends, viral potential, content recommendations, optimal posting times.\n\nReturn ONLY valid JSON with this exact structure:\n{\"report\": \"<html>your HTML report here</html>\", \"summary\": \"brief summary\"}"
            }
          ]
        },
        "builtInTools": {}
      },
      "typeVersion": 2
    },
    {
      "id": "08fe2e93-8312-490f-b477-8592f4111a90",
      "name": "Set Variant B Data",
      "type": "n8n-nodes-base.set",
      "position": [
        -28176,
        1136
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "abVariant",
              "type": "string",
              "value": "B"
            },
            {
              "id": "id-2",
              "name": "selectedTitle",
              "type": "string",
              "value": "={{ $json.titleVariations && $json.titleVariations.length > 1 ? $json.titleVariations[1] : $json.videoTitle }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "b07b3d66-bcd6-46cc-986f-83e341b0d267",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -30688,
        128
      ],
      "parameters": {
        "width": 928,
        "height": 560,
        "content": "## How it works\nThis workflow automates the full post-publish process for a new YouTube video: SEO optimization, cross-platform promotion, and engagement monitoring.\n\nWhen a new video is published, the workflow pulls the video metadata (title, description, tags, basic stats) and prepares a clean context payload. It then fetches competitor signals and trending topics, merges everything into one comparison context, and uses AI to generate improved title variations, an SEO-focused description, and optimized tags. A scoring step evaluates the generated assets, selects an A/B variant, and updates the video metadata on YouTube.\n\nIf the video meets the configured length threshold, the workflow can run thumbnail analysis and trigger a clip/shorts extraction step to create promo-ready snippets.\n\nNext, it generates platform-specific promo content (LinkedIn, X/Twitter, Instagram, Facebook), formats posts per platform, checks which channels are enabled, and publishes automatically. It also sends a Slack alert when a new video goes live.\n\nFinally, the workflow monitors comments (including negative sentiment detection), logs key data to Google Sheets, and runs a weekly analytics job that aggregates performance, calculates engagement/viral indicators, and emails a weekly report with insights.\n\n## Setup steps\n1. Connect YouTube (API/credentials) and set required IDs in **Workflow Configuration**.\n2. Connect OpenAI and adjust prompts/templates if needed.\n3. Connect Slack + choose alert channels.\n4. Connect Google Sheets (comments log + video database).\n5. Configure social posting credentials/APIs and enable only the platforms you use.\n6. Send a test publish event and verify: metadata updates, posts, logging, and weekly report."
      },
      "typeVersion": 1
    },
    {
      "id": "c627b913-885e-4b51-a354-261309e9ee91",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -30688,
        720
      ],
      "parameters": {
        "color": 7,
        "width": 368,
        "height": 304,
        "content": "## Triggers & Configuration\nStarts on new video publish (webhook) and runs weekly for reporting. Loads environment variables, IDs, and shared settings used across the workflow."
      },
      "typeVersion": 1
    },
    {
      "id": "750c4cfe-9711-404f-92e9-5f8de7b08187",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -30288,
        720
      ],
      "parameters": {
        "color": 7,
        "width": 368,
        "height": 304,
        "content": "## Video Intake\nFetches the published video metadata (title/description/tags/stats) and prepares a compact context payload for SEO generation and comparisons."
      },
      "typeVersion": 1
    },
    {
      "id": "38453d10-a556-4f24-b9ed-b3ca1447a56b",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -29888,
        720
      ],
      "parameters": {
        "color": 7,
        "width": 560,
        "height": 400,
        "content": "## Competitor & Trend Signals\nPulls competitor signals and trending topics, then merges them into a single comparison context used by the AI and scoring steps."
      },
      "typeVersion": 1
    },
    {
      "id": "f3daa799-269a-4b4a-8595-c44d55857f7b",
      "name": "Generate Title Variations",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -29168,
        704
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "id",
          "value": "gpt-4o"
        },
        "options": {},
        "responses": {
          "values": [
            {
              "content": "=Generate 3 SEO-optimized title variations for YouTube.\n\nOriginal Title: {{ $json.videoTitle }}\nCompetitor Titles: {{ JSON.stringify($json.competitors) }}\nTrending Keywords: {{ JSON.stringify($json.trendingKeywords) }}\n\nReturn ONLY valid JSON with this exact structure:\n{\"titles\": [\"title1\", \"title2\", \"title3\"]}"
            }
          ]
        },
        "builtInTools": {}
      },
      "typeVersion": 2
    },
    {
      "id": "572f0235-b68b-4406-aca3-6ac0e401afd2",
      "name": "Generate SEO Description",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -29168,
        896
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "id",
          "value": "gpt-4o"
        },
        "options": {},
        "responses": {
          "values": [
            {
              "content": "=Generate an SEO-optimized YouTube video description.\n\nOriginal Description: {{ $json.videoDescription }}\nTrending Keywords: {{ JSON.stringify($json.trendingKeywords) }}\n\nRequirements: 150-200 words, keyword-rich, engaging.\n\nReturn ONLY valid JSON with this exact structure:\n{\"description\": \"your description here\"}"
            }
          ]
        },
        "builtInTools": {}
      },
      "typeVersion": 2
    },
    {
      "id": "04c86bb5-e54b-48d6-b51b-a4dda3e846b2",
      "name": "Generate Tags",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -29168,
        1104
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "id",
          "value": "gpt-4o"
        },
        "options": {},
        "responses": {
          "values": [
            {
              "content": "=Generate 10-15 SEO-optimized tags for YouTube.\n\nVideo Title: {{ $json.videoTitle }}\nTrending Keywords: {{ JSON.stringify($json.trendingKeywords) }}\n\nReturn ONLY valid JSON with this exact structure:\n{\"tags\": [\"tag1\", \"tag2\", \"tag3\", ...]}"
            }
          ]
        },
        "builtInTools": {}
      },
      "typeVersion": 2
    },
    {
      "id": "34fe2254-db25-4594-99d4-1fec9f89ee0e",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -29296,
        592
      ],
      "parameters": {
        "color": 7,
        "width": 672,
        "height": 688,
        "content": "## Generate SEO Assets (AI)\nGenerates title variations, SEO description, and tags from the merged context, then consolidates all outputs into one structured SEO payload."
      },
      "typeVersion": 1
    },
    {
      "id": "1558d101-dcb7-4cc9-beae-2e62a0ecd146",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -28592,
        800
      ],
      "parameters": {
        "color": 7,
        "width": 576,
        "height": 480,
        "content": "## SEO Scoring & A/B Selection\nScores the generated SEO assets and applies A/B routing logic to select the final title variant to push to YouTube."
      },
      "typeVersion": 1
    },
    {
      "id": "3f8dd8f2-7b11-48de-8ae9-fd038f36a57f",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -27920,
        768
      ],
      "parameters": {
        "color": 7,
        "width": 368,
        "height": 272,
        "content": "## Update YouTube Metadata\nApplies the selected title, description, and tags to the published video via the YouTube update step."
      },
      "typeVersion": 1
    },
    {
      "id": "666eee34-1adb-41ca-9f31-b0066a7ecc22",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -27360,
        256
      ],
      "parameters": {
        "color": 7,
        "width": 768,
        "height": 448,
        "content": "## Clip & Thumbnail Processing\nIf the video meets the configured length threshold, runs thumbnail analysis and triggers clip/shorts extraction for promotion assets."
      },
      "typeVersion": 1
    },
    {
      "id": "d8e56b0a-3867-41d9-99f3-112dfb7c94f0",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -26560,
        96
      ],
      "parameters": {
        "color": 7,
        "width": 1136,
        "height": 800,
        "content": "## Cross-Platform Promotion\nBuilds platform-specific promo context, generates copy, formats posts, checks enabled platforms, and publishes to each connected channel."
      },
      "typeVersion": 1
    },
    {
      "id": "bacf73c9-d5a7-4b0f-b57f-971df994cf87",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -27376,
        928
      ],
      "parameters": {
        "color": 7,
        "width": 1120,
        "height": 416,
        "content": "## Comments Monitoring & Logging\nFetches comments, drafts reply suggestions, detects negative sentiment, and logs comments plus responses to Google Sheets for tracking."
      },
      "typeVersion": 1
    },
    {
      "id": "693a4960-ab2c-41c5-adcc-448dda72e265",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -27920,
        1504
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 288,
        "content": "## Storage (Video Database)\nLogs the video record and SEO score to Google Sheets to keep a historical dataset for reporting and optimization."
      },
      "typeVersion": 1
    },
    {
      "id": "9fc344da-f611-46b5-b430-06598bf66968",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -27504,
        1520
      ],
      "parameters": {
        "color": 7,
        "width": 1904,
        "height": 272,
        "content": "## Weekly Analytics & Reporting\nCollects weekly video analytics, aggregates performance, calculates engagement and viral indicators, logs insights, and emails a weekly report/newsletter."
      },
      "typeVersion": 1
    },
    {
      "id": "67685efc-c6b4-4906-b47a-988d28ea1a99",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -27840,
        1120
      ],
      "parameters": {
        "color": 7,
        "width": 272,
        "height": 304,
        "content": "## Alerts & Notifications\nSends immediate Slack alerts when a new video is published\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "4368a80f-7863-42c6-beb4-03d005be4d30",
  "connections": {
    "Generate Tags": {
      "main": [
        [
          {
            "node": "Merge SEO Data",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Merge SEO Data": {
      "main": [
        [
          {
            "node": "Calculate SEO Score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Video Details": {
      "main": [
        [
          {
            "node": "Prepare SEO Prompts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Video Length": {
      "main": [
        [
          {
            "node": "Thumbnail Analysis API",
            "type": "main",
            "index": 0
          },
          {
            "node": "Clip Extraction Service",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Variant B Data": {
      "main": [
        [
          {
            "node": "Update Video Metadata",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate SEO Score": {
      "main": [
        [
          {
            "node": "A/B Title Routing Logic",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare SEO Prompts": {
      "main": [
        [
          {
            "node": "Fetch Competitor Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch Trending Topics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Video Comments": {
      "main": [
        [
          {
            "node": "Generate Comment Responses1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Viral Potential": {
      "main": [
        [
          {
            "node": "Generate Weekly Report1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Competitor Comparison": {
      "main": [
        [
          {
            "node": "Generate Title Variations",
            "type": "main",
            "index": 0
          },
          {
            "node": "Generate SEO Description",
            "type": "main",
            "index": 0
          },
          {
            "node": "Generate Tags",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Competitor Data": {
      "main": [
        [
          {
            "node": "Competitor Comparison",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Trending Topics": {
      "main": [
        [
          {
            "node": "Competitor Comparison",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Video Analytics": {
      "main": [
        [
          {
            "node": "Aggregate Analytics Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Platform Posts": {
      "main": [
        [
          {
            "node": "Check Platform Availability",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Video Metadata": {
      "main": [
        [
          {
            "node": "Check Video Length",
            "type": "main",
            "index": 0
          },
          {
            "node": "Log to Video Database",
            "type": "main",
            "index": 0
          },
          {
            "node": "Slack - Video Published Alert",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch Video Comments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Detect High Engagement": {
      "main": [
        [
          {
            "node": "Check Viral Potential",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Strategic Insights": {
      "main": [
        [
          {
            "node": "Send Email Newsletter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Thumbnail Analysis API": {
      "main": [
        [
          {
            "node": "Prepare Cross-Platform Context",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Configuration": {
      "main": [
        [
          {
            "node": "Get Video Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "A/B Title Routing Logic": {
      "main": [
        [
          {
            "node": "A/B Test Variant Selection",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clip Extraction Service": {
      "main": [
        [
          {
            "node": "Prepare Cross-Platform Context",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Weekly Report1": {
      "main": [
        [
          {
            "node": "Log Strategic Insights",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Video Published Webhook": {
      "main": [
        [
          {
            "node": "Workflow Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Analytics Data": {
      "main": [
        [
          {
            "node": "Calculate Engagement Score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Detect Negative Comments": {
      "main": [
        [
          {
            "node": "Slack - Viral Potential Alert",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log Comments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate SEO Description": {
      "main": [
        [
          {
            "node": "Merge SEO Data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Generate Title Variations": {
      "main": [
        [
          {
            "node": "Merge SEO Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Weekly Analytics Schedule": {
      "main": [
        [
          {
            "node": "Fetch Video Analytics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "A/B Test Variant Selection": {
      "main": [
        [
          {
            "node": "Update Video Metadata",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set Variant B Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate Engagement Score": {
      "main": [
        [
          {
            "node": "Detect High Engagement",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Platform Availability": {
      "main": [
        [
          {
            "node": "Post to LinkedIn",
            "type": "main",
            "index": 0
          },
          {
            "node": "Post Twitter Thread",
            "type": "main",
            "index": 0
          },
          {
            "node": "Upload Instagram Reel",
            "type": "main",
            "index": 0
          },
          {
            "node": "Post to Facebook Group",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Email Newsletter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Comment Responses1": {
      "main": [
        [
          {
            "node": "Detect Negative Comments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Cross-Platform Context": {
      "main": [
        [
          {
            "node": "Generate Cross-Platform Content1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Cross-Platform Content1": {
      "main": [
        [
          {
            "node": "Format Platform Posts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}