{
  "name": "Social Posting Tracker",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 15
            }
          ]
        }
      },
      "id": "schedule-trigger",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1,
      "position": [240, 304]
    },
    {
      "parameters": {
        "resource": "playlistItem",
        "operation": "getAll",
        "playlistId": "UUEtYk9gIxymPV0n2zQ7TT2g",
        "returnAll": false,
        "limit": 10
      },
      "id": "youtube-node",
      "name": "YouTube",
      "type": "n8n-nodes-base.youTube",
      "typeVersion": 1,
      "position": [464, 208],
      "credentials": {
        "youTubeOAuth2Api": {
          "id": "",
          "name": "YouTube account"
        }
      }
    },
    {
      "parameters": {
        "method": "GET",
        "url": "https://graph.instagram.com/me/media",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            { "name": "fields", "value": "id,caption,permalink,timestamp" },
            { "name": "limit", "value": "10" }
          ]
        },
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "options": {}
      },
      "id": "instagram-graph",
      "name": "Instagram Graph API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [464, 400],
      "credentials": {
        "httpQueryAuth": {
          "id": "",
          "name": "Instagram Graph API Token"
        }
      }
    },
    {
      "parameters": {
        "mode": "append"
      },
      "id": "merge-node",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 2,
      "position": [688, 304]
    },
    {
      "parameters": {
        "jsCode": "const staticData = $getWorkflowStaticData('global');\n\nif (!staticData.seenIds) {\n  staticData.seenIds = [];\n}\n\nconst items = $input.all();\nconst newItems = [];\n\nfor (const item of items) {\n  const data = item.json;\n\n  // YouTube PlaylistItem\n  if (data.snippet && data.snippet.resourceId) {\n    const videoId = data.snippet.resourceId.videoId;\n    if (videoId && !staticData.seenIds.includes(videoId)) {\n      staticData.seenIds = [...staticData.seenIds, videoId];\n      newItems.push({\n        json: {\n          platform: 'YouTube',\n          title: data.snippet.title || 'New YouTube Video',\n          url: `https://www.youtube.com/watch?v=${videoId}`,\n          preview: (data.snippet.description || '').slice(0, 200) || 'Check out this new video!'\n        }\n      });\n    }\n  }\n\n  // Instagram Graph API — response shape: { data: [...posts] }\n  if (data.data && Array.isArray(data.data)) {\n    for (const post of data.data) {\n      if (post.id && !staticData.seenIds.includes(post.id)) {\n        staticData.seenIds = [...staticData.seenIds, post.id];\n        newItems.push({\n          json: {\n            platform: 'Instagram',\n            title: 'New Instagram Post',\n            url: post.permalink,\n            preview: (post.caption || '').slice(0, 200) || 'Check out this new post!'\n          }\n        });\n      }\n    }\n  }\n}\n\n// Keep last 200 seen IDs\nif (staticData.seenIds.length > 200) {\n  staticData.seenIds = staticData.seenIds.slice(-200);\n}\n\nreturn newItems;"
      },
      "id": "check-duplicates",
      "name": "Check Duplicates",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [912, 304]
    },
    {
      "parameters": {
        "chatId": "-1003869621483",
        "text": "=🔔 New Content Alert!\n\n📱 Platform: {{ $json.platform }}\n📝 Title: {{ $json.title }}\n🔗 Link: {{ $json.url }}\n\n{{ $json.preview }}",
        "additionalFields": {
          "parse_mode": "Markdown"
        }
      },
      "id": "telegram-notify",
      "name": "Telegram Notify",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1,
      "position": [1136, 304],
      "webhookId": "ebeb9e26-9377-40e8-be96-990104d2f2b2",
      "credentials": {
        "telegramApi": {
          "id": "O5BA1xXGEzkrjBXB",
          "name": "Social Posting Alert"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          { "node": "YouTube", "type": "main", "index": 0 },
          { "node": "Instagram Graph API", "type": "main", "index": 0 }
        ]
      ]
    },
    "YouTube": {
      "main": [
        [{ "node": "Merge", "type": "main", "index": 0 }]
      ]
    },
    "Instagram Graph API": {
      "main": [
        [{ "node": "Merge", "type": "main", "index": 1 }]
      ]
    },
    "Merge": {
      "main": [
        [{ "node": "Check Duplicates", "type": "main", "index": 0 }]
      ]
    },
    "Check Duplicates": {
      "main": [
        [{ "node": "Telegram Notify", "type": "main", "index": 0 }]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "saveDataErrorExecution": "all",
    "saveDataSuccessExecution": "all",
    "saveManualExecutions": true,
    "saveExecutionProgress": true,
    "callerPolicy": "workflowsFromSameOwner",
    "availableInMCP": false
  },
  "versionId": "49959e97-1dc8-4623-a6e7-8f95ff601ae7",
  "meta": {
    "instanceId": "e09d1f0f8b9f78e80ac70b6dc8726dd263b0b6ffc4300b0eee3b58f6da316f29"
  },
  "id": "AJxPkPQdQhqZS7pu",
  "tags": []
}
