{
  "id": "6tf9M5nFwT2Paz81",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Automated Instagram Reels Generator (Creatomate)",
  "tags": [],
  "nodes": [
    {
      "id": "561115db-ba74-44ba-bdf6-cc3b6e822f1a",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        176,
        64
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "db9d2789-926a-4471-848a-bb4d6836f9bb",
      "name": "Slack Approval Request",
      "type": "n8n-nodes-base.slack",
      "position": [
        1120,
        -16
      ],
      "parameters": {
        "select": "channel",
        "message": "=\u3010Approval Request\u3011Please check the new Reel video proposal \ud83c\udfac\n\n\u25bcDetails\nTitle: {{ $json['Title.text'] }}\nQuestion: {{ $json['Question.text'] }}\nAnswer: {{ $json['Answer.text'] }}\nBG Image: {{ $json['Image-R6B.source'] }}\nFont: Noto Sans\nBGM Trim Start: {{ $json['Audio-PTX.trim_start'] }}",
        "options": {},
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "example"
        },
        "operation": "sendAndWait",
        "authentication": "oAuth2",
        "approvalOptions": {
          "values": {
            "approvalType": "double"
          }
        }
      },
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "8e8a395c-0aca-462a-9ce3-cb3936a5475e",
      "name": "Instagram Upload",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        2400,
        -16
      ],
      "parameters": {
        "edge": "media",
        "node": "example",
        "options": {
          "queryParameters": {
            "parameter": [
              {
                "name": "media_type",
                "value": "REELS"
              },
              {
                "name": "video_url",
                "value": "={{ $json.url }}"
              },
              {
                "name": "caption",
                "value": "=\n\n{{ $('Parse LLM Output').item.json['Question.text'] }}\n\n#n8n #AIWorkflow #Automation"
              }
            ]
          }
        },
        "graphApiVersion": "v18.0",
        "httpRequestMethod": "POST"
      },
      "credentials": {
        "facebookGraphApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8a04580b-f92f-409d-84e3-c6d4691a5f80",
      "name": "Wait (1 min)",
      "type": "n8n-nodes-base.wait",
      "position": [
        2576,
        -16
      ],
      "parameters": {
        "unit": "minutes"
      },
      "typeVersion": 1
    },
    {
      "id": "c262e45a-3110-42ab-938e-62de1266468c",
      "name": "Instagram Publish",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        2768,
        -16
      ],
      "parameters": {
        "edge": "media_publish",
        "node": "example",
        "options": {
          "queryParameters": {
            "parameter": [
              {
                "name": "creation_id",
                "value": "={{ $json.id }}"
              }
            ]
          }
        },
        "graphApiVersion": "v18.0",
        "httpRequestMethod": "POST"
      },
      "credentials": {
        "facebookGraphApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "3211df9c-e47d-4d42-87ed-dd77828884c3",
      "name": "Slack Notification",
      "type": "n8n-nodes-base.slack",
      "position": [
        2976,
        -16
      ],
      "parameters": {
        "text": "=\u3010Post Complete\u3011Reel has been published!\n\n\u25bcVideo URL\n{{ $('Generate Video').item.json.url }}\n\n\u25bcSnapshot\n{{ $('Generate Video').item.json.snapshot_url }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "example"
        },
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "9e73d617-192d-4fa6-abe8-96959943321f",
      "name": "Main Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -400,
        -304
      ],
      "parameters": {
        "width": 500,
        "height": 664,
        "content": "# \ud83d\ude80 Automated Instagram Reels Generator\n\n## How it works\nAI plans a \"viral\" Reel based on trends and generates it using Creatomate.\n\n## Setup steps\n1. Configure Credentials for OpenAI, Creatomate, Google Sheets, Slack, and Facebook.\n2. Set up your Google Sheet and Slack Channel IDs in the respective nodes.\n3. Configure the Creatomate Template ID."
      },
      "typeVersion": 1
    },
    {
      "id": "7e8bdc97-dcc4-4bc0-a560-f24e7caeaf57",
      "name": "Section: Content Gen",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        128,
        -304
      ],
      "parameters": {
        "color": 7,
        "width": 1336,
        "height": 680,
        "content": "## 1. Content Planning & Approval\nGenerates ideas based on trends using AI and requests human approval via Slack."
      },
      "typeVersion": 1
    },
    {
      "id": "6a4e15ab-0db5-4562-96f4-f17c4699af31",
      "name": "Section: Approval",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1488,
        -304
      ],
      "parameters": {
        "color": 7,
        "width": 836,
        "height": 680,
        "content": "## 2. Video Creation\nTransform the accepted plan into a video using Creatomate."
      },
      "typeVersion": 1
    },
    {
      "id": "19a11961-c63b-41ff-ab75-bc24489b28a1",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        624,
        192
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {},
        "builtInTools": {
          "webSearch": {
            "searchContextSize": "medium"
          }
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "02ba6f13-65e4-4bfe-b1f9-769800ca3d39",
      "name": "Generate Content Plan",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        624,
        -16
      ],
      "parameters": {
        "text": "=You are a professional Instagram marketer aiming to grow followers to 1000. Create accurate quiz-style content about n8n automation. The target audience is tech-savvy users who are beginners in automation. Follow these strict requirements and output in JSON format suitable for the Creatomate template. Provide clear and accurate information.\n\n## Past Topics (Do not duplicate)\n{{ $('Get Past Topics').all().map(item => item.json.Question).join(', ') }}\n\n## Constraints (Strict)\n1. **JSON Output Only:** Return only raw JSON text. No explanation or Markdown code blocks.\n2. **Language:** Write in Japanese (as per original intent for content) OR English? -> User said \"Translate node names and parameters to English\". Usually templates should generate English content by default unless specified otherwise. I will switch the content generation to **English** for the template to be global-friendly.\n3. **Length:** `Answer.text` should be within 50 chars for mobile readability.\n\n## Output Fields\n1. **Image-R6B.source**:\n   - English prompt for an abstract, cool background image representing the node function.\n   - Keywords: \"Abstract technology background, dark blue, n8n style, 3d render\" + specific elements.\n2. **Audio-PTX.trim_start**:\n   - Numeric `6.5` (Fixed)\n3. **Question.text**:\n   - Line 1: Node Name (English)\n   - Line 2: Two newlines `\\n\\n` then a short question.\n   - Example: \"Sticky Note\\n\\nWhat is the surprising use of this node?\"\n4. **Answer.text**:\n   - Explain function/benefit briefly.\n   - Must include one `\\n\\n` to split into 2 lines.\n5. **Title.text**:\n   - String \"n8n Quiz\" (Fixed)\n6. **Title.font_family**:\n   - String \"Inter\" or \"Roboto\" (Changed from Noto Sans JP for English template compatibility)\n\n## Output Example\n{\n  \"Image-R6B.source\": \"Abstract technology background...\",\n  \"Audio-PTX.trim_start\": 6.5,\n  \"Question.text\": \"Guardrails\\n\\nWhat does this node do?\",\n  \"Answer.text\": \"Monitors AI I/O for safety.\\n\\nPrevents prompt injection.\",\n  \"Title.text\": \"n8n Quiz\",\n  \"Title.font_family\": \"Inter\"\n}",
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.4
    },
    {
      "id": "9e680267-8ebd-43df-883c-b37b004e2980",
      "name": "Generate Video",
      "type": "n8n-nodes-base.httpRequest",
      "notes": "\u753b\u50cf\u3092\u52d5\u753b\u5316\u3002\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8ID\u3092\u8a2d\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002",
      "position": [
        1952,
        -16
      ],
      "parameters": {
        "url": "https://api.creatomate.com/v2/renders",
        "method": "POST",
        "options": {},
        "jsonBody": "={{\n  {\n    \"template_id\": \"YOUR_TEMPLATE_ID\",\n    \"modifications\": {\n      \"Image-R6B.source\": $('Parse LLM Output').item.json['Image-R6B.source'],\n      \"Audio-PTX.trim_start\": 6.5,\n      \"Question.text\": $('Parse LLM Output').item.json['Question.text'],\n      \"Answer.text\": $('Parse LLM Output').item.json['Answer.text'],\n      \"Title.text\": $('Parse LLM Output').item.json['Title.text'],\n      \"Title.font_family\": \"Noto Sans\"\n    }\n  }\n}}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.1
    },
    {
      "id": "508733c9-e366-4fb7-886d-2e19ab895024",
      "name": "Wait for Rendering",
      "type": "n8n-nodes-base.wait",
      "position": [
        2160,
        -16
      ],
      "parameters": {
        "unit": "minutes"
      },
      "typeVersion": 1
    },
    {
      "id": "ee1b3225-b288-42bd-aa80-975824c82aec",
      "name": "Parse LLM Output",
      "type": "n8n-nodes-base.code",
      "position": [
        928,
        -16
      ],
      "parameters": {
        "jsCode": "// 1. Get AI node output (text)\nconst content = $input.first().json.text;\n\n// 2. Remove markdown code blocks (```json) to extract content\n// Extract JSON portion from first { to last }\nconst jsonString = content.replace(/```json/g, '').replace(/```/g, '').trim();\n\n// 3. Extract JSON object using regex as a fallback safety measure\nconst jsonMatch = jsonString.match(/\\{[\\s\\S]*\\}/);\nconst cleanJson = jsonMatch ? jsonMatch[0] : jsonString;\n\n// 4. Parse string to JSON object\ntry {\n  return JSON.parse(cleanJson);\n} catch (error) {\n  // Throw error if parse fails\n  throw new Error(\"JSON parse failed. AI output is not valid JSON: \" + cleanJson);\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "be4a76c5-708e-4a48-b657-c12dd8136b78",
      "name": "Check Approval",
      "type": "n8n-nodes-base.if",
      "position": [
        1296,
        -16
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "0e89b049-cc2c-44a1-a331-0d04648d79fd",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.data.approved }}",
              "rightValue": false
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "514e7878-0d11-4b7a-bbad-e289917e68a8",
      "name": "Get Past Topics",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        384,
        64
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "example"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "example"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "c2b6ad92-1af3-4ab2-975a-28c06411d40d",
      "name": "Save New Topic",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1616,
        -128
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "example"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "example"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "c6fdb5d7-6282-4201-b9a8-7a3bba23d788",
      "name": "Section: Approval1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2352,
        -304
      ],
      "parameters": {
        "color": 7,
        "width": 836,
        "height": 680,
        "content": "## 3. Publishing\nUploads and publishes the reel to Instagram automatically."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "7378716e-67cb-4151-b609-e1d16ac7ae7b",
  "connections": {
    "Wait (1 min)": {
      "main": [
        [
          {
            "node": "Instagram Publish",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Approval": {
      "main": [
        [
          {
            "node": "Save New Topic",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Generate Content Plan",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Video": {
      "main": [
        [
          {
            "node": "Wait for Rendering",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save New Topic": {
      "main": [
        [
          {
            "node": "Generate Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Past Topics": {
      "main": [
        [
          {
            "node": "Generate Content Plan",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Instagram Upload": {
      "main": [
        [
          {
            "node": "Wait (1 min)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse LLM Output": {
      "main": [
        [
          {
            "node": "Slack Approval Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get Past Topics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Instagram Publish": {
      "main": [
        [
          {
            "node": "Slack Notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Content Plan",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Rendering": {
      "main": [
        [
          {
            "node": "Instagram Upload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Content Plan": {
      "main": [
        [
          {
            "node": "Parse LLM Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Slack Approval Request": {
      "main": [
        [
          {
            "node": "Check Approval",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}