{
  "id": "DhContentSync01",
  "name": "Doppelherz — Robot đồng bộ nội dung Website → Facebook, Pinterest",
  "active": false,
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "doppelherz-new-post",
        "responseMode": "onReceived",
        "options": {}
      },
      "id": "1f4ead79-ceac-54b1-9df4-b692c4e77469",
      "name": "Webhook: WordPress đăng bài mới",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        0
      ],
      "webhookId": "6f1c2a3b-doppelherz-new-post"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $env.ROBOT_URL }}/webhook/wordpress",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Webhook-Secret",
              "value": "={{ $env.ROBOT_WEBHOOK_SECRET }}"
            },
            {
              "name": "X-Trigger",
              "value": "n8n:webhook"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={ \"post_id\": {{ $json.body.post_id }} }",
        "options": {}
      },
      "id": "5de99010-01b8-5bfa-9309-a5f65e11f361",
      "name": "Robot: viết lại + kiểm duyệt bài",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        260,
        0
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ ($json.variants || []).length }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "57a9f2db-afef-55d3-9d40-4d345974fcf9",
      "name": "Có bản chờ duyệt?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        520,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.telegram.org/bot{{ $env.TELEGRAM_BOT_TOKEN }}/sendMessage",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={ \"chat_id\": \"{{ $env.TELEGRAM_CHAT_ID }}\", \"text\": \"📝 Có {{ $json.variants.length }} bản mạng xã hội mới chờ duyệt. Mở dashboard: {{ $env.ROBOT_PUBLIC_URL }}\" }",
        "options": {}
      },
      "id": "e4ef6cda-4d48-528d-90b1-6c095879a2f1",
      "name": "Telegram: báo biên tập duyệt bài",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        780,
        -80
      ],
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 15
            }
          ]
        }
      },
      "id": "a27b740b-2bcf-5e3c-b4e8-64d9697db9f9",
      "name": "Lịch: mỗi 15 phút",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        260
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $env.ROBOT_URL }}/api/sync?limit=5&category=3",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Trigger",
              "value": "n8n:cron-15m"
            }
          ]
        }
      },
      "id": "b4d1e5cc-9662-565a-bfe1-dacc89fba93a",
      "name": "Robot: quét bài mới (dự phòng webhook)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        260,
        260
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $env.ROBOT_URL }}/api/run-due",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Trigger",
              "value": "n8n:cron-15m"
            }
          ]
        }
      },
      "id": "09a82946-430d-5f93-87bc-a7b3a035c4c5",
      "name": "Robot: đăng các bài đến giờ",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        520,
        260
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 8 * * 1"
            }
          ]
        }
      },
      "id": "5fd292b2-2945-5482-9294-88e169886e6c",
      "name": "Lịch: 8:00 thứ Hai",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        520
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $env.ROBOT_URL }}/api/metrics",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Trigger",
              "value": "n8n:weekly"
            }
          ]
        }
      },
      "id": "8bd95677-2099-5554-b45e-cf9a73ea9995",
      "name": "Robot: cập nhật số liệu tương tác",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        260,
        520
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "={{ $env.ROBOT_URL }}/api/report",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Trigger",
              "value": "n8n:weekly"
            }
          ]
        }
      },
      "id": "e1ee5cb1-2b61-5c7f-91dd-5ada52905dfb",
      "name": "Robot: lập báo cáo tuần",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        520,
        520
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.telegram.org/bot{{ $env.TELEGRAM_BOT_TOKEN }}/sendMessage",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ chat_id: $env.TELEGRAM_CHAT_ID, text: $json.text }) }}",
        "options": {}
      },
      "id": "d9e9faca-8dfa-52af-a864-6c09dcec60ea",
      "name": "Telegram: gửi báo cáo tuần",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        780,
        520
      ],
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $env.ROBOT_URL }}/api/metrics",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Trigger",
              "value": "n8n:cron-15m"
            }
          ]
        },
        "options": {}
      },
      "id": "af2a49b8-022f-59df-9dba-16a3ec6c69c2",
      "name": "Robot: cập nhật số liệu (sau khi đăng)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        780,
        260
      ]
    }
  ],
  "connections": {
    "Webhook: WordPress đăng bài mới": {
      "main": [
        [
          {
            "node": "Robot: viết lại + kiểm duyệt bài",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Robot: viết lại + kiểm duyệt bài": {
      "main": [
        [
          {
            "node": "Có bản chờ duyệt?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Có bản chờ duyệt?": {
      "main": [
        [
          {
            "node": "Telegram: báo biên tập duyệt bài",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Lịch: mỗi 15 phút": {
      "main": [
        [
          {
            "node": "Robot: quét bài mới (dự phòng webhook)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Robot: quét bài mới (dự phòng webhook)": {
      "main": [
        [
          {
            "node": "Robot: đăng các bài đến giờ",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lịch: 8:00 thứ Hai": {
      "main": [
        [
          {
            "node": "Robot: cập nhật số liệu tương tác",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Robot: cập nhật số liệu tương tác": {
      "main": [
        [
          {
            "node": "Robot: lập báo cáo tuần",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Robot: lập báo cáo tuần": {
      "main": [
        [
          {
            "node": "Telegram: gửi báo cáo tuần",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Robot: đăng các bài đến giờ": {
      "main": [
        [
          {
            "node": "Robot: cập nhật số liệu (sau khi đăng)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "timezone": "Asia/Ho_Chi_Minh"
  },
  "pinData": {},
  "tags": []
}