{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "40343fa3-62a4-468e-b39e-c419a1579207",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        16,
        -224
      ],
      "parameters": {
        "path": "manga-monarch-webhook",
        "options": {},
        "responseMode": "responseNode"
      },
      "typeVersion": 2.1
    },
    {
      "id": "2a9d306f-e1e7-4bde-9356-ea21102777c4",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        224,
        -224
      ],
      "parameters": {
        "options": {},
        "respondWith": "text",
        "responseBody": "={{ $json.query['hub.challenge'] }}"
      },
      "typeVersion": 1.5
    },
    {
      "id": "bd4eff56-6ae6-47dc-9375-c44b8fdcfcca",
      "name": "Webhook (Listen for Videos)",
      "type": "n8n-nodes-base.webhook",
      "position": [
        480,
        -224
      ],
      "parameters": {
        "path": "manga-monarch-webhook",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 1
    },
    {
      "id": "cdaa5aa1-9a48-4989-a400-2cb476d16c64",
      "name": "rename",
      "type": "n8n-nodes-base.set",
      "position": [
        656,
        -224
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f67713e5-ecee-4eb5-b62d-bfd224492d47",
              "name": "title",
              "type": "string",
              "value": "={{ $json.body.feed.entry.title }}"
            },
            {
              "id": "007410e6-6838-448e-a653-51436f9a239a",
              "name": "id",
              "type": "string",
              "value": "={{ $json.body.feed.entry['yt:videoid'] }}"
            },
            {
              "id": "f6e457d5-d858-4fca-8872-d4cfa676785c",
              "name": "channel_id",
              "type": "string",
              "value": "={{ $json.body.feed.entry['yt:channelid'] }}"
            },
            {
              "id": "c3252410-2898-49ac-98af-04a53b3f414c",
              "name": "video_url",
              "type": "string",
              "value": "={{ $json.body.feed.entry.link['$'].href }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "87d38cba-bc49-4695-a2d1-b3a0eed61109",
      "name": "Run an Actor and get dataset1",
      "type": "@apify/n8n-nodes-apify.apify",
      "position": [
        848,
        -224
      ],
      "parameters": {
        "memory": 4096,
        "actorId": {
          "__rl": true,
          "mode": "id",
          "value": "=UUhJDfKJT2SsXdclR"
        },
        "operation": "Run actor and get dataset",
        "customBody": "={\n    \"preferredFormat\": \"mp4\",\n    \"preferredQuality\": \"2160p\",\n    \"storeInKVStore\": true,\n    \"videos\": [\n        {\n            \"url\": \"{{ $json.video_url }}\"\n        }\n    ]\n}",
        "actorSource": "store"
      },
      "credentials": {
        "apifyApi": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "typeVersion": 1,
      "waitBetweenTries": 5000
    },
    {
      "id": "213a4368-b4ff-4a5e-8f45-40b5024a9476",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "maxTries": 5,
      "position": [
        1040,
        -224
      ],
      "parameters": {
        "url": "https://generativelanguage.googleapis.com/v1beta/interactions",
        "method": "POST",
        "options": {
          "timeout": 600000
        },
        "jsonBody": "={\n  \"model\": \"gemini-2.5-flash\",\n  \"input\": [\n    {\n      \"type\": \"video\",\n      \"uri\": \"{{ $json.input }}\"\n    },\n    {\n      \"type\": \"text\",\n      \"text\": \"You are an expert Pinterest SEO strategist specializing in anime, manga, and manhua content.\\n\\nAnalyze this YouTube Short and return ONLY valid JSON.\\n\\nDetermine:\\n- Anime/Manga/Manhua title (only if confidently identifiable)\\n- Characters shown\\n- Genre\\n- Theme\\n- Mood\\n- Scene type (Fight, Edit, AMV, Romance, Comedy, Emotional, Transformation, Power Showcase, etc.)\\n- Whether the clip contains spoilers.\\n\\nGenerate Pinterest-optimized metadata.\\n\\nReturn ONLY this JSON schema:\\n\\n{\\n  \\\"detected_series\\\": \\\"\\\",\\n  \\\"media_type\\\": \\\"Anime|Manga|Manhua|Unknown\\\",\\n  \\\"confidence\\\": 0.0,\\n  \\\"characters\\\": [],\\n  \\\"genre\\\": [],\\n  \\\"theme\\\": [],\\n  \\\"scene_type\\\": \\\"\\\",\\n  \\\"mood\\\": \\\"\\\",\\n  \\\"title\\\": \\\"\\\",\\n  \\\"description\\\": \\\"\\\",\\n  \\\"hashtags\\\": [],\\n  \\\"keywords\\\": [],\\n  \\\"search_queries\\\": [],\\n  \\\"board_suggestions\\\": [],\\n  \\\"pin_text_overlay\\\": \\\"\\\",\\n  \\\"cta\\\": \\\"\\\",\\n  \\\"spoiler_level\\\": \\\"none\\\",\\n  \\\"viral_score\\\": 0,\\n  \\\"summary\\\": \\\"\\\"\\n}\\n\\nRequirements:\\n- Title under 100 characters.\\n- Description between 250 and 500 characters.\\n- Include a natural call-to-action.\\n- Generate 20-30 Pinterest hashtags.\\n- Generate 20 Pinterest SEO keywords.\\n- Generate 10 Pinterest search queries.\\n- Suggest 5 Pinterest boards.\\n- Never invent anime names or character names.\\n- If uncertain, set detected_series to \\\"Unknown\\\" and lower confidence.\\n- Use only information present in the video.\\n- Return ONLY valid JSON with no markdown or additional text.\"\n    }\n  ]\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": []
        },
        "nodeCredentialType": "googlePalmApi"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.4,
      "waitBetweenTries": 5000
    },
    {
      "id": "3e5d2bde-94fa-47f2-96b9-93631c41001d",
      "name": "Basic LLM Chain",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "maxTries": 5,
      "position": [
        1248,
        -224
      ],
      "parameters": {
        "text": "=You are an expert Pinterest SEO strategist specializing in anime, manga, and manhua content.\n\nAnalyze this YouTube Short and return ONLY valid JSON.\n\nDetermine:\n- Anime/Manga/Manhua title\n- Genre\n- Theme\n\nBased on your analysis, you MUST select the most relevant Pinterest Board from the following strict list. DO NOT invent boards.\n\nAVAILABLE BOARDS:\n1. \"Best Manhwa Recommendations\" - Use for all Korean Manhwa and Webtoons.\n2. \"Epic Anime Edits & Shorts\" - Use for animated Japanese Anime clips.\n3. \"Isekai & Fantasy Webtoons\" - Use for any comic involving reincarnation, magic, or fantasy worlds.\n4. \"Manga Panels & Moments\" - Use for Japanese Manga panels (black and white).\n5. \"The Otaku Stream Daily\" - Default. Use only if you are completely unsure.\n\nGenerate Pinterest-optimized metadata.\n\nReturn ONLY this JSON schema:\n\n{\n  \"media_type\": \"Anime|Manga|Manhua|Unknown\",\n  \"genre\": [],\n  \"title\": \"\",\n  \"description\": \"\",\n  \"hashtags\": [],\n  \"selected_board_name\": \"\"\n}\n\nRequirements:\n- Title under 100 characters.\n- Description between 250 and 500 characters.\n- Generate 20-30 Pinterest hashtags.\n- \"selected_board_name\" MUST be one of the 5 exact names listed above.\n- Return ONLY valid JSON with no markdown.\n\nVideo Analysis:\n{{ $json.steps[1].content[0].text }}",
        "batching": {},
        "messages": {
          "messageValues": []
        },
        "promptType": "define",
        "needsFallback": true,
        "hasOutputParser": true
      },
      "retryOnFail": true,
      "typeVersion": 1.9,
      "waitBetweenTries": 5000
    },
    {
      "id": "545de162-d89c-4567-a389-78b078931c68",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1136,
        32
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "z-ai/glm-5.2",
          "cachedResultName": "z-ai/glm-5.2"
        },
        "options": {},
        "responsesApiEnabled": false
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "0b048e43-60c1-43c1-a505-c3c5b6eade35",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1424,
        -16
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"media_type\": {\n      \"type\": \"string\",\n      \"enum\": [\"Anime\", \"Manga\", \"Manhua\", \"Unknown\"]\n    },\n    \"genre\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"string\"\n      }\n    },\n    \"title\": {\n      \"type\": \"string\"\n    },\n    \"description\": {\n      \"type\": \"string\"\n    },\n    \"hashtags\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"string\"\n      }\n    },\n    \"selected_board_name\": {\n      \"type\": \"string\",\n      \"enum\": [\n        \"Best Manhwa Recommendations\",\n        \"Epic Anime Edits & Shorts\",\n        \"Isekai & Fantasy Webtoons\",\n        \"Manga Panels & Moments\",\n        \"The Otaku Stream Daily\"\n      ]\n    }\n  },\n  \"required\": [\n    \"media_type\",\n    \"genre\",\n    \"title\",\n    \"description\",\n    \"hashtags\",\n    \"selected_board_name\"\n  ]\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "3f19b7ef-8799-444b-93ca-67260d16a339",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        1584,
        -224
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "eb39139d-d6d8-4c4d-8023-8aea012a4edd",
              "name": "media_type",
              "type": "string",
              "value": "={{ $json.output.media_type }}"
            },
            {
              "id": "41a1c9bb-8d4a-4abc-85d5-6248295e1e92",
              "name": "output.genre",
              "type": "array",
              "value": "={{ $json.output.genre }}"
            },
            {
              "id": "ce8daaf8-5c88-41e2-b41b-63beceb8ebad",
              "name": "title",
              "type": "string",
              "value": "={{ $json.output.title }}"
            },
            {
              "id": "2894052c-377f-4603-bac8-eaa3841c13a2",
              "name": "description",
              "type": "string",
              "value": "={{ $json.output.description }}"
            },
            {
              "id": "da8c052e-df13-44af-92b3-0aadc931f407",
              "name": "board_id",
              "type": "string",
              "value": "={{ ({\n  \"Best Manhwa Recommendations\": \"1131318437585610843\",\n  \"Epic Anime Edits & Shorts\": \"1131318437585610842\",\n  \"Isekai & Fantasy Webtoons\": \"1131318437585610838\",\n  \"Manga Panels & Moments\": \"1131318437585610839\",\n  \"The Otaku Stream Daily\": \"1131318437585610835\"\n})[$json.output.selected_board_name] || \"1131318437585610835\" }}"
            },
            {
              "id": "7214e3c1-9ac2-4f4d-ad45-fcd8b0ecbea7",
              "name": "hashtags",
              "type": "string",
              "value": "={{ $json.output.hashtags.slice(0, 5).join(', ') }}"
            },
            {
              "id": "85e2be82-0c99-4def-97ba-f8b9a1891108",
              "name": "video_url",
              "type": "string",
              "value": "={{ $('Run an Actor and get dataset1').item.json.downloadedFileUrl }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c042e679-356f-4bfd-a5c6-d7bf3bb57de6",
      "name": "HTTP Request1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1792,
        -224
      ],
      "parameters": {
        "url": "https://zernio.com/api/v1/posts",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"content\": {{ JSON.stringify($json.description) }},\n  \"mediaItems\": [\n    {\n      \"type\": \"video\",\n      \"url\": {{ JSON.stringify($json.video_url) }}\n    }\n  ],\n  \"platforms\": [\n    {\n      \"platform\": \"pinterest\",\n      \"accountId\": \"6a4a8a8a9d9472faae87625c\",\n      \"platformSpecificData\": {\n        \"title\": {{ JSON.stringify($json.title) }},\n        \"boardId\": {{ JSON.stringify($json.board_id) }}\n      }\n    }\n  ],\n  \"scheduledFor\": \"{{ $now.plus(5, 'minutes').setZone('utc').toISO() }}\",\n  \"publishNow\": false\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": []
        },
        "nodeCredentialType": "lateApi"
      },
      "credentials": {
        "lateApi": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.4,
      "waitBetweenTries": 5000
    },
    {
      "id": "eff18ba3-2dcc-4202-ad98-2041ce50753a",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1264,
        128
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-3.5-flash"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0075c556-1fe7-4f4c-9905-e6940ea1a46d",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -704,
        -512
      ],
      "parameters": {
        "width": 672,
        "height": 624,
        "content": "## YouTube Shorts to Pinterest Video Pin Scheduler\n\nThis workflow helps anime, manga, manhwa, and manhua creators automatically repurpose YouTube Shorts into scheduled Pinterest video pins with AI-generated SEO metadata.\n\n### How it works\n\nThe workflow receives new YouTube Short data through a webhook, extracts the video title, video ID, channel ID, and video URL, then sends the video to Apify for processing. After that, an AI model analyzes the video and generates Pinterest-ready metadata, including the media type, genre, title, description, hashtags, and the most relevant Pinterest board. The structured output parser validates the AI response, then the workflow maps the selected board name to the correct Pinterest board ID and schedules the final video pin through the publishing API.\n\n### Setup\n\nAdd your own Apify, AI model, and publishing API credentials inside n8n credentials. Replace all example webhook URLs, account IDs, board IDs, API endpoints, and test data with your own values before activating the workflow.\n\nDo not hardcode private API keys inside HTTP Request nodes. Use n8n credentials for all sensitive information.\n\n### Customization tips\n\nYou can customize the AI prompt, Pinterest board list, board ID mapping, posting delay, hashtag limit, and description style to match your niche."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "rename": {
      "main": [
        [
          {
            "node": "Run an Actor and get dataset1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "HTTP Request1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request1": {
      "main": [
        []
      ]
    },
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 1
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Webhook (Listen for Videos)": {
      "main": [
        [
          {
            "node": "rename",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run an Actor and get dataset1": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}