{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "32926691-658c-4e36-a04a-e4ac0d887348",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1712,
        -16
      ],
      "parameters": {
        "color": 4,
        "width": 492,
        "height": 1028,
        "content": "## Multi-Platform Video Script Factory \u2014 GPT-4o-mini + Sheets + Gmail\n\nFor content creators, social media managers, and marketing agencies who need to repurpose one video topic into three platform-ready scripts without writing anything manually. Submit a single topic via the form and GPT-4o-mini generates all three scripts in one API call \u2014 a structured 700\u2013900 word YouTube long-form script, a fast-paced 100\u2013130 word Instagram Reels script with visual cues in brackets, and a punchy 50\u201370 word TikTok script that ends with a comment question. Each script includes a hook, full spoken script, platform-specific CTA, and 8 hashtags. All three rows are logged to Google Sheets and delivered to your inbox in one email.\n\n## How it works\n- **1. Form \u2014 Multi-Platform Video Topic** collects video topic, target audience, niche, tone of voice, and your name\n- **2. Set \u2014 Config Values** stores Sheet ID, recipient email, sender name, and all form values\n- **3. AI Agent \u2014 Write 3 Platform Scripts** uses GPT-4o-mini at temperature 0.7 to generate all 3 scripts in one call: YouTube (700\u2013900 words), Instagram Reels (100\u2013130 words with visual cues), TikTok (50\u201370 words, ends with question)\n- **6. Code \u2014 Split Scripts for Sheets** extracts the 3 platform objects into one item each, marks isLastRow on TikTok, carries allScripts on the last item only\n- **7. Google Sheets \u2014 Log Video Scripts** appends one row per platform \u2014 3 rows per run\n- **8. IF \u2014 All Scripts Logged?** gates the Gmail send so it fires exactly once after all 3 rows are saved\n- **9. Code \u2014 Build Email** reads allScripts from the last item and builds one structured plain text email with all 3 scripts\n- **10. Gmail \u2014 Send Scripts Email** delivers all 3 scripts in one message ready to copy and record\n\n## Set up steps\n1. In **2. Set \u2014 Config Values** \u2014 replace PASTE_YOUR_GOOGLE_SHEET_ID_HERE, PASTE_YOUR_EMAIL_HERE, and PASTE_YOUR_NAME_HERE\n2. In **4. OpenAI \u2014 GPT-4o-mini Model** \u2014 connect your OpenAI credential\n3. In **7. Google Sheets \u2014 Log Video Scripts** \u2014 connect your Google Sheets OAuth2 credential\n4. In **10. Gmail \u2014 Send Scripts Email** \u2014 connect your Gmail OAuth2 credential\n5. Create a Google Sheet tab named Video Scripts with columns: Date, Topic, Platform, Script Length, Hook, Script, CTA, Tags, Submitted By"
      },
      "typeVersion": 1
    },
    {
      "id": "ba37cc8a-1982-4245-952c-161b739bac8f",
      "name": "Section \u2014 Form Input and Config",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1184,
        288
      ],
      "parameters": {
        "color": 5,
        "width": 452,
        "height": 340,
        "content": "## Form Input and Config\nUser submits one video topic with target audience, niche, and optional tone. Config stores Sheet ID, email, sender name, and all form values. Niche and tone personalize all three platform scripts."
      },
      "typeVersion": 1
    },
    {
      "id": "d19345f9-8fda-4bee-b412-cc34eb74d240",
      "name": "Section \u2014 AI Script Generation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -688,
        96
      ],
      "parameters": {
        "color": 6,
        "width": 340,
        "height": 900,
        "content": "## AI Script Generation \u2014 All 3 Platforms\nOne GPT-4o-mini call generates all 3 scripts simultaneously. YouTube: 700\u2013900 words, structured with intro, 3 main points, conclusion. Instagram Reels: 100\u2013130 words, fast-paced, visual cues in brackets. TikTok: 50\u201370 words, one idea, punchy, ends with comment question. Structured Output Parser enforces the nested 3-platform schema."
      },
      "typeVersion": 1
    },
    {
      "id": "68ad6da8-3fa1-4e9f-8309-2f91f8741169",
      "name": "Section \u2014 Script Split, Sheet Logging, and Email Delivery",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -272,
        96
      ],
      "parameters": {
        "color": 4,
        "width": 852,
        "height": 804,
        "content": "## Script Split, Sheet Logging, and Email Delivery\nSplits the 3 scripts to one item per platform. Google Sheets logs all 3 rows. The IF node gates the email so it fires exactly once after all rows are saved \u2014 on the TikTok item (isLastRow). Build Email reads allScripts from the last item and assembles the full 3-script email."
      },
      "typeVersion": 1
    },
    {
      "id": "89b07d77-f142-40db-8e48-32ad5b63ad64",
      "name": "1. Form \u2014 Multi-Platform Video Topic",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -1104,
        448
      ],
      "parameters": {
        "options": {},
        "formTitle": "Multi-Platform Video Script Generator",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Video Topic",
              "placeholder": "Example: 5 ways to get more clients as a law firm using SEO",
              "requiredField": true
            },
            {
              "fieldLabel": "Target Audience",
              "placeholder": "Example: law firm owners, medical spa owners, SaaS founders",
              "requiredField": true
            },
            {
              "fieldLabel": "Your Niche or Industry",
              "placeholder": "Example: legal marketing, health and wellness, B2B SaaS",
              "requiredField": true
            },
            {
              "fieldLabel": "Tone of Voice",
              "placeholder": "Example: educational, motivational, direct, conversational"
            },
            {
              "fieldLabel": "Your Name",
              "placeholder": "Example: Rahul Dutt"
            }
          ]
        },
        "formDescription": "One topic. Three scripts. YouTube long form, Instagram Reels, and TikTok \u2014 all written and ready to record."
      },
      "typeVersion": 2.2
    },
    {
      "id": "2b9bc312-64db-434b-b8fc-573669d5a624",
      "name": "2. Set \u2014 Config Values",
      "type": "n8n-nodes-base.set",
      "position": [
        -880,
        448
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "cfg-001",
              "name": "sheetId",
              "type": "string",
              "value": "PASTE_YOUR_GOOGLE_SHEET_ID_HERE"
            },
            {
              "id": "cfg-002",
              "name": "sheetName",
              "type": "string",
              "value": "Video Scripts"
            },
            {
              "id": "cfg-003",
              "name": "recipientEmail",
              "type": "string",
              "value": "PASTE_YOUR_EMAIL_HERE"
            },
            {
              "id": "cfg-004",
              "name": "senderName",
              "type": "string",
              "value": "PASTE_YOUR_NAME_HERE"
            },
            {
              "id": "cfg-005",
              "name": "videoTopic",
              "type": "string",
              "value": "={{ $json['Video Topic'] }}"
            },
            {
              "id": "cfg-006",
              "name": "targetAudience",
              "type": "string",
              "value": "={{ $json['Target Audience'] }}"
            },
            {
              "id": "cfg-007",
              "name": "niche",
              "type": "string",
              "value": "={{ $json['Your Niche or Industry'] }}"
            },
            {
              "id": "cfg-008",
              "name": "toneOfVoice",
              "type": "string",
              "value": "={{ $json['Tone of Voice'] || 'educational and engaging' }}"
            },
            {
              "id": "cfg-009",
              "name": "submittedBy",
              "type": "string",
              "value": "={{ $json['Your Name'] || 'Unknown' }}"
            },
            {
              "id": "cfg-010",
              "name": "today",
              "type": "string",
              "value": "={{ $now.toFormat('dd MMM yyyy') }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c68a8b7e-e19d-4645-8a94-7695f0eecb5b",
      "name": "3. AI Agent \u2014 Write 3 Platform Scripts",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -656,
        448
      ],
      "parameters": {
        "text": "=You are a professional video scriptwriter for social media content creators.\n\nWrite scripts for exactly 3 platforms from this one topic.\n\nTopic: {{ $json.videoTopic }}\nAudience: {{ $json.targetAudience }}\nNiche: {{ $json.niche }}\nTone: {{ $json.toneOfVoice }}\n\nReturn ONLY a valid JSON object. No extra text. No markdown. No backticks.\n\nThe JSON must have exactly 3 keys: youtube, reels, tiktok\n\nEach key must have exactly these fields:\n\nhook\nThe opening line or sentence. Under 20 words. Must grab attention immediately.\n\nscript\nThe full spoken script for this platform. Plain text only. No bullet points. No markdown.\nFor youtube: 700 to 900 words. Structured with intro, 3 main points, and conclusion.\nFor reels: 100 to 130 words. Fast paced. Visual cues in brackets like [hold up phone] when helpful.\nFor tiktok: 50 to 70 words. One idea only. Punchy and direct. End with one question for comments.\n\ncta\nCall to action for this specific platform. One sentence.\nFor youtube: ask to subscribe and comment.\nFor reels: ask to save and follow.\nFor tiktok: ask to follow for more.\n\ntags\nArray of 8 hashtag strings relevant to this platform and niche. Include the # symbol. Mix broad and niche tags.",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.7
    },
    {
      "id": "6fe487dc-821b-49f4-ab12-d8e658bab9ab",
      "name": "4. OpenAI \u2014 GPT-4o-mini Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -656,
        656
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {
          "maxTokens": 2500,
          "temperature": 0.7
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f202a944-e213-4ca0-932f-225f71ff1c96",
      "name": "5. Parser \u2014 Structured Scripts Output",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -512,
        784
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"youtube\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"hook\": { \"type\": \"string\" },\n        \"script\": { \"type\": \"string\" },\n        \"cta\": { \"type\": \"string\" },\n        \"tags\": { \"type\": \"array\", \"items\": { \"type\": \"string\" } }\n      },\n      \"required\": [\"hook\", \"script\", \"cta\", \"tags\"]\n    },\n    \"reels\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"hook\": { \"type\": \"string\" },\n        \"script\": { \"type\": \"string\" },\n        \"cta\": { \"type\": \"string\" },\n        \"tags\": { \"type\": \"array\", \"items\": { \"type\": \"string\" } }\n      },\n      \"required\": [\"hook\", \"script\", \"cta\", \"tags\"]\n    },\n    \"tiktok\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"hook\": { \"type\": \"string\" },\n        \"script\": { \"type\": \"string\" },\n        \"cta\": { \"type\": \"string\" },\n        \"tags\": { \"type\": \"array\", \"items\": { \"type\": \"string\" } }\n      },\n      \"required\": [\"hook\", \"script\", \"cta\", \"tags\"]\n    }\n  },\n  \"required\": [\"youtube\", \"reels\", \"tiktok\"]\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "aaeec87f-2bb0-4366-84be-c99bde1f0710",
      "name": "6. Code \u2014 Split Scripts for Sheets",
      "type": "n8n-nodes-base.code",
      "position": [
        -240,
        448
      ],
      "parameters": {
        "jsCode": "const gptOutput = $input.first().json.output;\nconst config = $('2. Set \u2014 Config Values').item.json;\n\nif (!gptOutput || !gptOutput.youtube || !gptOutput.reels || !gptOutput.tiktok) {\n  throw new Error('GPT did not return all 3 scripts. Check your OpenAI credential.');\n}\n\nconst platforms = [\n  {\n    platform: 'YouTube',\n    scriptLength: 'Long form (8 to 10 min)',\n    hook: gptOutput.youtube.hook,\n    script: gptOutput.youtube.script,\n    cta: gptOutput.youtube.cta,\n    tags: (gptOutput.youtube.tags || []).join(' ')\n  },\n  {\n    platform: 'Instagram Reels',\n    scriptLength: 'Short form (60 sec)',\n    hook: gptOutput.reels.hook,\n    script: gptOutput.reels.script,\n    cta: gptOutput.reels.cta,\n    tags: (gptOutput.reels.tags || []).join(' ')\n  },\n  {\n    platform: 'TikTok',\n    scriptLength: 'Short form (30 sec)',\n    hook: gptOutput.tiktok.hook,\n    script: gptOutput.tiktok.script,\n    cta: gptOutput.tiktok.cta,\n    tags: (gptOutput.tiktok.tags || []).join(' ')\n  }\n];\n\nreturn platforms.map((p, index) => ({\n  json: {\n    today: config.today,\n    videoTopic: config.videoTopic,\n    platform: p.platform,\n    scriptLength: p.scriptLength,\n    hook: p.hook,\n    script: p.script,\n    cta: p.cta,\n    tags: p.tags,\n    submittedBy: config.submittedBy,\n    isLastRow: index === 2,\n    allScripts: index === 2 ? gptOutput : null,\n    targetAudience: config.targetAudience,\n    niche: config.niche,\n    sheetId: config.sheetId,\n    sheetName: config.sheetName,\n    recipientEmail: config.recipientEmail,\n    senderName: config.senderName\n  }\n}));"
      },
      "typeVersion": 2
    },
    {
      "id": "c87c7335-a38c-4727-aa8e-e32c879f98e6",
      "name": "7. Google Sheets \u2014 Log Video Scripts",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        0,
        288
      ],
      "parameters": {
        "columns": {
          "value": {
            "CTA": "={{ $json.cta }}",
            "Date": "={{ $json.today }}",
            "Hook": "={{ $json.hook }}",
            "Tags": "={{ $json.tags }}",
            "Topic": "={{ $json.videoTopic }}",
            "Script": "={{ $json.script }}",
            "Platform": "={{ $json.platform }}",
            "Submitted By": "={{ $json.submittedBy }}",
            "Script Length": "={{ $json.scriptLength }}"
          },
          "mappingMode": "defineBelow"
        },
        "options": {
          "cellFormat": "USER_ENTERED"
        },
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $json.sheetName }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.sheetId }}"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "8bce808e-b48e-485a-a6f6-249dcaf201e2",
      "name": "8. IF \u2014 All Scripts Logged?",
      "type": "n8n-nodes-base.if",
      "position": [
        0,
        608
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": false,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "cond-last",
              "operator": {
                "type": "boolean",
                "operation": "true"
              },
              "leftValue": "={{ $('6. Code \u2014 Split Scripts for Sheets').item.json.isLastRow }}",
              "rightValue": true
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "6bf3fb50-9d3b-487b-bc69-ac55cbd42f88",
      "name": "9. Code \u2014 Build Email",
      "type": "n8n-nodes-base.code",
      "position": [
        224,
        448
      ],
      "parameters": {
        "jsCode": "const data = $('6. Code \u2014 Split Scripts for Sheets').item.json;\nconst scripts = data.allScripts;\n\nconst yt = scripts.youtube;\nconst reels = scripts.reels;\nconst tiktok = scripts.tiktok;\n\nconst emailBody =\n  'Hello ' + data.senderName + ',\\n\\n' +\n  'Your 3 platform-ready video scripts are ready.\\n\\n' +\n  'Topic: ' + data.videoTopic + '\\n' +\n  'Audience: ' + data.targetAudience + '\\n' +\n  'Niche: ' + data.niche + '\\n' +\n  'Date: ' + data.today + '\\n\\n' +\n\n  '============================================================\\n' +\n  'YOUTUBE \u2014 Long Form (8 to 10 minutes)\\n' +\n  '============================================================\\n\\n' +\n  'Hook:\\n' + yt.hook + '\\n\\n' +\n  'Script:\\n' + yt.script + '\\n\\n' +\n  'CTA: ' + yt.cta + '\\n\\n' +\n  'Tags: ' + (yt.tags || []).join(' ') + '\\n\\n' +\n\n  '============================================================\\n' +\n  'INSTAGRAM REELS \u2014 Short Form (60 seconds)\\n' +\n  '============================================================\\n\\n' +\n  'Hook:\\n' + reels.hook + '\\n\\n' +\n  'Script:\\n' + reels.script + '\\n\\n' +\n  'CTA: ' + reels.cta + '\\n\\n' +\n  'Tags: ' + (reels.tags || []).join(' ') + '\\n\\n' +\n\n  '============================================================\\n' +\n  'TIKTOK \u2014 Short Form (30 seconds)\\n' +\n  '============================================================\\n\\n' +\n  'Hook:\\n' + tiktok.hook + '\\n\\n' +\n  'Script:\\n' + tiktok.script + '\\n\\n' +\n  'CTA: ' + tiktok.cta + '\\n\\n' +\n  'Tags: ' + (tiktok.tags || []).join(' ') + '\\n\\n' +\n\n  'All 3 scripts are also saved in your Google Sheets Video Scripts tab.\\n\\n' +\n  'Best regards,\\n' + data.senderName;\n\nreturn [{\n  json: {\n    emailSubject: '3 Video Scripts Ready \u2014 ' + data.videoTopic + ' \u2014 ' + data.today,\n    emailBody,\n    recipientEmail: data.recipientEmail\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "c99335e8-9f53-4d3f-bef1-0ffd79208e1a",
      "name": "10. Gmail \u2014 Send Scripts Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        448,
        448
      ],
      "parameters": {
        "sendTo": "={{ $json.recipientEmail }}",
        "message": "={{ $json.emailBody }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "={{ $json.emailSubject }}"
      },
      "typeVersion": 2.1
    },
    {
      "id": "e0e5810b-3783-4cf6-833d-044d6aec56fb",
      "name": "11. Set \u2014 More Scripts",
      "type": "n8n-nodes-base.set",
      "position": [
        224,
        720
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "more-001",
              "name": "result",
              "type": "string",
              "value": "Script logged \u2014 more rows being saved to Sheets."
            }
          ]
        }
      },
      "typeVersion": 3.4
    }
  ],
  "connections": {
    "9. Code \u2014 Build Email": {
      "main": [
        [
          {
            "node": "10. Gmail \u2014 Send Scripts Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2. Set \u2014 Config Values": {
      "main": [
        [
          {
            "node": "3. AI Agent \u2014 Write 3 Platform Scripts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "8. IF \u2014 All Scripts Logged?": {
      "main": [
        [
          {
            "node": "9. Code \u2014 Build Email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "11. Set \u2014 More Scripts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4. OpenAI \u2014 GPT-4o-mini Model": {
      "ai_languageModel": [
        [
          {
            "node": "3. AI Agent \u2014 Write 3 Platform Scripts",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "6. Code \u2014 Split Scripts for Sheets": {
      "main": [
        [
          {
            "node": "7. Google Sheets \u2014 Log Video Scripts",
            "type": "main",
            "index": 0
          },
          {
            "node": "8. IF \u2014 All Scripts Logged?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1. Form \u2014 Multi-Platform Video Topic": {
      "main": [
        [
          {
            "node": "2. Set \u2014 Config Values",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5. Parser \u2014 Structured Scripts Output": {
      "ai_outputParser": [
        [
          {
            "node": "3. AI Agent \u2014 Write 3 Platform Scripts",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "3. AI Agent \u2014 Write 3 Platform Scripts": {
      "main": [
        [
          {
            "node": "6. Code \u2014 Split Scripts for Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}