{
  "name": "02 \u2013 Notify Editor When Draft Ready",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "sheetId": "={{ $vars.GOOGLE_SHEETS_ID }}",
        "range": "Pipeline!A:N",
        "keyRow": 1,
        "startIndex": 2
      },
      "name": "Watch Sheets: Draft Ready",
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "typeVersion": 4,
      "position": [
        240,
        300
      ],
      "id": "node-1",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json['Status'] }}",
              "operation": "equals",
              "value2": "Draft Ready"
            }
          ]
        }
      },
      "name": "Filter: Status = Draft Ready",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        460,
        300
      ],
      "id": "node-2"
    },
    {
      "parameters": {
        "fromEmail": "={{ $vars.GMAIL_USER }}",
        "toEmail": "editor@yourcompany.com",
        "subject": "=\ud83d\udcdd [Review C\u1ea7n] {{ $json['Content Type'] }}: {{ $json['Topic'] }}",
        "emailType": "html",
        "message": "=<div style=\"font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto;\">\n  <div style=\"background: #4f46e5; padding: 20px; border-radius: 8px 8px 0 0;\">\n    <h2 style=\"color: white; margin: 0;\">\ud83d\udcdd B\u1ea3n Nh\u00e1p S\u1eb5n S\u00e0ng Review</h2>\n  </div>\n  <div style=\"background: #f9fafb; padding: 24px; border-radius: 0 0 8px 8px; border: 1px solid #e5e7eb;\">\n    <table style=\"width: 100%;\">\n      <tr><td style=\"color: #6b7280; width: 120px;\">ID:</td><td style=\"font-weight: 600;\">{{ $json['ID'] }}</td></tr>\n      <tr><td style=\"color: #6b7280;\">Topic:</td><td style=\"font-weight: 600;\">{{ $json['Topic'] }}</td></tr>\n      <tr><td style=\"color: #6b7280;\">Lo\u1ea1i:</td><td>{{ $json['Content Type'] }}</td></tr>\n      <tr><td style=\"color: #6b7280;\">AI Model:</td><td>{{ $json['AI Model'] }}</td></tr>\n      <tr><td style=\"color: #6b7280;\">Assign:</td><td>{{ $json['Editor'] || 'Ch\u01b0a assign' }}</td></tr>\n    </table>\n    <div style=\"margin-top: 20px;\">\n      {{ $json['Draft URL'] ? '<a href=\"' + $json['Draft URL'] + '\" style=\"background: #4f46e5; color: white; padding: 12px 24px; border-radius: 6px; text-decoration: none; display: inline-block;\">\ud83d\udcc4 Xem B\u1ea3n Nh\u00e1p</a>' : '<p style=\"color: #9ca3af;\">Draft \u0111ang \u0111\u01b0\u1ee3c l\u01b0u...</p>' }}\n    </div>\n    <p style=\"color: #6b7280; font-size: 14px; margin-top: 16px;\">\n      Vui l\u00f2ng review v\u00e0 c\u1eadp nh\u1eadt status trong <strong>Google Sheet Pipeline</strong>.\n    </p>\n  </div>\n</div>"
      },
      "name": "Gmail: Notify Editor",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2,
      "position": [
        680,
        200
      ],
      "id": "node-3",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "webhookUri": "={{ $vars.SLACK_WEBHOOK_URL }}",
        "text": "=*\ud83d\udcdd Content S\u1eb5n S\u00e0ng Review!*\n\n*ID:* `{{ $json['ID'] }}`\n*Topic:* {{ $json['Topic'] }}\n*Lo\u1ea1i:* {{ $json['Content Type'] }}\n*Assign:* {{ $json['Editor'] || '@channel' }}\n\n{{ $json['Draft URL'] ? '<' + $json['Draft URL'] + '|\ud83d\udc49 Xem b\u1ea3n nh\u00e1p t\u1ea1i \u0111\u00e2y>' : 'Draft \u0111ang \u0111\u01b0\u1ee3c upload...' }}\n\n_Vui l\u00f2ng review v\u00e0 c\u1eadp nh\u1eadt status trong Sheets._"
      },
      "name": "Slack: Notify Channel",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.1,
      "position": [
        680,
        400
      ],
      "id": "node-4",
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "sheetId": "={{ $vars.GOOGLE_SHEETS_ID }}",
        "range": "Pipeline!A:N",
        "keyRow": 1,
        "dataToSend": {
          "values": [
            {
              "column": "Status",
              "value": "In Review"
            }
          ]
        }
      },
      "name": "Sheets: Update \u2192 In Review",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        900,
        300
      ],
      "id": "node-5",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Watch Sheets: Draft Ready": {
      "main": [
        [
          {
            "node": "Filter: Status = Draft Ready",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter: Status = Draft Ready": {
      "main": [
        [
          {
            "node": "Gmail: Notify Editor",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Gmail: Notify Editor": {
      "main": [
        [
          {
            "node": "Slack: Notify Channel",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Slack: Notify Channel": {
      "main": [
        [
          {
            "node": "Sheets: Update \u2192 In Review",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "meta": {
    "description": "Workflow 2: Khi draft s\u1eb5n s\u00e0ng \u2192 G\u1eedi email + Slack notification cho editor \u2192 Update status v\u1ec1 In Review",
    "version": "1.0"
  }
}