{
  "name": "tik.tools - daily recruit list -> Telegram",
  "nodes": [
    {
      "parameters": {
        "content": "## Daily recruit list -> Telegram\n\nNeeds a tik.tools **Agency Global** plan. Lower plans get a 403 from the recruit feed.\n\n**1. Credentials**\n- **tik.tools API key**: a Header Auth credential. Name: x-api-key, Value: YOUR_API_KEY.\n- **Telegram bot**: Telegram API credential with your bot token from @BotFather.\n\n**2. Settings**: set region (for example UK+, US+, DE, MENA), min_usd_7d (skip creators below this estimated 7-day earning) and max_rows.\n\n**3. Telegram chat**: replace YOUR_TELEGRAM_CHAT_ID in *Send to Telegram*.\n\nRuns every day at 08:00 (your n8n timezone) and lists the creators first seen since yesterday in that region (up to 1,000 per run), highest estimated 7-day earnings first. Creators your team marked ineligible with the Backstage checker are left out.",
        "height": 560,
        "width": 520
      },
      "id": "e4a05cda-9ab6-4021-ae35-ca3524e7c08e",
      "name": "Setup",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -460,
        -420
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "days",
              "triggerAtHour": 8
            }
          ]
        }
      },
      "id": "b005e8bd-22e9-42c2-a7c9-279e5d019e2d",
      "name": "Every day at 08:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        120,
        0
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "5191d653-849c-46ed-a818-6168545e95b3",
              "name": "region",
              "value": "UK+",
              "type": "string"
            },
            {
              "id": "9247ef1e-eedb-43a2-acea-d1c02a0710f7",
              "name": "min_usd_7d",
              "value": 50,
              "type": "number"
            },
            {
              "id": "e60bb9b9-c12f-40f0-ac40-d4106efabc6c",
              "name": "max_rows",
              "value": 25,
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "id": "13c1c441-ac20-475a-a2b6-a0396ee4003d",
      "name": "Settings",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        340,
        0
      ]
    },
    {
      "parameters": {
        "url": "https://api.tik.tools/webcast/creator_digest",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "region",
              "value": "={{ $json.region }}"
            },
            {
              "name": "since",
              "value": "={{ $now.minus({ days: 1 }).toFormat('yyyy-MM-dd') }}"
            },
            {
              "name": "limit",
              "value": "100"
            }
          ]
        },
        "options": {
          "pagination": {
            "pagination": {
              "paginationMode": "updateAParameterInEachRequest",
              "parameters": {
                "parameters": [
                  {
                    "type": "qs",
                    "name": "page",
                    "value": "={{ $pageCount + 1 }}"
                  }
                ]
              },
              "paginationCompleteWhen": "other",
              "completeExpression": "={{ $response.body.page >= $response.body.total_pages }}",
              "limitPagesFetched": true,
              "maxRequests": 10,
              "requestInterval": 250
            }
          }
        }
      },
      "id": "2459c8c1-14fc-4b98-a929-ae98c9937649",
      "name": "Get new creators",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        560,
        0
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "REPLACE_WITH_YOUR_CREDENTIAL",
          "name": "tik.tools API key"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Turns one page of the recruit feed into a Telegram message, kept under\n// Telegram's 4096 character limit.\nconst settings = $('Settings').first().json;\n// The request node pages through the feed, so each input item is one page.\nconst pages = $input.all().map((i) => i.json);\nconst res = pages[0] || {};\nconst minUsd = Number(settings.min_usd_7d) || 0;\nconst maxRows = Math.max(1, Number(settings.max_rows) || 25);\nconst esc = (s) => String(s ?? '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');\nconst money = (n) => '$' + Math.round(Number(n) || 0).toLocaleString('en-US');\n\nconst rows = pages.flatMap((p) => p.results || [])\n  .filter((c) => c.backstage !== 'ineligible' && (Number(c.usd_7d) || 0) >= minUsd)\n  .sort((a, b) => (Number(b.usd_7d) || 0) - (Number(a.usd_7d) || 0))\n  .slice(0, maxRows);\n\nconst region = res.region || settings.region;\nconst head = [\n  `<b>New creators to recruit - ${esc(region)}</b>`,\n  `First seen since ${esc(res.since || '')}: ${Number(res.total) || 0} new, ${rows.length} shown (7-day estimate ${money(minUsd)} or more).`,\n  '',\n];\nif (res.region_note) head.splice(1, 0, `<i>${esc(res.region_note)}</i>`);\n\nconst verdict = { eligible: 'eligible', premium_only: 'premium slot', checked: 'checked', unchecked: 'not checked' };\nconst lines = rows.map((c, i) => {\n  const u = String(c.username || '');\n  const name = c.display_name && c.display_name !== u ? ` (${esc(c.display_name)})` : '';\n  return `${i + 1}. <a href=\"https://www.tiktok.com/@${encodeURIComponent(u)}\">@${esc(u)}</a>${name} - ${money(c.usd_7d)} 7d - ${verdict[c.backstage] || esc(c.backstage || 'not checked')}`;\n});\nif (!rows.length) lines.push('Nothing new above your threshold today.');\n\nlet text = head.join('\\n');\nfor (const line of lines) {\n  if (text.length + line.length + 1 > 3900) { text += '\\n...'; break; }\n  text += '\\n' + line;\n}\nreturn [{ json: { text, shown: rows.length, total: Number(res.total) || 0 } }];\n"
      },
      "id": "7e82e758-c139-4931-ad51-cb32c37dc2e8",
      "name": "Build recruit message",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        780,
        0
      ]
    },
    {
      "parameters": {
        "resource": "message",
        "operation": "sendMessage",
        "chatId": "YOUR_TELEGRAM_CHAT_ID",
        "text": "={{ $json.text }}",
        "additionalFields": {
          "appendAttribution": false,
          "parse_mode": "HTML",
          "disable_web_page_preview": true
        }
      },
      "id": "de5aac3b-3e79-4e1f-ad83-717382c9cf2a",
      "name": "Send to Telegram",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1000,
        0
      ],
      "credentials": {
        "telegramApi": {
          "id": "REPLACE_WITH_YOUR_CREDENTIAL",
          "name": "Telegram bot"
        }
      }
    }
  ],
  "connections": {
    "Every day at 08:00": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Settings": {
      "main": [
        [
          {
            "node": "Get new creators",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get new creators": {
      "main": [
        [
          {
            "node": "Build recruit message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build recruit message": {
      "main": [
        [
          {
            "node": "Send to Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}
