{
  "name": "Symcio \u00b7 Daily Brand Valuation Broadcast",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 1 * * *"
            }
          ]
        }
      },
      "id": "cron-trigger",
      "name": "Daily 09:00 Taipei (UTC 01:00)",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "url": "https://symcio.tw/api/bci/Symcio",
        "options": {
          "timeout": 15000
        }
      },
      "id": "fetch-bci",
      "name": "Fetch current BCI",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "const b = $json.body ?? $json;\nconst bci = b.total_bci ?? b.bci ?? null;\nconst updated = b.updated_at ?? b.snapshot_date ?? new Date().toISOString().slice(0, 10);\nconst title = `Symcio BCI \u6bcf\u65e5\u66f4\u65b0 \u00b7 ${updated.slice(0, 10)}`;\nconst bodyShort = bci == null\n  ? `BCI \u4eca\u65e5\u5c1a\u672a\u66f4\u65b0\u3002`\n  : `Symcio Brand Capital Index \u4eca\u65e5 ${bci}/100\u3002\u4f9d\u5faa ISO 10668 + TNFD + \u8de8\u56db\u5f15\u64ce AI \u53ef\u898b\u5ea6\u3002`;\nconst bodyMedium = `${bodyShort}\\n\\n\u4e09\u8ef8\u62c6\u89e3\uff1aFinancial\uff08\u5e02\u503c\u52d5\u80fd\uff09\u00b7 Visibility\uff08AI \u5f15\u64ce\u63d0\u53ca\uff09\u00b7 Engagement\uff08\u54c1\u724c\u53c3\u8207\u5ea6\uff09\u3002\u516c\u5f0f\u516c\u958b\u3001\u6b0a\u91cd\u9589\u6e90\u3002`;\n\nreturn { json: {\n  kind: 'daily_brand_valuation',\n  title,\n  body_short: bodyShort,\n  body_medium: bodyMedium,\n  link_path: '/about',\n  tags: ['BCI', '\u54c1\u724c\u4f30\u503c', 'ESG', 'AI\u53ef\u898b\u5ea6'],\n  channels: ['discord', 'linkedin', 'x', 'threads', 'facebook'],\n  campaign: `daily_bci_${updated.slice(0, 10)}`,\n} };"
      },
      "id": "build-payload",
      "name": "Build broadcast payload",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        680,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://symcio.tw/api/publish/broadcast",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $credentials.symcioBroadcast.secret }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyContentType": "json",
        "jsonBody": "={{ JSON.stringify($json) }}",
        "options": {
          "timeout": 30000
        }
      },
      "id": "call-broadcast",
      "name": "Call Symcio broadcast API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        900,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "leftValue": "={{ $json.results.linkedin.ready }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true"
              }
            }
          ],
          "combinator": "and"
        }
      },
      "id": "check-linkedin",
      "name": "LinkedIn ready?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        1120,
        200
      ]
    },
    {
      "parameters": {
        "resource": "post",
        "text": "={{ $('Call Symcio broadcast API').item.json.results.linkedin.text }}",
        "additionalFields": {
          "visibility": "PUBLIC"
        }
      },
      "id": "linkedin-post",
      "name": "Post to LinkedIn",
      "type": "n8n-nodes-base.linkedIn",
      "typeVersion": 1,
      "position": [
        1340,
        200
      ],
      "credentials": {
        "linkedInOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "text": "={{ $('Call Symcio broadcast API').item.json.results.x.text }}"
      },
      "id": "x-post",
      "name": "Post to X",
      "type": "n8n-nodes-base.twitter",
      "typeVersion": 2,
      "position": [
        1340,
        340
      ],
      "credentials": {
        "twitterOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "graphApiVersion": "v21.0",
        "resource": "post",
        "edge": "feed",
        "message": "={{ $('Call Symcio broadcast API').item.json.results.facebook.text }}"
      },
      "id": "facebook-post",
      "name": "Post to Facebook Page",
      "type": "n8n-nodes-base.facebookGraphApi",
      "typeVersion": 1,
      "position": [
        1340,
        480
      ],
      "credentials": {
        "facebookGraphApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Daily 09:00 Taipei (UTC 01:00)": {
      "main": [
        [
          {
            "node": "Fetch current BCI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch current BCI": {
      "main": [
        [
          {
            "node": "Build broadcast payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build broadcast payload": {
      "main": [
        [
          {
            "node": "Call Symcio broadcast API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call Symcio broadcast API": {
      "main": [
        [
          {
            "node": "LinkedIn ready?",
            "type": "main",
            "index": 0
          },
          {
            "node": "Post to X",
            "type": "main",
            "index": 0
          },
          {
            "node": "Post to Facebook Page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "LinkedIn ready?": {
      "main": [
        [
          {
            "node": "Post to LinkedIn",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [
    "symcio",
    "broadcast",
    "daily"
  ]
}