{
  "schemaVersion": "1.0",
  "item": {
    "slug": "tiktok-trend-radar",
    "name": "Automated TikTok & Instagram Trend Radar",
    "source": "tencent",
    "type": "skill",
    "category": "开发工具",
    "sourceUrl": "https://clawhub.ai/g4dr/tiktok-trend-radar",
    "canonicalUrl": "https://clawhub.ai/g4dr/tiktok-trend-radar",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/tiktok-trend-radar",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=tiktok-trend-radar",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "SKILL.md"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
        },
        {
          "label": "Upgrade existing",
          "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-23T16:43:11.935Z",
      "expiresAt": "2026-04-30T16:43:11.935Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=4claw-imageboard",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=4claw-imageboard",
        "contentDisposition": "attachment; filename=\"4claw-imageboard-1.0.1.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/tiktok-trend-radar"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/tiktok-trend-radar",
    "agentPageUrl": "https://openagent3.xyz/skills/tiktok-trend-radar/agent",
    "manifestUrl": "https://openagent3.xyz/skills/tiktok-trend-radar/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/tiktok-trend-radar/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
      },
      {
        "label": "Upgrade existing",
        "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "Overview",
        "body": "This skill builds a fully automated trend monitoring pipeline that:\n\nScrapes TikTok and Instagram in real-time using Apify\nSends trend data into Claude (via OpenClaw) for AI analysis\nAutomatically generates content ideas, video scripts, and hashtag explosion alerts\nProduces ready-to-publish short videos via InVideo AI\n\nThe result: you know what's trending before everyone else — and you already have the content ready.\n\n🔗 Apify: https://www.apify.com/?fpr=dx06p\n🔗 InVideo: https://invideo.sjv.io/TBB"
      },
      {
        "title": "What This Skill Does",
        "body": "Scrape TikTok hashtags, sounds, and viral posts every few hours via Apify\nScrape Instagram Reels and trending hashtags in parallel\nDetect hashtag explosions — sudden spikes in post volume or engagement\nSend raw trend data to Claude for instant AI-powered analysis\nAuto-generate content ideas, angles, and hooks based on detected trends\nWrite complete video scripts tailored to the trending topic\nProduce the video automatically via InVideo AI\nAlert via webhook, Slack, or email when a trend is breaking"
      },
      {
        "title": "Architecture Overview",
        "body": "┌─────────────────────────────────────────────────────────────┐\n│                    TREND RADAR PIPELINE                     │\n│                                                             │\n│  ┌──────────┐    ┌──────────┐    ┌──────────────────────┐  │\n│  │  Apify   │───▶│  Trend   │───▶│   Claude / OpenClaw  │  │\n│  │ Scraper  │    │ Detector │    │   AI Analysis Engine │  │\n│  │TikTok +  │    │(spike    │    │                      │  │\n│  │Instagram │    │detection)│    │ • Content ideas      │  │\n│  └──────────┘    └──────────┘    │ • Script generation  │  │\n│                                  │ • Hashtag insights   │  │\n│                                  └──────────┬───────────┘  │\n│                                             │               │\n│                         ┌───────────────────▼────────────┐ │\n│                         │       InVideo AI               │ │\n│                         │   Auto Video Production        │ │\n│                         │   (script → MP4 in minutes)    │ │\n│                         └───────────────────┬────────────┘ │\n│                                             │               │\n│                         ┌───────────────────▼────────────┐ │\n│                         │         ALERTS & OUTPUT        │ │\n│                         │  Slack / Email / Webhook / CMS │ │\n│                         └────────────────────────────────┘ │\n└─────────────────────────────────────────────────────────────┘"
      },
      {
        "title": "Apify",
        "body": "Sign up at https://www.apify.com/?fpr=dx06p\nGo to Settings → Integrations\nCopy your token:\nexport APIFY_TOKEN=apify_api_xxxxxxxxxxxxxxxx"
      },
      {
        "title": "InVideo",
        "body": "Sign up at https://invideo.sjv.io/TBB\nGo to Settings → API / Developer Settings\nCopy your key:\nexport INVIDEO_API_KEY=iv_api_xxxxxxxxxxxxxxxx"
      },
      {
        "title": "OpenClaw / Claude API",
        "body": "Get your Claude API key from your OpenClaw or Anthropic account\nStore it:\nexport CLAUDE_API_KEY=sk-ant-xxxxxxxxxxxxxxxx"
      },
      {
        "title": "Step 2 — Install Dependencies",
        "body": "npm install apify-client axios node-cron"
      },
      {
        "title": "Module 1 — Scrape TikTok & Instagram Trends",
        "body": "import ApifyClient from 'apify-client';\n\nconst apify = new ApifyClient({ token: process.env.APIFY_TOKEN });\n\n// Define hashtags to monitor\nconst WATCHED_HASHTAGS = [\n  \"viral\", \"trending\", \"fyp\", \"lifehack\",\n  \"productivity\", \"ai\", \"money\", \"fitness\"\n];\n\nasync function scrapeTikTokTrends() {\n  const run = await apify.actor(\"apify/tiktok-hashtag-scraper\").call({\n    hashtags: WATCHED_HASHTAGS,\n    resultsPerPage: 50,\n    shouldDownloadVideos: false\n  });\n  const { items } = await run.dataset().getData();\n  return items.map(item => ({\n    platform: \"tiktok\",\n    hashtag: item.hashtag,\n    postCount: item.viewCount,\n    likes: item.diggCount,\n    shares: item.shareCount,\n    comments: item.commentCount,\n    description: item.text,\n    author: item.authorMeta?.name,\n    createdAt: item.createTime,\n    url: item.webVideoUrl\n  }));\n}\n\nasync function scrapeInstagramTrends() {\n  const run = await apify.actor(\"apify/instagram-hashtag-scraper\").call({\n    hashtags: WATCHED_HASHTAGS,\n    resultsLimit: 50\n  });\n  const { items } = await run.dataset().getData();\n  return items.map(item => ({\n    platform: \"instagram\",\n    hashtag: item.hashtags?.[0] || \"unknown\",\n    likes: item.likesCount,\n    comments: item.commentsCount,\n    description: item.caption,\n    author: item.ownerUsername,\n    createdAt: item.timestamp,\n    url: item.url\n  }));\n}\n\nasync function scrapeAllPlatforms() {\n  const [tiktok, instagram] = await Promise.all([\n    scrapeTikTokTrends(),\n    scrapeInstagramTrends()\n  ]);\n  return [...tiktok, ...instagram];\n}"
      },
      {
        "title": "Module 2 — Hashtag Explosion Detector",
        "body": "// In-memory baseline (use a database like Redis for production)\nconst baseline = {};\n\nfunction detectExplosions(currentData) {\n  const alerts = [];\n\n  // Group by hashtag and calculate engagement scores\n  const grouped = currentData.reduce((acc, post) => {\n    if (!acc[post.hashtag]) acc[post.hashtag] = { posts: 0, totalLikes: 0, platforms: new Set() };\n    acc[post.hashtag].posts++;\n    acc[post.hashtag].totalLikes += post.likes || 0;\n    acc[post.hashtag].platforms.add(post.platform);\n    return acc;\n  }, {});\n\n  for (const [hashtag, stats] of Object.entries(grouped)) {\n    const prev = baseline[hashtag] || { posts: 0, totalLikes: 0 };\n    const growthRate = prev.posts > 0\n      ? ((stats.posts - prev.posts) / prev.posts) * 100\n      : 100;\n\n    // Alert if posts grew more than 40% since last check\n    if (growthRate > 40) {\n      alerts.push({\n        hashtag,\n        growthRate: Math.round(growthRate),\n        currentPosts: stats.posts,\n        previousPosts: prev.posts,\n        totalLikes: stats.totalLikes,\n        platforms: [...stats.platforms],\n        detectedAt: new Date().toISOString(),\n        severity: growthRate > 100 ? \"EXPLOSIVE\" : \"RISING\"\n      });\n    }\n\n    // Update baseline\n    baseline[hashtag] = stats;\n  }\n\n  return alerts.sort((a, b) => b.growthRate - a.growthRate);\n}"
      },
      {
        "title": "Module 3 — AI Analysis with Claude (OpenClaw)",
        "body": "import axios from 'axios';\n\nasync function analyzeWithClaude(trendData, explosionAlerts) {\n  const prompt = `\nYou are a viral content strategist. Analyze these trending social media data and provide actionable output.\n\n## TRENDING DATA (last scrape)\n${JSON.stringify(trendData.slice(0, 20), null, 2)}\n\n## EXPLOSION ALERTS\n${JSON.stringify(explosionAlerts, null, 2)}\n\nRespond ONLY in this exact JSON format, no preamble:\n{\n  \"topTrends\": [\n    {\n      \"hashtag\": \"#example\",\n      \"whyItsTrending\": \"brief explanation\",\n      \"targetAudience\": \"who this appeals to\",\n      \"contentAngle\": \"unique angle to take on this trend\"\n    }\n  ],\n  \"contentIdeas\": [\n    {\n      \"title\": \"video title idea\",\n      \"hashtag\": \"#hashtag\",\n      \"hook\": \"first 3 seconds script\",\n      \"format\": \"tutorial | reaction | storytime | list | pov\",\n      \"estimatedViralPotential\": \"high | medium | low\",\n      \"reasoning\": \"why this would perform well\"\n    }\n  ],\n  \"urgentAlerts\": [\n    {\n      \"hashtag\": \"#hashtag\",\n      \"message\": \"alert message\",\n      \"recommendedAction\": \"what to do right now\",\n      \"windowOfOpportunity\": \"estimated hours before trend peaks\"\n    }\n  ],\n  \"bestTimeToPost\": \"recommendation based on trend timing\"\n}\n`;\n\n  const response = await axios.post(\n    'https://api.anthropic.com/v1/messages',\n    {\n      model: \"claude-opus-4-5\",\n      max_tokens: 2000,\n      messages: [{ role: \"user\", content: prompt }]\n    },\n    {\n      headers: {\n        'x-api-key': process.env.CLAUDE_API_KEY,\n        'anthropic-version': '2023-06-01',\n        'Content-Type': 'application/json'\n      }\n    }\n  );\n\n  const raw = response.data.content[0].text;\n  const clean = raw.replace(/```json|```/g, '').trim();\n  return JSON.parse(clean);\n}"
      },
      {
        "title": "Module 4 — Auto Script Generation",
        "body": "async function generateVideoScript(contentIdea, trendContext) {\n  const prompt = `\nWrite a complete short-form video script for this content idea.\n\nCONTENT IDEA: ${JSON.stringify(contentIdea)}\nTREND CONTEXT: ${trendContext}\n\nRespond ONLY in this JSON format:\n{\n  \"title\": \"video title\",\n  \"duration\": \"estimated seconds\",\n  \"hook\": \"opening line — first 3 seconds\",\n  \"fullScript\": \"complete word-for-word script\",\n  \"captions\": [\"caption 1\", \"caption 2\", \"...\"],\n  \"hashtags\": [\"#tag1\", \"#tag2\", \"#tag3\"],\n  \"cta\": \"call to action at the end\",\n  \"thumbnailIdea\": \"description of ideal thumbnail\"\n}\n\nRules:\n- Hook must create curiosity or shock in under 4 seconds\n- Script must be 120–180 words for a 30–45 second video\n- Conversational, energetic tone\n- End with a strong CTA (follow, comment, share)\n`;\n\n  const response = await axios.post(\n    'https://api.anthropic.com/v1/messages',\n    {\n      model: \"claude-opus-4-5\",\n      max_tokens: 1000,\n      messages: [{ role: \"user\", content: prompt }]\n    },\n    {\n      headers: {\n        'x-api-key': process.env.CLAUDE_API_KEY,\n        'anthropic-version': '2023-06-01',\n        'Content-Type': 'application/json'\n      }\n    }\n  );\n\n  const raw = response.data.content[0].text;\n  return JSON.parse(raw.replace(/```json|```/g, '').trim());\n}"
      },
      {
        "title": "Module 5 — Auto Video Production with InVideo",
        "body": "const invideo = axios.create({\n  baseURL: 'https://api.invideo.io/v1',\n  headers: { Authorization: `Bearer ${process.env.INVIDEO_API_KEY}` }\n});\n\nasync function produceVideo(script) {\n  // Start generation\n  const { data } = await invideo.post('/videos/generate', {\n    script: script.fullScript,\n    format: \"9:16\",\n    duration: \"short\",\n    style: \"dynamic\",\n    voiceover: { enabled: true, voice: \"en-US-female-1\", speed: 1.1 },\n    captions: { enabled: true, style: \"bold-bottom\", highlight: true },\n    music: { enabled: true, mood: \"upbeat\", volume: 0.25 },\n    cta: { enabled: true, text: script.cta, position: \"bottom\" }\n  });\n\n  const videoId = data.videoId;\n\n  // Poll until ready\n  let exportUrl = null;\n  while (!exportUrl) {\n    await new Promise(r => setTimeout(r, 6000));\n    const status = await invideo.get(`/videos/${videoId}/status`);\n    if (status.data.state === \"completed\") exportUrl = status.data.exportUrl;\n    if (status.data.state === \"failed\") throw new Error(\"Video generation failed\");\n    console.log(`  Video progress: ${status.data.progress}%`);\n  }\n\n  return { videoId, exportUrl, script };\n}"
      },
      {
        "title": "Module 6 — Alerts & Notifications",
        "body": "async function sendAlert(alert, analysis) {\n  const payload = {\n    text: `🚨 *TREND ALERT: ${alert.hashtag}* — ${alert.severity}`,\n    blocks: [\n      {\n        type: \"section\",\n        text: {\n          type: \"mrkdwn\",\n          text: `*📈 ${alert.hashtag}* grew *${alert.growthRate}%* in the last check\\n` +\n                `Platforms: ${alert.platforms.join(', ')}\\n` +\n                `Window: ${analysis.urgentAlerts?.[0]?.windowOfOpportunity || 'Act now'}`\n        }\n      },\n      {\n        type: \"section\",\n        text: {\n          type: \"mrkdwn\",\n          text: `*💡 Recommended action:*\\n${analysis.urgentAlerts?.[0]?.recommendedAction || 'Create content immediately'}`\n        }\n      }\n    ]\n  };\n\n  // Send to Slack webhook\n  if (process.env.SLACK_WEBHOOK_URL) {\n    await axios.post(process.env.SLACK_WEBHOOK_URL, payload);\n  }\n\n  // Or send to any custom webhook\n  if (process.env.ALERT_WEBHOOK_URL) {\n    await axios.post(process.env.ALERT_WEBHOOK_URL, {\n      type: \"trend_explosion\",\n      alert,\n      analysis,\n      timestamp: new Date().toISOString()\n    });\n  }\n}"
      },
      {
        "title": "Main Orchestrator — Full Pipeline",
        "body": "import cron from 'node-cron';\n\nasync function runTrendRadar() {\n  console.log(`\\n🔍 Trend Radar scan started at ${new Date().toISOString()}`);\n\n  try {\n    // 1 — Scrape all platforms\n    console.log(\"  [1/5] Scraping TikTok & Instagram...\");\n    const trendData = await scrapeAllPlatforms();\n    console.log(`  ✅ ${trendData.length} posts collected`);\n\n    // 2 — Detect explosions\n    console.log(\"  [2/5] Detecting explosions...\");\n    const alerts = detectExplosions(trendData);\n    console.log(`  ✅ ${alerts.length} alerts detected`);\n\n    // 3 — AI analysis\n    console.log(\"  [3/5] Analyzing with Claude...\");\n    const analysis = await analyzeWithClaude(trendData, alerts);\n    console.log(`  ✅ ${analysis.contentIdeas?.length} content ideas generated`);\n\n    // 4 — Auto-generate scripts for top 2 ideas\n    console.log(\"  [4/5] Generating video scripts...\");\n    const topIdeas = analysis.contentIdeas?.slice(0, 2) || [];\n    const scripts = await Promise.all(\n      topIdeas.map(idea => generateVideoScript(idea, JSON.stringify(analysis.topTrends)))\n    );\n    console.log(`  ✅ ${scripts.length} scripts written`);\n\n    // 5 — Produce videos\n    console.log(\"  [5/5] Producing videos with InVideo...\");\n    const videos = await Promise.all(scripts.map(produceVideo));\n    console.log(`  ✅ ${videos.length} videos ready`);\n\n    // 6 — Send alerts\n    if (alerts.length > 0) {\n      await sendAlert(alerts[0], analysis);\n      console.log(\"  ✅ Alerts sent\");\n    }\n\n    // Final report\n    return {\n      scannedAt: new Date().toISOString(),\n      postsAnalyzed: trendData.length,\n      explosionAlerts: alerts,\n      contentIdeas: analysis.contentIdeas,\n      videos: videos.map(v => ({ title: v.script.title, url: v.exportUrl })),\n      bestTimeToPost: analysis.bestTimeToPost\n    };\n\n  } catch (err) {\n    console.error(\"Radar error:\", err.message);\n    throw err;\n  }\n}\n\n// Schedule: run every 4 hours automatically\ncron.schedule('0 */4 * * *', () => {\n  runTrendRadar().then(report => {\n    console.log(\"\\n📊 RADAR REPORT:\", JSON.stringify(report, null, 2));\n  });\n});\n\n// Also run immediately on startup\nrunTrendRadar();"
      },
      {
        "title": "Environment Variables",
        "body": "# .env\nAPIFY_TOKEN=apify_api_xxxxxxxxxxxxxxxx\nINVIDEO_API_KEY=iv_api_xxxxxxxxxxxxxxxx\nCLAUDE_API_KEY=sk-ant-xxxxxxxxxxxxxxxx\n\n# Optional alerts\nSLACK_WEBHOOK_URL=https://hooks.slack.com/services/xxx/xxx/xxx\nALERT_WEBHOOK_URL=https://your-app.com/webhooks/trends"
      },
      {
        "title": "Normalized Radar Report Schema",
        "body": "{\n  \"scannedAt\": \"2025-02-25T10:00:00Z\",\n  \"postsAnalyzed\": 400,\n  \"explosionAlerts\": [\n    {\n      \"hashtag\": \"#aitools\",\n      \"severity\": \"EXPLOSIVE\",\n      \"growthRate\": 187,\n      \"platforms\": [\"tiktok\", \"instagram\"],\n      \"windowOfOpportunity\": \"4–8 hours\"\n    }\n  ],\n  \"contentIdeas\": [\n    {\n      \"title\": \"5 AI tools that replaced my entire team\",\n      \"hashtag\": \"#aitools\",\n      \"hook\": \"I fired my team. Here's what I replaced them with.\",\n      \"format\": \"list\",\n      \"estimatedViralPotential\": \"high\"\n    }\n  ],\n  \"videos\": [\n    {\n      \"title\": \"5 AI tools that replaced my entire team\",\n      \"url\": \"https://cdn.invideo.io/exports/iv_xxx.mp4\"\n    }\n  ],\n  \"bestTimeToPost\": \"Post within the next 3 hours while the trend is rising\"\n}"
      },
      {
        "title": "Best Practices",
        "body": "Run the radar every 2–4 hours — trends peak fast and fade within 24–48h\nMonitor 8–15 hashtags max per run to stay within Apify free tier\nAlways produce content within the rising phase — never wait for the peak\nUse node-cron for local scheduling or Apify Schedules for cloud automation\nStore baseline data in Redis or a database for accurate spike detection in production\nPipe the video URLs directly into your social media scheduler (Buffer, Later, etc.)"
      },
      {
        "title": "Requirements",
        "body": "Apify account → https://www.apify.com/?fpr=dx06p\nInVideo account → https://invideo.sjv.io/TBB\nClaude / OpenClaw API key\nNode.js 18+\nOptional: Slack workspace for real-time alerts\nOptional: Social media scheduler (Buffer, Later) for auto-publishing"
      }
    ],
    "body": "Automated TikTok & Instagram Trend Radar Skill\nOverview\n\nThis skill builds a fully automated trend monitoring pipeline that:\n\nScrapes TikTok and Instagram in real-time using Apify\nSends trend data into Claude (via OpenClaw) for AI analysis\nAutomatically generates content ideas, video scripts, and hashtag explosion alerts\nProduces ready-to-publish short videos via InVideo AI\n\nThe result: you know what's trending before everyone else — and you already have the content ready.\n\n🔗 Apify: https://www.apify.com/?fpr=dx06p 🔗 InVideo: https://invideo.sjv.io/TBB\n\nWhat This Skill Does\nScrape TikTok hashtags, sounds, and viral posts every few hours via Apify\nScrape Instagram Reels and trending hashtags in parallel\nDetect hashtag explosions — sudden spikes in post volume or engagement\nSend raw trend data to Claude for instant AI-powered analysis\nAuto-generate content ideas, angles, and hooks based on detected trends\nWrite complete video scripts tailored to the trending topic\nProduce the video automatically via InVideo AI\nAlert via webhook, Slack, or email when a trend is breaking\nArchitecture Overview\n┌─────────────────────────────────────────────────────────────┐\n│                    TREND RADAR PIPELINE                     │\n│                                                             │\n│  ┌──────────┐    ┌──────────┐    ┌──────────────────────┐  │\n│  │  Apify   │───▶│  Trend   │───▶│   Claude / OpenClaw  │  │\n│  │ Scraper  │    │ Detector │    │   AI Analysis Engine │  │\n│  │TikTok +  │    │(spike    │    │                      │  │\n│  │Instagram │    │detection)│    │ • Content ideas      │  │\n│  └──────────┘    └──────────┘    │ • Script generation  │  │\n│                                  │ • Hashtag insights   │  │\n│                                  └──────────┬───────────┘  │\n│                                             │               │\n│                         ┌───────────────────▼────────────┐ │\n│                         │       InVideo AI               │ │\n│                         │   Auto Video Production        │ │\n│                         │   (script → MP4 in minutes)    │ │\n│                         └───────────────────┬────────────┘ │\n│                                             │               │\n│                         ┌───────────────────▼────────────┐ │\n│                         │         ALERTS & OUTPUT        │ │\n│                         │  Slack / Email / Webhook / CMS │ │\n│                         └────────────────────────────────┘ │\n└─────────────────────────────────────────────────────────────┘\n\nStep 1 — Get Your API Keys\nApify\nSign up at https://www.apify.com/?fpr=dx06p\nGo to Settings → Integrations\nCopy your token:\nexport APIFY_TOKEN=apify_api_xxxxxxxxxxxxxxxx\n\nInVideo\nSign up at https://invideo.sjv.io/TBB\nGo to Settings → API / Developer Settings\nCopy your key:\nexport INVIDEO_API_KEY=iv_api_xxxxxxxxxxxxxxxx\n\nOpenClaw / Claude API\nGet your Claude API key from your OpenClaw or Anthropic account\nStore it:\nexport CLAUDE_API_KEY=sk-ant-xxxxxxxxxxxxxxxx\n\nStep 2 — Install Dependencies\nnpm install apify-client axios node-cron\n\nFull Pipeline Implementation\nModule 1 — Scrape TikTok & Instagram Trends\nimport ApifyClient from 'apify-client';\n\nconst apify = new ApifyClient({ token: process.env.APIFY_TOKEN });\n\n// Define hashtags to monitor\nconst WATCHED_HASHTAGS = [\n  \"viral\", \"trending\", \"fyp\", \"lifehack\",\n  \"productivity\", \"ai\", \"money\", \"fitness\"\n];\n\nasync function scrapeTikTokTrends() {\n  const run = await apify.actor(\"apify/tiktok-hashtag-scraper\").call({\n    hashtags: WATCHED_HASHTAGS,\n    resultsPerPage: 50,\n    shouldDownloadVideos: false\n  });\n  const { items } = await run.dataset().getData();\n  return items.map(item => ({\n    platform: \"tiktok\",\n    hashtag: item.hashtag,\n    postCount: item.viewCount,\n    likes: item.diggCount,\n    shares: item.shareCount,\n    comments: item.commentCount,\n    description: item.text,\n    author: item.authorMeta?.name,\n    createdAt: item.createTime,\n    url: item.webVideoUrl\n  }));\n}\n\nasync function scrapeInstagramTrends() {\n  const run = await apify.actor(\"apify/instagram-hashtag-scraper\").call({\n    hashtags: WATCHED_HASHTAGS,\n    resultsLimit: 50\n  });\n  const { items } = await run.dataset().getData();\n  return items.map(item => ({\n    platform: \"instagram\",\n    hashtag: item.hashtags?.[0] || \"unknown\",\n    likes: item.likesCount,\n    comments: item.commentsCount,\n    description: item.caption,\n    author: item.ownerUsername,\n    createdAt: item.timestamp,\n    url: item.url\n  }));\n}\n\nasync function scrapeAllPlatforms() {\n  const [tiktok, instagram] = await Promise.all([\n    scrapeTikTokTrends(),\n    scrapeInstagramTrends()\n  ]);\n  return [...tiktok, ...instagram];\n}\n\nModule 2 — Hashtag Explosion Detector\n// In-memory baseline (use a database like Redis for production)\nconst baseline = {};\n\nfunction detectExplosions(currentData) {\n  const alerts = [];\n\n  // Group by hashtag and calculate engagement scores\n  const grouped = currentData.reduce((acc, post) => {\n    if (!acc[post.hashtag]) acc[post.hashtag] = { posts: 0, totalLikes: 0, platforms: new Set() };\n    acc[post.hashtag].posts++;\n    acc[post.hashtag].totalLikes += post.likes || 0;\n    acc[post.hashtag].platforms.add(post.platform);\n    return acc;\n  }, {});\n\n  for (const [hashtag, stats] of Object.entries(grouped)) {\n    const prev = baseline[hashtag] || { posts: 0, totalLikes: 0 };\n    const growthRate = prev.posts > 0\n      ? ((stats.posts - prev.posts) / prev.posts) * 100\n      : 100;\n\n    // Alert if posts grew more than 40% since last check\n    if (growthRate > 40) {\n      alerts.push({\n        hashtag,\n        growthRate: Math.round(growthRate),\n        currentPosts: stats.posts,\n        previousPosts: prev.posts,\n        totalLikes: stats.totalLikes,\n        platforms: [...stats.platforms],\n        detectedAt: new Date().toISOString(),\n        severity: growthRate > 100 ? \"EXPLOSIVE\" : \"RISING\"\n      });\n    }\n\n    // Update baseline\n    baseline[hashtag] = stats;\n  }\n\n  return alerts.sort((a, b) => b.growthRate - a.growthRate);\n}\n\nModule 3 — AI Analysis with Claude (OpenClaw)\nimport axios from 'axios';\n\nasync function analyzeWithClaude(trendData, explosionAlerts) {\n  const prompt = `\nYou are a viral content strategist. Analyze these trending social media data and provide actionable output.\n\n## TRENDING DATA (last scrape)\n${JSON.stringify(trendData.slice(0, 20), null, 2)}\n\n## EXPLOSION ALERTS\n${JSON.stringify(explosionAlerts, null, 2)}\n\nRespond ONLY in this exact JSON format, no preamble:\n{\n  \"topTrends\": [\n    {\n      \"hashtag\": \"#example\",\n      \"whyItsTrending\": \"brief explanation\",\n      \"targetAudience\": \"who this appeals to\",\n      \"contentAngle\": \"unique angle to take on this trend\"\n    }\n  ],\n  \"contentIdeas\": [\n    {\n      \"title\": \"video title idea\",\n      \"hashtag\": \"#hashtag\",\n      \"hook\": \"first 3 seconds script\",\n      \"format\": \"tutorial | reaction | storytime | list | pov\",\n      \"estimatedViralPotential\": \"high | medium | low\",\n      \"reasoning\": \"why this would perform well\"\n    }\n  ],\n  \"urgentAlerts\": [\n    {\n      \"hashtag\": \"#hashtag\",\n      \"message\": \"alert message\",\n      \"recommendedAction\": \"what to do right now\",\n      \"windowOfOpportunity\": \"estimated hours before trend peaks\"\n    }\n  ],\n  \"bestTimeToPost\": \"recommendation based on trend timing\"\n}\n`;\n\n  const response = await axios.post(\n    'https://api.anthropic.com/v1/messages',\n    {\n      model: \"claude-opus-4-5\",\n      max_tokens: 2000,\n      messages: [{ role: \"user\", content: prompt }]\n    },\n    {\n      headers: {\n        'x-api-key': process.env.CLAUDE_API_KEY,\n        'anthropic-version': '2023-06-01',\n        'Content-Type': 'application/json'\n      }\n    }\n  );\n\n  const raw = response.data.content[0].text;\n  const clean = raw.replace(/```json|```/g, '').trim();\n  return JSON.parse(clean);\n}\n\nModule 4 — Auto Script Generation\nasync function generateVideoScript(contentIdea, trendContext) {\n  const prompt = `\nWrite a complete short-form video script for this content idea.\n\nCONTENT IDEA: ${JSON.stringify(contentIdea)}\nTREND CONTEXT: ${trendContext}\n\nRespond ONLY in this JSON format:\n{\n  \"title\": \"video title\",\n  \"duration\": \"estimated seconds\",\n  \"hook\": \"opening line — first 3 seconds\",\n  \"fullScript\": \"complete word-for-word script\",\n  \"captions\": [\"caption 1\", \"caption 2\", \"...\"],\n  \"hashtags\": [\"#tag1\", \"#tag2\", \"#tag3\"],\n  \"cta\": \"call to action at the end\",\n  \"thumbnailIdea\": \"description of ideal thumbnail\"\n}\n\nRules:\n- Hook must create curiosity or shock in under 4 seconds\n- Script must be 120–180 words for a 30–45 second video\n- Conversational, energetic tone\n- End with a strong CTA (follow, comment, share)\n`;\n\n  const response = await axios.post(\n    'https://api.anthropic.com/v1/messages',\n    {\n      model: \"claude-opus-4-5\",\n      max_tokens: 1000,\n      messages: [{ role: \"user\", content: prompt }]\n    },\n    {\n      headers: {\n        'x-api-key': process.env.CLAUDE_API_KEY,\n        'anthropic-version': '2023-06-01',\n        'Content-Type': 'application/json'\n      }\n    }\n  );\n\n  const raw = response.data.content[0].text;\n  return JSON.parse(raw.replace(/```json|```/g, '').trim());\n}\n\nModule 5 — Auto Video Production with InVideo\nconst invideo = axios.create({\n  baseURL: 'https://api.invideo.io/v1',\n  headers: { Authorization: `Bearer ${process.env.INVIDEO_API_KEY}` }\n});\n\nasync function produceVideo(script) {\n  // Start generation\n  const { data } = await invideo.post('/videos/generate', {\n    script: script.fullScript,\n    format: \"9:16\",\n    duration: \"short\",\n    style: \"dynamic\",\n    voiceover: { enabled: true, voice: \"en-US-female-1\", speed: 1.1 },\n    captions: { enabled: true, style: \"bold-bottom\", highlight: true },\n    music: { enabled: true, mood: \"upbeat\", volume: 0.25 },\n    cta: { enabled: true, text: script.cta, position: \"bottom\" }\n  });\n\n  const videoId = data.videoId;\n\n  // Poll until ready\n  let exportUrl = null;\n  while (!exportUrl) {\n    await new Promise(r => setTimeout(r, 6000));\n    const status = await invideo.get(`/videos/${videoId}/status`);\n    if (status.data.state === \"completed\") exportUrl = status.data.exportUrl;\n    if (status.data.state === \"failed\") throw new Error(\"Video generation failed\");\n    console.log(`  Video progress: ${status.data.progress}%`);\n  }\n\n  return { videoId, exportUrl, script };\n}\n\nModule 6 — Alerts & Notifications\nasync function sendAlert(alert, analysis) {\n  const payload = {\n    text: `🚨 *TREND ALERT: ${alert.hashtag}* — ${alert.severity}`,\n    blocks: [\n      {\n        type: \"section\",\n        text: {\n          type: \"mrkdwn\",\n          text: `*📈 ${alert.hashtag}* grew *${alert.growthRate}%* in the last check\\n` +\n                `Platforms: ${alert.platforms.join(', ')}\\n` +\n                `Window: ${analysis.urgentAlerts?.[0]?.windowOfOpportunity || 'Act now'}`\n        }\n      },\n      {\n        type: \"section\",\n        text: {\n          type: \"mrkdwn\",\n          text: `*💡 Recommended action:*\\n${analysis.urgentAlerts?.[0]?.recommendedAction || 'Create content immediately'}`\n        }\n      }\n    ]\n  };\n\n  // Send to Slack webhook\n  if (process.env.SLACK_WEBHOOK_URL) {\n    await axios.post(process.env.SLACK_WEBHOOK_URL, payload);\n  }\n\n  // Or send to any custom webhook\n  if (process.env.ALERT_WEBHOOK_URL) {\n    await axios.post(process.env.ALERT_WEBHOOK_URL, {\n      type: \"trend_explosion\",\n      alert,\n      analysis,\n      timestamp: new Date().toISOString()\n    });\n  }\n}\n\nMain Orchestrator — Full Pipeline\nimport cron from 'node-cron';\n\nasync function runTrendRadar() {\n  console.log(`\\n🔍 Trend Radar scan started at ${new Date().toISOString()}`);\n\n  try {\n    // 1 — Scrape all platforms\n    console.log(\"  [1/5] Scraping TikTok & Instagram...\");\n    const trendData = await scrapeAllPlatforms();\n    console.log(`  ✅ ${trendData.length} posts collected`);\n\n    // 2 — Detect explosions\n    console.log(\"  [2/5] Detecting explosions...\");\n    const alerts = detectExplosions(trendData);\n    console.log(`  ✅ ${alerts.length} alerts detected`);\n\n    // 3 — AI analysis\n    console.log(\"  [3/5] Analyzing with Claude...\");\n    const analysis = await analyzeWithClaude(trendData, alerts);\n    console.log(`  ✅ ${analysis.contentIdeas?.length} content ideas generated`);\n\n    // 4 — Auto-generate scripts for top 2 ideas\n    console.log(\"  [4/5] Generating video scripts...\");\n    const topIdeas = analysis.contentIdeas?.slice(0, 2) || [];\n    const scripts = await Promise.all(\n      topIdeas.map(idea => generateVideoScript(idea, JSON.stringify(analysis.topTrends)))\n    );\n    console.log(`  ✅ ${scripts.length} scripts written`);\n\n    // 5 — Produce videos\n    console.log(\"  [5/5] Producing videos with InVideo...\");\n    const videos = await Promise.all(scripts.map(produceVideo));\n    console.log(`  ✅ ${videos.length} videos ready`);\n\n    // 6 — Send alerts\n    if (alerts.length > 0) {\n      await sendAlert(alerts[0], analysis);\n      console.log(\"  ✅ Alerts sent\");\n    }\n\n    // Final report\n    return {\n      scannedAt: new Date().toISOString(),\n      postsAnalyzed: trendData.length,\n      explosionAlerts: alerts,\n      contentIdeas: analysis.contentIdeas,\n      videos: videos.map(v => ({ title: v.script.title, url: v.exportUrl })),\n      bestTimeToPost: analysis.bestTimeToPost\n    };\n\n  } catch (err) {\n    console.error(\"Radar error:\", err.message);\n    throw err;\n  }\n}\n\n// Schedule: run every 4 hours automatically\ncron.schedule('0 */4 * * *', () => {\n  runTrendRadar().then(report => {\n    console.log(\"\\n📊 RADAR REPORT:\", JSON.stringify(report, null, 2));\n  });\n});\n\n// Also run immediately on startup\nrunTrendRadar();\n\nEnvironment Variables\n# .env\nAPIFY_TOKEN=apify_api_xxxxxxxxxxxxxxxx\nINVIDEO_API_KEY=iv_api_xxxxxxxxxxxxxxxx\nCLAUDE_API_KEY=sk-ant-xxxxxxxxxxxxxxxx\n\n# Optional alerts\nSLACK_WEBHOOK_URL=https://hooks.slack.com/services/xxx/xxx/xxx\nALERT_WEBHOOK_URL=https://your-app.com/webhooks/trends\n\nNormalized Radar Report Schema\n{\n  \"scannedAt\": \"2025-02-25T10:00:00Z\",\n  \"postsAnalyzed\": 400,\n  \"explosionAlerts\": [\n    {\n      \"hashtag\": \"#aitools\",\n      \"severity\": \"EXPLOSIVE\",\n      \"growthRate\": 187,\n      \"platforms\": [\"tiktok\", \"instagram\"],\n      \"windowOfOpportunity\": \"4–8 hours\"\n    }\n  ],\n  \"contentIdeas\": [\n    {\n      \"title\": \"5 AI tools that replaced my entire team\",\n      \"hashtag\": \"#aitools\",\n      \"hook\": \"I fired my team. Here's what I replaced them with.\",\n      \"format\": \"list\",\n      \"estimatedViralPotential\": \"high\"\n    }\n  ],\n  \"videos\": [\n    {\n      \"title\": \"5 AI tools that replaced my entire team\",\n      \"url\": \"https://cdn.invideo.io/exports/iv_xxx.mp4\"\n    }\n  ],\n  \"bestTimeToPost\": \"Post within the next 3 hours while the trend is rising\"\n}\n\nBest Practices\nRun the radar every 2–4 hours — trends peak fast and fade within 24–48h\nMonitor 8–15 hashtags max per run to stay within Apify free tier\nAlways produce content within the rising phase — never wait for the peak\nUse node-cron for local scheduling or Apify Schedules for cloud automation\nStore baseline data in Redis or a database for accurate spike detection in production\nPipe the video URLs directly into your social media scheduler (Buffer, Later, etc.)\nRequirements\nApify account → https://www.apify.com/?fpr=dx06p\nInVideo account → https://invideo.sjv.io/TBB\nClaude / OpenClaw API key\nNode.js 18+\nOptional: Slack workspace for real-time alerts\nOptional: Social media scheduler (Buffer, Later) for auto-publishing"
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/g4dr/tiktok-trend-radar",
    "publisherUrl": "https://clawhub.ai/g4dr/tiktok-trend-radar",
    "owner": "g4dr",
    "version": "1.0.0",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/tiktok-trend-radar",
    "downloadUrl": "https://openagent3.xyz/downloads/tiktok-trend-radar",
    "agentUrl": "https://openagent3.xyz/skills/tiktok-trend-radar/agent",
    "manifestUrl": "https://openagent3.xyz/skills/tiktok-trend-radar/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/tiktok-trend-radar/agent.md"
  }
}