{
  "name": "Auto Comment Reply + post other social",
  "nodes": [
    {
      "parameters": {
        "path": "fb-comment-webhook",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "8fda774b-c882-49e1-bd10-5b9ceed5910b",
      "name": "Webhook Verify (GET)",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -208,
        -32
      ],
      "webhookId": "PLACEHOLDER_WEBHOOK_ID"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "leftValue": "={{ $json.query['hub.verify_token'] }}",
              "rightValue": "PLACEHOLDER_FB_VERIFY_TOKEN",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "id": "bf56c89d-c4cf-4fc6-9780-f7f6399e4fe9"
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "852d5ef1-7ede-4020-be70-7d5859454bb9",
      "name": "Check Verify Token",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        16,
        -32
      ]
    },
    {
      "parameters": {
        "respondWith": "text",
        "responseBody": "={{ $json.query['hub.challenge'] }}",
        "options": {}
      },
      "id": "6ee72538-4133-442e-9fcd-fc4a89fa723b",
      "name": "Respond Challenge",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        240,
        -112
      ]
    },
    {
      "parameters": {
        "respondWith": "text",
        "responseBody": "Forbidden",
        "options": {
          "responseCode": 403
        }
      },
      "id": "d665cae5-7cfb-4987-afc1-594d3abc71ce",
      "name": "Respond Forbidden",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        240,
        80
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "fb-comment-webhook",
        "options": {}
      },
      "id": "7f05a217-e35a-435e-a06d-01882ee1b548",
      "name": "Webhook Event (POST)",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -448,
        816
      ],
      "webhookId": "PLACEHOLDER_WEBHOOK_ID"
    },
    {
      "parameters": {
        "fieldToSplitOut": "body.entry",
        "options": {}
      },
      "id": "e13f6909-ec9a-4110-90af-6ff73307983f",
      "name": "Split Entries",
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        -448,
        640
      ]
    },
    {
      "parameters": {
        "fieldToSplitOut": "changes",
        "options": {}
      },
      "id": "b0e2937c-f5f8-499c-8bef-c4f3eaa933d4",
      "name": "Split Changes",
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        -320,
        416
      ]
    },
    {
      "parameters": {
        "url": "={{ $json.attachments.data[0].media.source }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "id": "dab1234d-c090-4cdf-9c28-8627e9d53a80",
      "name": "Download Video from FB",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        656,
        304
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://zernio.com/api/v1/posts",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer PLACEHOLDER_ZERNIO_API_KEY"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { \"content\": $json.caption, \"mediaItems\": [{ \"type\": \"video\", \"url\": $json.video_url }], \"platforms\": [{ \"platform\": \"tiktok\", \"accountId\": \"PLACEHOLDER_TIKTOK_ACCOUNT_ID\" }], \"publishNow\": true } }}",
        "options": {}
      },
      "id": "6eaca5f2-87e1-4cdc-ad76-e178354ba86a",
      "name": "Post to TikTok (Zernio)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1120,
        240
      ],
      "continueOnFail": true
    },
    {
      "parameters": {
        "url": "={{ $json.video_url }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "id": "3e2ee854-6fd0-4edf-be16-8642d1f55ce8",
      "name": "Download Video for YouTube",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1072,
        640
      ],
      "continueOnFail": true
    },
    {
      "parameters": {
        "resource": "video",
        "operation": "upload",
        "title": "={{ $('Build Public Video URL1').item.json.caption.slice(0, 95) }}",
        "regionCode": "VN",
        "categoryId": "=22",
        "options": {
          "description": "={{ $('Build Public Video URL1').item.json.caption }}",
          "privacyStatus": "public"
        }
      },
      "id": "62436d1e-0f2e-4e7f-abaa-745795294670",
      "name": "Post to YouTube Shorts (Native)",
      "type": "n8n-nodes-base.youTube",
      "typeVersion": 1,
      "position": [
        1232,
        640
      ],
      "credentials": {
        "youTubeOAuth2Api": {
          "id": "PLACEHOLDER_CREDENTIAL_ID",
          "name": "YouTube account"
        }
      },
      "continueOnFail": true
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://zernio.com/api/v1/posts",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer PLACEHOLDER_ZERNIO_API_KEY"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { \"content\": $json.caption, \"mediaItems\": [{ \"type\": \"video\", \"url\": $json.video_url }], \"platforms\": [{ \"platform\": \"linkedin\", \"accountId\": \"PLACEHOLDER_ACCOUNT_ID\" }], \"publishNow\": true } }}",
        "options": {}
      },
      "id": "0e8cb563-063f-4d9c-b09f-78e74059e549",
      "name": "Post to LinkedIn (Zernio)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1136,
        816
      ],
      "continueOnFail": true
    },
    {
      "parameters": {
        "numberInputs": 4
      },
      "id": "46e4cae2-5c7e-43c7-8804-455c06576ec5",
      "name": "Gộp 5 nền tảng",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.1,
      "position": [
        1552,
        576
      ]
    },
    {
      "parameters": {
        "chatId": "PLACEHOLDER_TELEGRAM_CHAT_ID",
        "text": "={{ $json.text }}",
        "additionalFields": {}
      },
      "id": "96485110-183d-443e-a878-f7ca1074725c",
      "name": "Báo Telegram - Tổng hợp",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1920,
        672
      ],
      "webhookId": "PLACEHOLDER_WEBHOOK_ID",
      "credentials": {
        "telegramApi": {
          "id": "PLACEHOLDER_CREDENTIAL_ID",
          "name": "Telegram account"
        }
      }
    },
    {
      "parameters": {
        "name": "={{ 'fb-video-' + Date.now() + '.mp4' }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "root",
          "cachedResultName": "/ (Root folder)"
        },
        "options": {}
      },
      "id": "1831a3de-82e9-43cb-aeb4-1f690dabad1d",
      "name": "Upload to Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        432,
        848
      ],
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "PLACEHOLDER_CREDENTIAL_ID",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "operation": "share",
        "fileId": "={{ $json.id }}",
        "permissionsUi": {
          "permissionsValues": {
            "role": "reader",
            "type": "anyone"
          }
        },
        "options": {}
      },
      "id": "4f551d56-c4c2-4cbc-b865-5e3a82a80d84",
      "name": "Share công khai",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        576,
        592
      ],
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "PLACEHOLDER_CREDENTIAL_ID",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "name": "publicUrl",
              "type": "string",
              "value": "={{ 'https://drive.usercontent.google.com/download?id=' + $('Upload to Google Drive').item.json.id + '&export=download' }}"
            }
          ]
        },
        "options": {}
      },
      "id": "1218cf28-5bd9-4815-b566-1470996e710b",
      "name": "Tạo link Drive",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        688,
        848
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://zernio.com/api/v1/posts",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer PLACEHOLDER_ZERNIO_API_KEY"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { \"content\": $json.caption, \"mediaItems\": [{ \"type\": \"video\", \"url\": $json.video_url }], \"platforms\": [{ \"platform\": \"instagram\", \"accountId\": \"PLACEHOLDER_ACCOUNT_ID\" }], \"publishNow\": true } }}",
        "options": {}
      },
      "id": "125cdec2-00da-4187-a334-440889ca38c7",
      "name": "Post to Instagram (Zernio)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1104,
        416
      ],
      "continueOnFail": true
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.value ? $json.value.item : $json.body.entry[0].changes[0].value.item }}",
                    "rightValue": "comment",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "cb6655d8-0121-477f-9cf0-daf1373d706e"
                  },
                  {
                    "leftValue": "={{ $json.value ? $json.value.verb : $json.body.entry[0].changes[0].value.verb }}",
                    "rightValue": "add",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "248f22b1-8a2e-4a1d-ae07-bec6a2ad7b96"
                  },
                  {
                    "leftValue": "={{ $json.value.from.id }}",
                    "rightValue": "={{ $('Split Entries').item.json.id }}",
                    "operator": {
                      "type": "string",
                      "operation": "notEquals"
                    },
                    "id": "8752094e-c24d-42f8-984b-473d821ff259"
                  },
                  {
                    "leftValue": "={{[\"PLACEHOLDER_FB_ADMIN_ID\",\"PLACEHOLDER_FB_ADMIN_ID\",\"PLACEHOLDER_FB_ADMIN_ID\",\"PLACEHOLDER_FB_ADMIN_ID\"]}}",
                    "rightValue": "={{ $json.value.from.id }}",
                    "operator": {
                      "type": "array",
                      "operation": "notContains",
                      "rightType": "any"
                    },
                    "id": "9a7e0dca-5128-4361-b2ff-2eb2e5661cd0"
                  }
                ],
                "combinator": "and"
              }
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.value ? $json.value.item : $json.body.entry[0].changes[0].value.item }}",
                    "rightValue": "video",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "a2e00102-2667-479a-9fe8-3d3867af426b"
                  },
                  {
                    "leftValue": "={{ $json.value ? $json.value.verb : $json.body.entry[0].changes[0].value.verb }}",
                    "rightValue": "add",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "04e506bd-71d7-4097-9ee2-a9458db6d0bb"
                  }
                ],
                "combinator": "and"
              }
            }
          ]
        },
        "options": {
          "fallbackOutput": "none"
        }
      },
      "id": "b916d3ab-aa41-4af5-af3d-0e13cf327373",
      "name": "Phân loại sự kiện Feed",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -144,
        416
      ]
    },
    {
      "parameters": {
        "jsCode": "const items = $input.all();\nconst displayNames = { tiktok: 'TikTok', instagram: 'Instagram', linkedin: 'LinkedIn', threads: 'Threads' };\nlet lines = ['📊 Báo cáo đăng bài:'];\nitems.forEach((item) => {\n  const j = item.json;\n  if (j.kind && j.kind.includes('youtube')) {\n    lines.push(`YouTube Shorts: ✅ https://youtube.com/watch?v=${j.id}`);\n    return;\n  }\n  const platformResult = j.post ? j.post.platforms?.[0] : (j.platforms ? j.platforms[0] : null);\n  if (platformResult && !j.error) {\n    const name = displayNames[platformResult.platform] || platformResult.platform;\n    lines.push(`${name}: ✅ ${platformResult.platformPostUrl}`);\n    return;\n  }\n  if (j.error) {\n    lines.push(`Không rõ nền tảng: ❌ ${j.error.message || JSON.stringify(j.error)}`);\n    return;\n  }\n  lines.push('Không rõ nền tảng: ⚠️ Không xác định được kết quả');\n});\nreturn [{ json: { text: lines.join('\\n') } }];"
      },
      "id": "0e586f3c-e6c5-4016-84a0-dea8fc7c1b6d",
      "name": "Gộp nội dung báo cáo1",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1712,
        592
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "name": "video_url",
              "type": "string",
              "value": "={{ $json.publicUrl }}"
            },
            {
              "name": "caption",
              "type": "string",
              "value": "={{ $('Get Post Details (Graph API)1').item.json.message }}"
            }
          ]
        },
        "options": {}
      },
      "id": "229198a1-48b6-4c52-8f1b-898a0862cea6",
      "name": "Build Public Video URL1",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        816,
        464
      ]
    },
    {
      "parameters": {},
      "id": "97cf4cad-abca-4e9d-886e-d0dcd1c7a8cb",
      "name": "Wait 5s",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        112,
        416
      ],
      "webhookId": "PLACEHOLDER_WEBHOOK_ID"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "leftValue": "={{ $json.is_published }}",
              "rightValue": false,
              "operator": {
                "type": "boolean",
                "operation": "equals"
              },
              "id": "98d96b09-b40a-4605-bb03-3f62ffdcda85"
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "9fd7da96-7b0b-4cd9-9c7e-36e707059c34",
      "name": "Is Published?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        640,
        64
      ]
    },
    {
      "parameters": {
        "url": "=https://graph.facebook.com/v19.0/{{ $json.value.post_id }}",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "fields",
              "value": "message,full_picture,permalink_url,is_published,attachments{media_type,media,url},scheduled_publish_time"
            },
            {
              "name": "access_token",
              "value": "PLACEHOLDER_FB_ACCESS_TOKEN"
            }
          ]
        },
        "options": {}
      },
      "id": "367c0fb7-4106-44ea-9b90-f60084355fae",
      "name": "Get Post Details (Graph API)1",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        320,
        288
      ]
    },
    {
      "parameters": {
        "resume": "specificTime",
        "dateTime": "={{ $('Get Post Details (Graph API)1').item.json.scheduled_publish_time ? new Date($('Get Post Details (Graph API)1').item.json.scheduled_publish_time * 1000).toISOString() : new Date().toISOString() }}"
      },
      "id": "6d7392ca-bf17-4366-b2cf-8ecae864126b",
      "name": "Wait Until Public",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        880,
        720
      ],
      "webhookId": "PLACEHOLDER_WEBHOOK_ID"
    }
  ],
  "pinData": {},
  "connections": {
    "Webhook Verify (GET)": {
      "main": [
        [
          {
            "node": "Check Verify Token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Verify Token": {
      "main": [
        [
          {
            "node": "Respond Challenge",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond Forbidden",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook Event (POST)": {
      "main": [
        [
          {
            "node": "Split Entries",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Entries": {
      "main": [
        [
          {
            "node": "Split Changes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Changes": {
      "main": [
        [
          {
            "node": "Phân loại sự kiện Feed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Video from FB": {
      "main": [
        [
          {
            "node": "Upload to Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Video for YouTube": {
      "main": [
        [
          {
            "node": "Post to YouTube Shorts (Native)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post to YouTube Shorts (Native)": {
      "main": [
        [
          {
            "node": "Gộp 5 nền tảng",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Post to LinkedIn (Zernio)": {
      "main": [
        [
          {
            "node": "Gộp 5 nền tảng",
            "type": "main",
            "index": 3
          }
        ]
      ]
    },
    "Gộp 5 nền tảng": {
      "main": [
        [
          {
            "node": "Gộp nội dung báo cáo1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload to Google Drive": {
      "main": [
        [
          {
            "node": "Share công khai",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Share công khai": {
      "main": [
        [
          {
            "node": "Tạo link Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tạo link Drive": {
      "main": [
        [
          {
            "node": "Build Public Video URL1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post to Instagram (Zernio)": {
      "main": [
        [
          {
            "node": "Gộp 5 nền tảng",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Phân loại sự kiện Feed": {
      "main": [
        [],
        [
          {
            "node": "Wait 5s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gộp nội dung báo cáo1": {
      "main": [
        [
          {
            "node": "Báo Telegram - Tổng hợp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Public Video URL1": {
      "main": [
        [
          {
            "node": "Wait Until Public",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 5s": {
      "main": [
        [
          {
            "node": "Get Post Details (Graph API)1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Published?": {
      "main": [
        [
          {
            "node": "Download Video from FB",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Post Details (Graph API)1": {
      "main": [
        [
          {
            "node": "Is Published?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait Until Public": {
      "main": [
        [
          {
            "node": "Post to Instagram (Zernio)",
            "type": "main",
            "index": 0
          },
          {
            "node": "Download Video for YouTube",
            "type": "main",
            "index": 0
          },
          {
            "node": "Post to LinkedIn (Zernio)",
            "type": "main",
            "index": 0
          },
          {
            "node": "Post to TikTok (Zernio)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post to TikTok (Zernio)": {
      "main": [
        [
          {
            "node": "Gộp 5 nền tảng",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "PLACEHOLDER_VERSION_ID",
  "meta": {
    "instanceId": "PLACEHOLDER_INSTANCE_ID"
  },
  "nodeGroups": [],
  "id": "PLACEHOLDER_WORKFLOW_ID",
  "tags": []
}