{
  "id": "5b6XImwh2D5ylRT8",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "YouTube Auto Social Sharing",
  "tags": [
    {
      "id": "rY6TJEjN9atwcpVb",
      "name": "Fan's AI Lab",
      "createdAt": "2025-06-15T04:39:41.962Z",
      "updatedAt": "2025-06-15T04:39:41.962Z"
    }
  ],
  "nodes": [
    {
      "id": "289f99c2-0769-4b6b-87cf-f94b0a32d3c2",
      "name": "API Requirements",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -220,
        -200
      ],
      "parameters": {
        "width": 330,
        "height": 220,
        "content": "\u26a0\ufe0f **Meta API Requirements**\n\n**Required Permissions:**\n- pages_manage_posts\n- pages_read_engagement\n- pages_show_list\n\n\n**Token Type:** Long-lived access token\n**API Version:** v23.0"
      },
      "typeVersion": 1
    },
    {
      "id": "a4ef5c3f-815c-4084-9a34-c2bcdee625cc",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "notes": "Formats post caption using video metadata. Customize prompt for your brand voice and hashtags",
      "position": [
        -560,
        160
      ],
      "parameters": {
        "text": "=Write a short, engaging social media post about this new YouTube video with title: {{ $json.title }}\n\nTitle: {{ $json.title }}\nURL: {{ $json.link }}\nHashtags: #AI #Automation #n8n\n\nInclude emojis and a call to action and above 3 predefined hashtags and 1 more hashtags which are relevant to the context. Ensure the output content is within 260 character limit and do NOT display char count in the content.",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "retryOnFail": true,
      "typeVersion": 1.9,
      "waitBetweenTries": 5000
    },
    {
      "id": "b90a7af1-135a-4d79-8419-8a11336001d8",
      "name": "Post on Facebook",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -100,
        60
      ],
      "parameters": {
        "url": "=https://graph.facebook.com/v23.0/me/feed\n",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "form-urlencoded",
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "message",
              "value": "={{ $json.output }}"
            },
            {
              "name": "link",
              "value": "={{ $('Pull Youtube Video From Channel').item.json.link }}"
            }
          ]
        },
        "genericAuthType": "httpQueryAuth"
      },
      "credentials": {
        "httpQueryAuth": {
          "name": "<your credential>"
        },
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2,
      "waitBetweenTries": 5000
    },
    {
      "id": "8ac0edc0-4ff5-4250-bced-188a916e4545",
      "name": "Pull Youtube Video From Channel",
      "type": "n8n-nodes-base.rssFeedReadTrigger",
      "notes": "Monitors new uploads from your YouTube channel. Replace channel_id in RSS URL",
      "position": [
        -780,
        160
      ],
      "parameters": {
        "feedUrl": "https://www.youtube.com/feeds/videos.xml?channel_id=UCftG6qEuKdshJIOx_Auf1wA",
        "pollTimes": {
          "item": [
            {
              "mode": "everyHour",
              "minute": 17
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6309cc22-f127-4583-94df-0fc346054bab",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        -480,
        380
      ],
      "parameters": {
        "model": "deepseek/deepseek-r1:free",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "287b3c51-1de5-45a7-a1e2-786ef9920730",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1400,
        -160
      ],
      "parameters": {
        "width": 460,
        "height": 700,
        "content": "## YouTube Auto Social Sharing Bot\n\nThis n8n template demonstrates how to use a LLM like DeepSeek to generate a post and share to Facebook page and X automatically whenever a new video is published to a YouTube channel.\n\n### How it works\n* We first define RSS with a polling schedule to pull YouTube videos from a specified channel\n* Prompt AI agent to generate a post with proper url and hash tags based on the video metadata\n* Then automatically create a new post in Facebook and X via their APIs\n* Post a new message in Discord channel via Webhook\n\n### How to use\n* Simply setup a RSS polling trigger to automatically trigger the workflow\n\n### Requirements\n* Facebook API setup, see [step by step tutorials](https://developers.facebook.com/ads/blog/post/v2/2018/11/01/marketing-api-setup-101/#:~:text=Step%201:%20Create%20a%20Facebook,7:%20Generate%20an%20access%20token.)\n* X v2 API setup, see [step by step tutorials](https://developer.x.com/en/docs/tutorials/step-by-step-guide-to-making-your-first-request-to-the-twitter-api-v2)\n* Discord channel webhook, see [step by step tutorials](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks)\n\n\n### Need Help?\nContact me via [My Blog](https://fans-ai-lab.com/contact) or ask in the [Forum](https://community.n8n.io/)!\n\nHappy Hacking!"
      },
      "typeVersion": 1
    },
    {
      "id": "b8c08f4a-2fbd-4161-8f2b-398912f40ed5",
      "name": "API Requirements1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -600,
        -200
      ],
      "parameters": {
        "width": 330,
        "height": 340,
        "content": "**Prompt an AI Agent**\n\n**Prompt attributes:**\n- title\n- url\n- hash tags\n- feel free to customize the prompts to meet your needs\n\n\n**Notes:**\n- openrouter deepseek r1 free is used\n- feel free to replace it with other models, like gpt-4o etc"
      },
      "typeVersion": 1
    },
    {
      "id": "7db6ebd0-8776-4bc4-bbf6-0c53018c4a37",
      "name": "API Requirements2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -220,
        420
      ],
      "parameters": {
        "width": 330,
        "height": 220,
        "content": "\u26a0\ufe0f **X v2 API**\n\n**Instructions:**\n- Create a Developer Account and Project\n- Configure User Authentication, use OAuth in this case\n- Generate API Keys and Access Tokens\n\n\nSee [step by step tutorials](https://developer.x.com/en/docs/tutorials/step-by-step-guide-to-making-your-first-request-to-the-twitter-api-v2)"
      },
      "typeVersion": 1
    },
    {
      "id": "e6a6161e-d5c1-4c42-b2e8-7acb27880e70",
      "name": "API Requirements3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        180,
        320
      ],
      "parameters": {
        "width": 330,
        "height": 320,
        "content": "**Discord Webhook**\n\n**Instructions:**\n- To create a Discord webhook, navigate to the desired text channel's settings, find the Integrations tab, and click \"Create Webhook\".\n- You can then customize the webhook's name and avatar, and select the channel it will post to. \n- Finally, copy the generated webhook URL to use it in other applications.\n\n\nSee [step by step tutorials](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks)"
      },
      "typeVersion": 1
    },
    {
      "id": "7e0b8b07-9c09-4d2f-a5da-c9c9d2fbe9a4",
      "name": "API Requirements4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -900,
        320
      ],
      "parameters": {
        "width": 330,
        "height": 200,
        "content": "**RSS to pull YouTube video from a specified channel**\n\n**Setup:**\n- polling time\n- RSS url with the specified YouTube channel ID"
      },
      "typeVersion": 1
    },
    {
      "id": "5b98232f-f454-4fc8-b059-37c036926181",
      "name": "Post on X",
      "type": "n8n-nodes-base.twitter",
      "position": [
        -100,
        260
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "additionalFields": {}
      },
      "credentials": {
        "twitterOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "typeVersion": 2,
      "waitBetweenTries": 5000
    },
    {
      "id": "696aeb19-c4f0-4358-a534-5315c6a2027b",
      "name": "Notify in Discord",
      "type": "n8n-nodes-base.discord",
      "position": [
        280,
        160
      ],
      "parameters": {
        "content": "=\ud83d\ude80 \ud83d\ude80 The below YouTube video has been published to other social platforms\ud83d\ude80 \ud83d\ude80 \n\n**message**: {{ $('AI Agent').item.json.output }}\n\n**title**:  {{ $('Pull Youtube Video From Channel').item.json.title }}\n**url**: {{ $('Pull Youtube Video From Channel').item.json.link }}",
        "options": {},
        "authentication": "webhook"
      },
      "credentials": {
        "discordWebhookApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    }
  ],
  "active": true,
  "settings": {
    "callerPolicy": "workflowsFromSameOwner",
    "executionOrder": "v1",
    "timeSavedPerExecution": 30
  },
  "versionId": "40aec766-c385-4b13-941b-9ceb29a64c61",
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Post on X",
            "type": "main",
            "index": 0
          },
          {
            "node": "Post on Facebook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post on X": {
      "main": [
        [
          {
            "node": "Notify in Discord",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post on Facebook": {
      "main": [
        [
          {
            "node": "Notify in Discord",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Pull Youtube Video From Channel": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}