{
  "nodes": [
    {
      "parameters": {
        "jsCode": "return [{\n  json: {\n    attached_media: $input.all().map(item => ({\n      media_fbid: item.json.id // Giữ danh sách media_fbid từ các item trước\n    })),\n  }\n}];\n\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2360,
        200
      ],
      "id": "be039605-c372-4387-8b34-8d19f952e557",
      "name": "Merge Photo Ids"
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineAll",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3,
      "position": [
        2640,
        280
      ],
      "id": "3c2afc18-d030-4c74-86de-370efe61c9a3",
      "name": "Merge",
      "executeOnce": true
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json['Loại bài viết'] }}",
                    "rightValue": "Nhiều Ảnh",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "9dd48146-7a45-40dc-b767-b2e2912c9222"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Đăng Nhiều Ảnh"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "6218b7a5-0a35-47e5-a238-3d47391ca197",
                    "leftValue": "={{ $json['Loại bài viết'] }}",
                    "rightValue": "Một Ảnh",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Đăng Một Ảnh"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "729dd07c-e848-4bd6-a674-45493004bded",
                    "leftValue": "={{ $json['Loại bài viết'] }}",
                    "rightValue": "Không Ảnh",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Đăng không ảnh"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "490bd794-3110-4c68-b341-184c245bee34",
                    "leftValue": "={{ $json['Loại bài viết'] }}",
                    "rightValue": "Reels",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Đăng Reels"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "9e8d0dc7-959a-40ff-adaf-a915188e85f3",
                    "leftValue": "={{ $json['Loại bài viết'] }}",
                    "rightValue": "Video",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Đăng Video"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "1f12d000-7084-431d-8126-45067694db0f",
                    "leftValue": "={{ $json[\"Loại bài viết\"] }}",
                    "rightValue": "Story_Images",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Đăng Story Ảnh"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "033e0992-0069-4854-85c3-8b959a5595b4",
                    "leftValue": "={{ $json['Loại bài viết'] }}",
                    "rightValue": "Story_Video",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Đăng Story Video"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        960,
        1320
      ],
      "id": "4a23a8dc-5ca6-4b81-b5dd-acbd6edb511e",
      "name": "Switch"
    },
    {
      "parameters": {
        "fieldToSplitOut": "Link",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        1720,
        200
      ],
      "id": "1568cb13-a8d2-4166-8648-c015f0e015c2",
      "name": "Split Out"
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/11SWC5VyspWd23SSZOnkxIzkB1FbunIyu_DcQ4Fx0l5k/edit?gid=0#gid=0",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Content",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/11SWC5VyspWd23SSZOnkxIzkB1FbunIyu_DcQ4Fx0l5k/edit#gid=0"
        },
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "Trạng thái",
              "lookupValue": "Queue"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        740,
        420
      ],
      "id": "a170016f-d11e-4752-a51d-593584539cda",
      "name": "Google Sheets",
      "executeOnce": true,
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "AxWVGvJ75f8LaApa",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://graph.facebook.com/v22.0/{{ $('ReadContent').item.json[\"ID Trang\"] }}/feed",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('ReadContent').item.json.accessToken }}"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "attached_media",
              "value": "={{ $json.attached_media }}"
            },
            {
              "name": "message",
              "value": "={{ $('ReadContent').item.json.title }}\n\n{{ $('ReadContent').item.json.content }}\n{{ $('ReadContent').item.json['Nội dung bắt buộc'] }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2780,
        280
      ],
      "id": "a7ae85d7-e35c-40db-a85a-b9269e66c9e8",
      "name": "PostFeed"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://graph.facebook.com/v22.0/{{ $('ReadContent').item.json[\"ID Trang\"] }}/photos",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('ReadContent').item.json.accessToken }}"
            }
          ]
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "parameterType": "formBinaryData",
              "name": "data",
              "inputDataFieldName": "data"
            },
            {
              "name": "message",
              "value": "={{ $('ReadContent').item.json.title }}\n\n{{ $('ReadContent').item.json.content }}\n{{ $('ReadContent').item.json['Nội dung bắt buộc'] }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2780,
        480
      ],
      "id": "6523ca53-1a49-4608-b0cb-57272d18aa16",
      "name": "PostSinglePhoto"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://graph.facebook.com/v22.0/{{ $('ReadContent').item.json[\"ID Trang\"] }}/feed",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('ReadContent').item.json.accessToken }}"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "attached_media",
              "value": "={{ $json.attached_media }}"
            },
            {
              "name": "message",
              "value": "={{ $('ReadContent').item.json.title }}\n\n{{ $('ReadContent').item.json.content }}\n{{ $('ReadContent').item.json['Nội dung bắt buộc'] }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2780,
        640
      ],
      "id": "18747513-f500-4c0b-b387-082797f00361",
      "name": "PostFeedText"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1560,
        640
      ],
      "id": "4d055783-ce57-4d59-8855-486259ce51e8",
      "name": "No Operation, do nothing1"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $json.upload_url }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=OAuth {{ $('ReadContent').last().json.accessToken }}"
            },
            {
              "name": "offset",
              "value": "0"
            },
            {
              "name": "file_size",
              "value": "={{ $binary.data.fileSize.split(' ')[0] * 100000 }}"
            }
          ]
        },
        "sendBody": true,
        "contentType": "binaryData",
        "inputDataFieldName": "data",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1900,
        840
      ],
      "id": "c880f3c7-c24b-4e16-9283-ea9109f32080",
      "name": "Upload a Local File"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://graph.facebook.com/v22.0/{{ $('ReadContent').item.json[\"ID Trang\"] }}/video_reels",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "upload_phase",
              "value": "start"
            }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('ReadContent').item.json.accessToken }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1560,
        840
      ],
      "id": "4c64dcc5-ab63-4e15-be6b-01dbff060e7b",
      "name": "CreateSessionUpload"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://graph.facebook.com/v22.0/{{ $('ReadContent').item.json['ID Trang'] }}/video_reels",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "access_token",
              "value": "={{ $('ReadContent').item.json.accessToken }}"
            },
            {
              "name": "video_id",
              "value": "={{ $('CreateSessionUpload').item.json.video_id }}"
            },
            {
              "name": "upload_phase",
              "value": "FINISH"
            },
            {
              "name": "video_state",
              "value": "PUBLISHED"
            },
            {
              "name": "description",
              "value": "={{ $('ReadContent').item.json.title }}\n\n{{ $('ReadContent').item.json.content }}\n{{ $('ReadContent').item.json['Nội dung bắt buộc'] }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2140,
        840
      ],
      "id": "c95cde60-69ac-495a-ab15-c06f1793967c",
      "name": "Manual Publish"
    },
    {
      "parameters": {
        "amount": 10
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        2360,
        840
      ],
      "id": "b02ecbcc-904b-4614-8593-b756c85f300a",
      "name": "Wait",
      "webhookId": "924656cc-bd66-4587-b976-8aae149f8ea8"
    },
    {
      "parameters": {
        "url": "=https://graph.facebook.com/v22.0/{{ $('CreateSessionUpload').item.json.video_id }}",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "fields",
              "value": "status "
            },
            {
              "name": "access_token",
              "value": "={{ $('ReadContent').item.json.accessToken }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2780,
        840
      ],
      "id": "6e97300e-e13b-4669-af68-591b108c779b",
      "name": "check status"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://graph.facebook.com/v22.0/{{ $('ReadContent').item.json[\"ID Trang\"] }}/videos",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "videoUrl",
              "value": "=start {{ $json['Link Video'] }}"
            },
            {
              "name": "description",
              "value": "={{ $('ReadContent').item.json.title }}\n\n{{ $('ReadContent').item.json.content }}\n{{ $('ReadContent').item.json['Nội dung bắt buộc'] }}"
            }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('ReadContent').item.json.accessToken }}"
            }
          ]
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "parameterType": "formBinaryData",
              "name": "data",
              "inputDataFieldName": "data"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2780,
        1060
      ],
      "id": "1d784555-db70-48c8-968d-40a22d7e72e3",
      "name": "UploadVideo"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://graph.facebook.com/v22.0/{{ $('ReadContent').item.json[\"ID Trang\"] }}/video_stories",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "upload_phase",
              "value": "start"
            }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('ReadContent').item.json.accessToken }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1560,
        1500
      ],
      "id": "0600cabe-f89d-4601-a262-4c175275226a",
      "name": "CreateSessionUploadVideoStory"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $json.upload_url }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=OAuth {{ $('ReadContent').last().json.accessToken }}"
            },
            {
              "name": "offset",
              "value": "0"
            },
            {
              "name": "file_size",
              "value": "={{ $binary.data.fileSize.split(' ')[0] * 100000 }}"
            }
          ]
        },
        "sendBody": true,
        "contentType": "binaryData",
        "inputDataFieldName": "data",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1900,
        1500
      ],
      "id": "bde1f9fc-545b-4850-9f68-bec23712dca3",
      "name": "Upload Video Story"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://graph.facebook.com/v22.0/{{ $('ReadContent').item.json['ID Trang'] }}/video_stories",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "access_token",
              "value": "={{ $('ReadContent').item.json.accessToken }}"
            },
            {
              "name": "video_id",
              "value": "={{ $('CreateSessionUploadVideoStory').item.json.video_id }}"
            },
            {
              "name": "upload_phase",
              "value": "finish"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2580,
        1500
      ],
      "id": "a827c47c-d67f-4fdf-bc42-5018c1d3398f",
      "name": "Pushlish Story"
    },
    {
      "parameters": {
        "url": "=https://graph.facebook.com/v23.0/{{ $('CreateSessionUploadVideoStory').item.json.video_id }}",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "access_token",
              "value": "={{ $('ReadContent').item.json.accessToken }}"
            },
            {
              "name": "fields",
              "value": "status"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2120,
        1500
      ],
      "id": "7ef4d47b-884d-4bde-a86c-5104ea7f76b2",
      "name": "GetStatusVideoStory"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "8733b520-ea60-4703-b922-2a6d80d6588d",
              "leftValue": "={{ $json.status.processing_phase?.error }}",
              "rightValue": "",
              "operator": {
                "type": "object",
                "operation": "notExists",
                "singleValue": true
              }
            },
            {
              "id": "94c680be-93b6-4eb5-b6ff-705839287627",
              "leftValue": "={{ $json.status.copyright_check_status.status }}",
              "rightValue": "complete",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        2340,
        1500
      ],
      "id": "2d7e3e59-7d7a-40c7-80da-a966338445c0",
      "name": "If"
    },
    {
      "parameters": {
        "amount": 10
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        2580,
        1680
      ],
      "id": "16403285-14e2-469c-91c2-c412036e898d",
      "name": "Wait1",
      "webhookId": "68f8668e-01ac-45b0-b65c-f51625c9918c"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://graph.facebook.com/v22.0/{{ $('ReadContent').last().json[\"ID Trang\"] }}/photos",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('ReadContent').item.json.accessToken }}"
            }
          ]
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "parameterType": "formBinaryData",
              "name": "data",
              "inputDataFieldName": "data"
            },
            {
              "name": "published",
              "value": "false"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1740,
        1280
      ],
      "id": "f8421d30-ecfd-46ac-8ea6-2cdbc08456e2",
      "name": "UploadImage"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://graph.facebook.com/v22.0/{{ $('ReadContent').item.json['ID Trang'] }}/photo_stories",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "access_token",
              "value": "={{ $('ReadContent').item.json.accessToken }}"
            },
            {
              "name": "photo_id",
              "value": "={{ $json.id }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2580,
        1280
      ],
      "id": "5b9e2117-2b77-4ed3-8daa-89468457352c",
      "name": "PostStory"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "59bdf330-df02-451e-91dd-cfb37bdc414a",
              "name": "id",
              "value": "=stories/{{ $json.post_id }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        2760,
        1380
      ],
      "id": "81181063-1480-4a89-9ff6-983b1f5be733",
      "name": "SetIdStory"
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "={{ $json.Link }}",
          "mode": "url"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        1920,
        200
      ],
      "id": "54f7f442-46dd-4d7d-a787-6371899b695e",
      "name": "DownloadImage",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "s4vmzuANXvCaTyKp",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://graph.facebook.com/v22.0/{{ $('ReadContent').last().json[\"ID Trang\"] }}/photos",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('ReadContent').item.json.accessToken }}"
            }
          ]
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "parameterType": "formBinaryData",
              "name": "data",
              "inputDataFieldName": "data"
            },
            {
              "name": "published",
              "value": "false"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2140,
        200
      ],
      "id": "c68b0f47-0106-4282-9808-5c72ff8ff317",
      "name": "UploadToPhotos"
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "={{ $('ReadContent').last().json.Link[0] }}",
          "mode": "url"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        1560,
        480
      ],
      "id": "ff084a66-e83b-4a2e-8018-6d3912b8854a",
      "name": "DownloadImage2",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "s4vmzuANXvCaTyKp",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "={{ $('ReadContent').item.json['Link Video'] }}",
          "mode": "url"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        1740,
        1500
      ],
      "id": "615ed161-90d8-48b0-9a29-5cb1122f88da",
      "name": "DownloadVideo3",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "s4vmzuANXvCaTyKp",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "d20c173b-3b4a-4555-817b-3ab3ac699d30",
              "name": "content",
              "value": "={{ $json[\"Nội dung chính\"] }}",
              "type": "string"
            },
            {
              "id": "37814ce7-fb97-4fc8-8181-6dbe545c2464",
              "name": "title",
              "value": "={{ $json[\"Chủ đề\"] }}",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        240,
        1400
      ],
      "id": "d88e90e7-ba1b-4879-b5d1-c2e0dd841d31",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "5db2a872-9357-4312-b8a9-b3f7e3fb3943",
              "leftValue": "={{ $json[\"Thời gian đăng\"] }}",
              "rightValue": "={{ $now.toISO() }}",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        220,
        640
      ],
      "id": "3e5a8fba-9a01-40a9-ae8e-53130af65897",
      "name": "IfTimeExists"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "5db2a872-9357-4312-b8a9-b3f7e3fb3943",
              "leftValue": "={{ $json.formattedDate }}",
              "rightValue": "={{ $now.toISO() }}",
              "operator": {
                "type": "dateTime",
                "operation": "before"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        220,
        860
      ],
      "id": "34dae731-83bb-4536-95af-5ff6bb1d6243",
      "name": "IfTimeIsPresent"
    },
    {
      "parameters": {
        "operation": "formatDate",
        "date": "={{ $json[\"Thời gian đăng\"] }}",
        "format": "custom",
        "customFormat": "yyyy-dd-MM'T'HH:mm:ss.000+07:00",
        "options": {}
      },
      "type": "n8n-nodes-base.dateTime",
      "typeVersion": 2,
      "position": [
        740,
        640
      ],
      "id": "547d3521-62df-466c-ac2c-0629662b6eca",
      "name": "FormatTime"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "d9188620-4c52-42d1-91dd-a71c5367b1bd",
              "leftValue": "={{ $json[\"AI Agent\"] }}",
              "rightValue": "Có",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        220,
        1040
      ],
      "id": "e52c2886-153a-42f4-87f1-ddbd53ca70a1",
      "name": "IfUseAIAgent"
    },
    {
      "parameters": {
        "jsCode": "const list = [];\nfor(const item of $('Data').all()) {\n  list.push({\n    ... item.json,\n    accessToken: $('FindPage').first().json[\"Access Token\"],\n    Link: \n      [item.json[\"Ảnh 1(Đại diện)\"],\n      item.json['Ảnh 2'],\n      item.json['Ảnh 4'],\n      item.json['Ảnh 5'],\n      item.json['Ảnh 6'],\n      item.json['Ảnh 7'],\n      item.json['Ảnh 8'],\n      item.json['Ảnh 9'],\n      item.json['Ảnh 10']\n    ].filter(x => !!x),\n    content: $input.last().json.content,\n    title: $input.last().json.title,\n  })\n}\nreturn list;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        760,
        1400
      ],
      "id": "6c6354e5-cb6d-4da9-83aa-d4597907788a",
      "name": "ReadContent"
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 1
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -60,
        420
      ],
      "id": "8619bf94-dccd-4e21-92bd-ca584f6cb57b",
      "name": "Schedule Trigger"
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/11SWC5VyspWd23SSZOnkxIzkB1FbunIyu_DcQ4Fx0l5k/edit?gid=0#gid=0",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Content",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/11SWC5VyspWd23SSZOnkxIzkB1FbunIyu_DcQ4Fx0l5k/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "STT": "={{ $('ReadContent').last().json.STT }}",
            "Link bài đăng": "=http://facebook.com/{{ $json.id }}",
            "Trạng thái": "Thành Công"
          },
          "matchingColumns": [
            "STT"
          ],
          "schema": [
            {
              "id": "STT",
              "displayName": "STT",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Trang",
              "displayName": "Trang",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "ID Trang",
              "displayName": "ID Trang",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Trạng thái",
              "displayName": "Trạng thái",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Chủ đề",
              "displayName": "Chủ đề",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Nội dung chính",
              "displayName": "Nội dung chính",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Nội dung bắt buộc",
              "displayName": "Nội dung bắt buộc",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Thời gian đăng",
              "displayName": "Thời gian đăng",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Link bài đăng",
              "displayName": "Link bài đăng",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Ảnh 1(Đại diện)",
              "displayName": "Ảnh 1(Đại diện)",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 2",
              "displayName": "Ảnh 2",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 3",
              "displayName": "Ảnh 3",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 4",
              "displayName": "Ảnh 4",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 5",
              "displayName": "Ảnh 5",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 6",
              "displayName": "Ảnh 6",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 7",
              "displayName": "Ảnh 7",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 8",
              "displayName": "Ảnh 8",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 9",
              "displayName": "Ảnh 9",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 10",
              "displayName": "Ảnh 10",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "readOnly": true,
              "removed": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.6,
      "position": [
        3180,
        640
      ],
      "id": "7dd88517-177a-4123-992a-0c8d479eca54",
      "name": "UpdateStatusSuccess",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "AxWVGvJ75f8LaApa",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1560,
        300
      ],
      "id": "c61e38d5-4b8d-4820-a530-ca7d44dc89a6",
      "name": "Next"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1720,
        360
      ],
      "id": "ae4f17a9-1b6d-4f5a-a6d8-09c525491b41",
      "name": "Next1"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        2360,
        360
      ],
      "id": "e98e4a1e-2323-4079-bba4-b2388253c959",
      "name": "Next2"
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "={{ $json.Link[0] }}",
          "mode": "url"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        1560,
        1280
      ],
      "id": "800c35f0-d227-4a23-9249-40e290503940",
      "name": "DownloadImageStory",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "s4vmzuANXvCaTyKp",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "={{ $('ReadContent').item.json['Link Video'] }}",
          "mode": "url"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        1720,
        840
      ],
      "id": "35283806-dc12-4306-a22d-49d1082350d2",
      "name": "DownloadVideoReels",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "s4vmzuANXvCaTyKp",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "={{ $('ReadContent').item.json['Link Video'] }}",
          "mode": "url"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        1560,
        1060
      ],
      "id": "42947bcc-2aa1-44e8-855a-28d59e495320",
      "name": "DownloadVideo",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "s4vmzuANXvCaTyKp",
          "name": "Google Drive account"
        }
      }
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/11SWC5VyspWd23SSZOnkxIzkB1FbunIyu_DcQ4Fx0l5k/edit?gid=1902888278#gid=1902888278",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": 1902888278,
          "mode": "list",
          "cachedResultName": "Page",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/11SWC5VyspWd23SSZOnkxIzkB1FbunIyu_DcQ4Fx0l5k/edit#gid=1902888278"
        },
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "ID trang",
              "lookupValue": "={{ $('Google Sheets').item.json[\"ID Trang\"] }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.6,
      "position": [
        500,
        840
      ],
      "id": "541645db-990e-4288-a694-77342243347b",
      "name": "FindPage",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "AxWVGvJ75f8LaApa",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "return $('Loop Over Items').all();"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        740,
        840
      ],
      "id": "f666c3b6-e0f1-488e-91c2-88181f6cc5f0",
      "name": "Data"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        3400,
        1680
      ],
      "id": "0c3bb40f-67cf-49da-9213-d0211a752222",
      "name": "WaitContinueStep",
      "webhookId": "68f8668e-01ac-45b0-b65c-f51625c9918c"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "6ee6f2e0-7f8f-432c-9a5e-2d8ca6a30b07",
              "name": "title",
              "value": "={{ $json.output.title }}",
              "type": "string"
            },
            {
              "id": "9e0fdd15-51c3-414f-84b2-2c7d361e8d09",
              "name": "content",
              "value": "={{ $json.output.content }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        740,
        1040
      ],
      "id": "115113f7-f049-40b5-a85a-6dad76e41db8",
      "name": "Output"
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n\t\"title\": \"The headline for the social meadia post\",\n\t\"content\": \"The formatted social media post\" \n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.2,
      "position": [
        580,
        1260
      ],
      "id": "525c38c7-91d5-443d-b680-d78377e8d967",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "model": "gpt-4o",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1,
      "position": [
        380,
        1260
      ],
      "id": "e4d8d702-1360-4e03-95e7-edb42ca67247",
      "name": "OpenAI Chat Model2",
      "credentials": {
        "openAiApi": {
          "id": "npnMtU7kA3sNSLyr",
          "name": "OpenAi Chatbot"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Chủ đề: {{ $json['Chủ đề'] }}\nNội dung chính: {{ $json['Nội dung chính'] }}",
        "hasOutputParser": true,
        "options": {
          "systemMessage": "=Bạn là 1 chuyên gia về Lĩnh vực sức khỏe Đông y. Bạn viết nội dung chia sẻ kiến thức về sức khỏe và cộng đồng, và đăng tải trên 1 trang Facebook. Bạn hãy viết cho tôi 1 Status Facebook chia sẻ về chủ đề và bao gồm các nội dung chính của người dùng. lấy thêm cho tôi 5 hastag phổ biến về chủ đề.\n\nOutput Format:\n- Trả kết quả bằng tiếng việt.\n- Xuống dòng ở tiêu đề.\n- Status sẽ viết bằng định dạng văn bản, không có format in đậm, in nghiêng, ...\n- Luôn luôn sử dụng SerpAPI để tìm ra keyword SEO tốt nhất.\n- Sử dụng biểu tượng cảm xúc (emoji) ở đầu dòng để làm nổi bật các ý chính, ví dụ: ♥️, 🍀, 🏵️, ⭐… không chèn vào cuối câu, cuối đoạn.\n- Giữ nội dung ngắn gọn, thu hút, không dịch từng từ mà đảm bảo ý nghĩa trôi chảy, dễ đọc\n- Tránh các câu quá dài, giữ bài viết dễ hiểu, giọng điệu tự nhiên\n- Đảm bảo đúng chính tả, ngữ pháp tiếng Việt, tuyệt đối không dùng ký hiệu * hoặc ** trong bài viết."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        400,
        1040
      ],
      "id": "064a1c85-a928-4785-a8fb-386a427cdab8",
      "name": "Think"
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/11SWC5VyspWd23SSZOnkxIzkB1FbunIyu_DcQ4Fx0l5k/edit?gid=1203419718#gid=1203419718",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": 1203419718,
          "mode": "list",
          "cachedResultName": "Result",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/11SWC5VyspWd23SSZOnkxIzkB1FbunIyu_DcQ4Fx0l5k/edit#gid=1203419718"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Link bài đăng": "={{ $json[\"Link bài đăng\"] }}",
            "Thời gian đăng": "={{ $now.toISO() }}",
            "Trạng thái": "={{ $json[\"Trạng thái\"] }}",
            "STT": "={{ $('ReadContent').item.json.STT }}",
            "ID Trang": "={{ $('ReadContent').item.json[\"ID Trang\"] }}",
            "Trang": "={{ $('ReadContent').item.json.Trang }}",
            "AI Agent": "={{ $('ReadContent').item.json[\"AI Agent\"] }}",
            "Loại bài viết": "={{ $('ReadContent').item.json[\"Loại bài viết\"] }}",
            "Chủ đề": "={{ $('ReadContent').item.json.title }}",
            "Nội dung chính": "={{ $('ReadContent').item.json.content }}",
            "Nội dung bắt buộc": "={{ $('ReadContent').item.json[\"Nội dung bắt buộc\"] }}"
          },
          "matchingColumns": [
            "STT"
          ],
          "schema": [
            {
              "id": "STT",
              "displayName": "STT",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Trang",
              "displayName": "Trang",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "ID Trang",
              "displayName": "ID Trang",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Trạng thái",
              "displayName": "Trạng thái",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Loại bài viết",
              "displayName": "Loại bài viết",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "AI Agent",
              "displayName": "AI Agent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Thời gian đăng",
              "displayName": "Thời gian đăng",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Chủ đề",
              "displayName": "Chủ đề",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Nội dung chính",
              "displayName": "Nội dung chính",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Nội dung bắt buộc",
              "displayName": "Nội dung bắt buộc",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Link bài đăng",
              "displayName": "Link bài đăng",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.6,
      "position": [
        3400,
        640
      ],
      "id": "b60d8982-1304-425b-8bef-36abce99df18",
      "name": "UpdateResult",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "AxWVGvJ75f8LaApa",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/11SWC5VyspWd23SSZOnkxIzkB1FbunIyu_DcQ4Fx0l5k/edit?gid=0#gid=0",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Content",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/11SWC5VyspWd23SSZOnkxIzkB1FbunIyu_DcQ4Fx0l5k/edit#gid=0"
        },
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "Trạng thái",
              "lookupValue": "Chờ Đăng"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        220,
        420
      ],
      "id": "827e4912-e406-4a17-bd5b-25e17a955590",
      "name": "GetAllPending",
      "alwaysOutputData": false,
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "AxWVGvJ75f8LaApa",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/11SWC5VyspWd23SSZOnkxIzkB1FbunIyu_DcQ4Fx0l5k/edit?gid=0#gid=0",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Content",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/11SWC5VyspWd23SSZOnkxIzkB1FbunIyu_DcQ4Fx0l5k/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "STT": "={{ $json.STT }}",
            "Trạng thái": "Queue"
          },
          "matchingColumns": [
            "STT"
          ],
          "schema": [
            {
              "id": "STT",
              "displayName": "STT",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Trang",
              "displayName": "Trang",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "ID Trang",
              "displayName": "ID Trang",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Trạng thái",
              "displayName": "Trạng thái",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Loại bài viết",
              "displayName": "Loại bài viết",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Chủ đề",
              "displayName": "Chủ đề",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Nội dung chính",
              "displayName": "Nội dung chính",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Nội dung bắt buộc",
              "displayName": "Nội dung bắt buộc",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Thời gian đăng",
              "displayName": "Thời gian đăng",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Link bài đăng",
              "displayName": "Link bài đăng",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Link Video",
              "displayName": "Link Video",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 1(Đại diện)",
              "displayName": "Ảnh 1(Đại diện)",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 2",
              "displayName": "Ảnh 2",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 3",
              "displayName": "Ảnh 3",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 4",
              "displayName": "Ảnh 4",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 5",
              "displayName": "Ảnh 5",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 6",
              "displayName": "Ảnh 6",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 7",
              "displayName": "Ảnh 7",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 8",
              "displayName": "Ảnh 8",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 9",
              "displayName": "Ảnh 9",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 10",
              "displayName": "Ảnh 10",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "readOnly": true,
              "removed": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        500,
        420
      ],
      "id": "f58ec297-6896-40fb-a675-adacecb0cc54",
      "name": "UpdateToQueue",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "AxWVGvJ75f8LaApa",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -60,
        620
      ],
      "id": "80a81740-655c-4c0c-935c-9478f13a45c4",
      "name": "Loop Over Items"
    },
    {
      "parameters": {
        "content": "## Đăng bài Fanpage all in one và nội dung tự động bằng Open Ai\nTừng bước cấu hình trong các node, lưu ý bỏ ghim ở node google sheet khi chạy\n![](https://datadex.vn/storage/2025/06/auto-post-content.png)\n**[Video Hướng dẫn](https://www.youtube.com/watch?v=LMrwOltLHTY)",
        "height": 540,
        "width": 640
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        900,
        420
      ],
      "typeVersion": 1,
      "id": "feeff62a-c306-4049-a1f4-d5dfa4508708",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/11SWC5VyspWd23SSZOnkxIzkB1FbunIyu_DcQ4Fx0l5k/edit?gid=0#gid=0",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Content",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/11SWC5VyspWd23SSZOnkxIzkB1FbunIyu_DcQ4Fx0l5k/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "STT": "={{ $('Loop Over Items').item.json.STT }}",
            "Trạng thái": "Chờ Đăng"
          },
          "matchingColumns": [
            "STT"
          ],
          "schema": [
            {
              "id": "STT",
              "displayName": "STT",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Trang",
              "displayName": "Trang",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "ID Trang",
              "displayName": "ID Trang",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Trạng thái",
              "displayName": "Trạng thái",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Loại bài viết",
              "displayName": "Loại bài viết",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Chủ đề",
              "displayName": "Chủ đề",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Nội dung chính",
              "displayName": "Nội dung chính",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Nội dung bắt buộc",
              "displayName": "Nội dung bắt buộc",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Thời gian đăng",
              "displayName": "Thời gian đăng",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Link bài đăng",
              "displayName": "Link bài đăng",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Link Video",
              "displayName": "Link Video",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 1(Đại diện)",
              "displayName": "Ảnh 1(Đại diện)",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 2",
              "displayName": "Ảnh 2",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 3",
              "displayName": "Ảnh 3",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 4",
              "displayName": "Ảnh 4",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 5",
              "displayName": "Ảnh 5",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 6",
              "displayName": "Ảnh 6",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 7",
              "displayName": "Ảnh 7",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 8",
              "displayName": "Ảnh 8",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 9",
              "displayName": "Ảnh 9",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Ảnh 10",
              "displayName": "Ảnh 10",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "readOnly": true,
              "removed": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -500,
        620
      ],
      "id": "69866381-4ca4-49bc-9a29-6a8bd0b8cb49",
      "name": "UpdateToPending",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "AxWVGvJ75f8LaApa",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "amount": 3
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -280,
        620
      ],
      "id": "a70bed70-9aa6-45ff-9133-eeeb22b1dabb",
      "name": "Wait2",
      "webhookId": "7a2ba736-d30b-48d3-b164-bd2b8b8efc04"
    }
  ],
  "connections": {
    "Merge Photo Ids": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "PostFeed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Next",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "DownloadImage2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "CreateSessionUpload",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "DownloadVideo",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "DownloadImageStory",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "CreateSessionUploadVideoStory",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "DownloadImage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PostFeed": {
      "main": [
        [
          {
            "node": "UpdateStatusSuccess",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PostSinglePhoto": {
      "main": [
        [
          {
            "node": "UpdateStatusSuccess",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PostFeedText": {
      "main": [
        [
          {
            "node": "UpdateStatusSuccess",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "No Operation, do nothing1": {
      "main": [
        [
          {
            "node": "PostFeedText",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload a Local File": {
      "main": [
        [
          {
            "node": "Manual Publish",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CreateSessionUpload": {
      "main": [
        [
          {
            "node": "DownloadVideoReels",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Manual Publish": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "check status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "check status": {
      "main": [
        [
          {
            "node": "UpdateStatusSuccess",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "UploadVideo": {
      "main": [
        [
          {
            "node": "UpdateStatusSuccess",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CreateSessionUploadVideoStory": {
      "main": [
        [
          {
            "node": "DownloadVideo3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Video Story": {
      "main": [
        [
          {
            "node": "GetStatusVideoStory",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pushlish Story": {
      "main": [
        [
          {
            "node": "SetIdStory",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GetStatusVideoStory": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Pushlish Story",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait1": {
      "main": [
        [
          {
            "node": "GetStatusVideoStory",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "UploadImage": {
      "main": [
        [
          {
            "node": "PostStory",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PostStory": {
      "main": [
        [
          {
            "node": "SetIdStory",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SetIdStory": {
      "main": [
        [
          {
            "node": "UpdateStatusSuccess",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DownloadImage": {
      "main": [
        [
          {
            "node": "UploadToPhotos",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "UploadToPhotos": {
      "main": [
        [
          {
            "node": "Merge Photo Ids",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DownloadImage2": {
      "main": [
        [
          {
            "node": "PostSinglePhoto",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DownloadVideo3": {
      "main": [
        [
          {
            "node": "Upload Video Story",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "ReadContent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IfTimeExists": {
      "main": [
        [
          {
            "node": "FormatTime",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "FindPage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IfTimeIsPresent": {
      "main": [
        [
          {
            "node": "FindPage",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "UpdateToPending",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FormatTime": {
      "main": [
        [
          {
            "node": "IfTimeIsPresent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IfUseAIAgent": {
      "main": [
        [
          {
            "node": "Think",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ReadContent": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "GetAllPending",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "UpdateStatusSuccess": {
      "main": [
        [
          {
            "node": "UpdateResult",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Next": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          },
          {
            "node": "Next1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Next1": {
      "main": [
        [
          {
            "node": "Next2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Next2": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "DownloadImageStory": {
      "main": [
        [
          {
            "node": "UploadImage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DownloadVideoReels": {
      "main": [
        [
          {
            "node": "Upload a Local File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DownloadVideo": {
      "main": [
        [
          {
            "node": "UploadVideo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FindPage": {
      "main": [
        [
          {
            "node": "Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Data": {
      "main": [
        [
          {
            "node": "IfUseAIAgent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "WaitContinueStep": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Output": {
      "main": [
        [
          {
            "node": "ReadContent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Think",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Think",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Think": {
      "main": [
        [
          {
            "node": "Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "UpdateResult": {
      "main": [
        [
          {
            "node": "WaitContinueStep",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GetAllPending": {
      "main": [
        [
          {
            "node": "UpdateToQueue",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "UpdateToQueue": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "IfTimeExists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "UpdateToPending": {
      "main": [
        [
          {
            "node": "Wait2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait2": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "588a021bb54b760204dc9fed657516230744845e005fe72c0f4b0664fd815974"
  }
}