{
  "name": "Đăng bài hàng ngày lên Fanpage - Done",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 9
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -1700,
        -160
      ],
      "id": "f9501f33-0aa1-4fcf-8b04-544e52819726",
      "name": "Schedule Trigger"
    },
    {
      "parameters": {
        "jsCode": "// Truy cập hoặc khởi tạo Static Data\nconst staticData = $getWorkflowStaticData('global');\n\n// Khởi tạo chỉ số hiện tại nếu chưa có\nif (typeof staticData.lastStatus === 'undefined') {\n  staticData.lastStatus = 0;\n}\nconst newStatus = staticData.lastStatus + 1;\nif(newStatus === 30) {\n  staticData.lastStatus = 0;\n} else {\n  staticData.lastStatus = newStatus;\n}\n// Trả về phần tử đã chọn\nreturn [{json:{\n  id:newStatus}}\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -1520,
        -160
      ],
      "id": "64f49251-33a0-4a9c-adf0-9197551b0aa6",
      "name": "Code"
    },
    {
      "parameters": {
        "operation": "search",
        "base": {
          "__rl": true,
          "value": "apppJGImf5hARF6Go",
          "mode": "list",
          "cachedResultName": "n8n airtable",
          "cachedResultUrl": "https://airtable.com/apppJGImf5hARF6Go"
        },
        "table": {
          "__rl": true,
          "value": "tblvmkhA4K4KeUOgz",
          "mode": "list",
          "cachedResultName": "Table 1",
          "cachedResultUrl": "https://airtable.com/apppJGImf5hARF6Go/tblvmkhA4K4KeUOgz"
        },
        "filterByFormula": "={ID} = {{ $json.id }}",
        "options": {}
      },
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 2.1,
      "position": [
        -1360,
        -160
      ],
      "id": "3c74ec23-3e5b-4cb8-b470-5fa772818200",
      "name": "Airtable",
      "credentials": {
        "airtableTokenApi": {
          "id": "voS2zV2GKOwnG2e9",
          "name": "Airtable Personal Access Token account"
        }
      }
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o",
          "mode": "list",
          "cachedResultName": "GPT-4O"
        },
        "messages": {
          "values": [
            {
              "content": "=Bạn là 1 Blogger chuyên về lĩnh vực tên miền. Bạn viết nội dung chia sẻ kiến thức dành cho người mới tìm hiểu về tên miền và đăng tải trên 1 trang Fanpages Facebook. Bạn hãy viết cho tôi 1 Status Facebook ngắn gọn chia sẻ về chủ đề:  {{ $json['Chủ đề'] }} bao gồm các nội dung chính sau: {{ $json['Nội dung chính'] }}\nOutput Format:\n- Trả kết quả bằng tiếng việt\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- Trả kết quả ở dạng JSON:\n  title: 1 câu tiêu đề thu hút người đọc\n  content: 1 đoạn status nội dung chính, văn phong thân thiện dễ hiểu cho người mới\n  image_prompt: 1 câu lệnh prompt để tạo ra ảnh dựa theo nội dung chính, không yêu cầu tạo ra chữ, chỉ cần là ảnh nổi bật nội dung chính"
            }
          ]
        },
        "jsonOutput": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        -1180,
        -160
      ],
      "id": "d0164cb1-442f-4cdc-b436-28dce22bd586",
      "name": "OpenAI",
      "credentials": {
        "openAiApi": {
          "id": "aaSLeVmfy4Eq64Uq",
          "name": "OpenAi _API"
        }
      }
    },
    {
      "parameters": {
        "resource": "image",
        "prompt": "={{ $json.message.content.image_prompt }}",
        "options": {
          "returnImageUrls": true
        }
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        -820,
        -160
      ],
      "id": "b42f856d-25d2-4279-8f86-487a888f1e37",
      "name": "OpenAI1",
      "credentials": {
        "openAiApi": {
          "id": "aaSLeVmfy4Eq64Uq",
          "name": "OpenAi _API"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.templated.io/v1/render",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "Bearer 9110deba-d0d5-49cd-887d-4231f923c684"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n    \"template\": \"6d48215d-53e2-41bf-bb5e-d7ab2f30c390\",\n    \"layers\": {\n      \"title\": {\n        \"text\": \"{{ $('OpenAI').item.json.message.content.title }}\"\n      },\n      \"image\": {\n        \"image_url\": \"{{ $json.url }}\"\n      }\n    },\n\"async\":\"false\"\n  }",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -600,
        -160
      ],
      "id": "a8ff9dd9-2596-40c9-b527-dcaf23a41f9b",
      "name": "HTTP Request"
    },
    {
      "parameters": {
        "httpRequestMethod": "POST",
        "graphApiVersion": "v20.0",
        "node": "me",
        "edge": "photos",
        "options": {
          "queryParameters": {
            "parameter": [
              {
                "name": "message",
                "value": "={{ $('OpenAI').item.json.message.content.content }}"
              },
              {
                "name": "url",
                "value": "={{ $json.render_url }}"
              }
            ]
          }
        }
      },
      "type": "n8n-nodes-base.facebookGraphApi",
      "typeVersion": 1,
      "position": [
        -380,
        -160
      ],
      "id": "91c9350b-be23-49bc-beff-69b273330f93",
      "name": "Facebook Graph API",
      "credentials": {
        "facebookGraphApi": {
          "id": "qTTJInBVEUkjvP4c",
          "name": "Facebook Graph account"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Airtable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI": {
      "main": [
        [
          {
            "node": "OpenAI1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI1": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Facebook Graph API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "ae466e03-cbb1-4766-8a80-1915ad01aa57",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "fc570fd857b7b5d0d7faa603bc852c94fbebf88ded999dbdfb27670741e5660b"
  },
  "id": "fdz1zGcez7IjeSxo",
  "tags": []
}