{
  "name": "02 Daily TikTok trending hashtags digest",
  "nodes": [
    {
      "parameters": {
        "content": "## Daily TikTok trends digest\nEvery morning: new and rising TikTok hashtags in your countries, straight to Discord/Slack/Telegram.\n\n1. Open **Config** and paste your Apify API token (free account: console.apify.com -> Settings -> API & Integrations).\n2. Paste a Discord/Slack webhook URL and/or a Telegram bot token + chat ID (delete the node you don't use).\n3. Click **Test workflow**, then switch it to **Active**.",
        "height": 340,
        "width": 420
      },
      "name": "How to use",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        -400
      ],
      "id": "629d11e9-5ed7-4566-895b-789c379d9b08"
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 8 * * *"
            }
          ]
        }
      },
      "name": "Schedule",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ],
      "id": "e6acf1e1-3b72-437c-a3c3-1064d5dae47b"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "5d1b3cbe-7632-4894-af5b-e66013670d56",
              "name": "apifyToken",
              "value": "YOUR_APIFY_TOKEN",
              "type": "string"
            },
            {
              "id": "37cd877e-41b9-4048-853b-e31703a7eac1",
              "name": "webhookUrl",
              "value": "https://discord.com/api/webhooks/...",
              "type": "string"
            },
            {
              "id": "f006bb2b-9a98-4bb1-a3e9-136f7a4bca9c",
              "name": "telegramBotToken",
              "value": "",
              "type": "string"
            },
            {
              "id": "a3177e13-75fb-4a09-8d5c-16cd3b2b0ae9",
              "name": "telegramChatId",
              "value": "",
              "type": "string"
            },
            {
              "id": "b936765a-8cb8-43c1-9550-4af5a3b9db4a",
              "name": "countries",
              "value": "US, GB, DE, FR, BR",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "name": "Config",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        0
      ],
      "id": "b341ac7c-f7ed-40ff-a4b8-221cbdf562c2"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.apify.com/v2/acts/martin10291~tiktok-trend-alert-bot/run-sync-get-dataset-items",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "token",
              "value": "={{ $('Config').item.json.apifyToken }}"
            },
            {
              "name": "timeout",
              "value": "280"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({countries: $('Config').item.json.countries.split(',').map(s => s.trim()), periods: ['7'], alertOn: 'none'}) }}",
        "options": {
          "timeout": 300000
        }
      },
      "name": "Run Apify scraper",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        440,
        0
      ],
      "id": "07d71f97-5aca-4f47-b262-9c69440639d4"
    },
    {
      "parameters": {
        "jsCode": "const rows = $input.all();\nif (!rows.length) return [];\nconst d = rows.map(i => i.json).filter(r => r.isNew || r.trendDirection === 'rising');\nif (!d.length) return [];\nconst text = 'TikTok trends today:\\n' + d.slice(0, 25).map(r => `${r.trendDirection === 'rising' ? '🚀' : '🔥'} ${r.hashtag} (${r.country}) ${Math.round((r.views||0)/1e6)}M views`).join('\\n');\nreturn [{ json: { text } }];"
      },
      "name": "Format message",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        660,
        0
      ],
      "id": "9d21fca0-16a2-4560-8663-1f161c708fe3"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $('Config').item.json.webhookUrl }}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({content: $json.text, text: $json.text}) }}",
        "options": {}
      },
      "name": "Send to Discord or Slack",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        880,
        0
      ],
      "id": "4b0d2c95-7379-4eac-8dfc-b7ee25f43c90"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.telegram.org/bot{{ $('Config').item.json.telegramBotToken }}/sendMessage",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({chat_id: $('Config').item.json.telegramChatId, text: $json.text, disable_web_page_preview: true}) }}",
        "options": {}
      },
      "name": "Send to Telegram",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        880,
        200
      ],
      "id": "d6cd41ba-8bfb-4c3a-8ba2-63588bfa0178"
    }
  ],
  "connections": {
    "Schedule": {
      "main": [
        [
          {
            "node": "Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Config": {
      "main": [
        [
          {
            "node": "Run Apify scraper",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Apify scraper": {
      "main": [
        [
          {
            "node": "Format message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format message": {
      "main": [
        [
          {
            "node": "Send to Discord or Slack",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send to Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "active": false
}