Low-Code/No-Code Tools

Build a Multi-Platform Viral Content Detector with n8n

Problem statement:

Manually tracking viral content across TikTok, Instagram, YouTube, and Twitter can be slow and inconsistent. To streamline this process, we built a set of no-code workflows in n8n that automatically detect high-performing posts across platforms.

Each workflow connects to a specific source, collects trending or recent content, calculates a viral score based on relative performance, and stores the results in Google Sheets. When a post exceeds a defined threshold, an email notification is triggered with key metadata. These workflows run on a schedule, require no manual input, and are built entirely using visual automation.

We began with TikTok.

For TikTok automation, we used the TikTok Trending Scraper available on Apify. It returns structured data from the platform’s trending feed, including the username, view count, like count, hashtags, bio, and video URL.

The workflow starts with an HTTP Request node that fetches this data in JSON format.

Configuration:

  • Method: GET
  • Authentication: None
  • Body Parameters: None
  • Header Parameters: None

2. Google sheet: Append Tiktok Data

Once the data is fetched from TikTok, it flows directly into a Google Sheets node. This node is responsible for saving all trending video entries in their original form. Capturing this unfiltered data allows future comparison, trend analysis, or debugging if needed. The Google Sheet contains columns like username, caption, views, likes, video URL, and hashtags.

Configuration:

  • Credential to connect with: Google Sheets account
  • Resource: Sheet Within Document
  • Operation: Append Row
  • Document: From list → Workflow Sheet
  • Sheet: From list → Sheet1
  • Mapping Column Mode: Map Automatically

3. Code : Viral Score Logic

The Code node processes each video’s view count and estimates a viral score by comparing it to an average based on follower tiers. If the score is 6 or above, the video is labeled as viral. This helps the next step filter out only high-performing content.

Configuration:

  • Mode: Run Once for Each Item
  • Language: JavaScript
  • Output Fields: views, avgViews, viralScore, viral

Code:

function parse(val) {
if (!val) return 0;
val = val.toString().toUpperCase();
if (val.includes("K")) return parseFloat(val) * 1000;
if (val.includes("M")) return parseFloat(val) * 1000000;
return parseFloat(val.replace(/[^\d]/g, "")) || 0;
}
return items.map(item => {
const views = parse(item.json.Views);
const followers = parse(item.json.followersCount);
// Estimate avgViews based on follower tier
let avgViews = 0;
if (followers >= 1000000) avgViews = 600000;
else if (followers >= 500000) avgViews = 250000;
else if (followers >= 100000) avgViews = 80000;
else if (followers >= 10000) avgViews = 20000;
else avgViews = 5000;
const score = avgViews > 0 ? views / avgViews : 0;
item.json.avgViews = avgViews;
item.json.followers = followers;
item.json.viralScore = score.toFixed(2);
item.json.viral = score >= 6 ? "Yes" : "No";
return item;
})

4. IF Node : Filtering Viral Posts

After calculating the viral score, the IF node checks whether each post qualifies as viral. Only posts with a viral label marked as Yes continue through the workflow. This keeps the process focused on high-performing content.

Configuration:

  • Value 1: {{$json[“viral”]}}
  • Operator: is equal to
  • Value 2: Yes
  • Output: true path (for viral), false path (ignored)

5. Google Sheets Node : Appending Viral TikTok Posts

Viral posts identified by the IF node are sent to a separate Google Sheet for tracking. This creates a clean list of high-performing TikTok videos for future use in analysis, reporting, or content planning.

Configuration:

  • Credential: Google Sheets account
  • Resource: Sheet Within Document
  • Operation: Append Row
  • Document: From list → TikTok_Viral_Posts
  • Sheet: From list → Sheet1
  • Mapping Column Mode: Map Automatically

6. Send Email Node : Viral TikTok Alert

To enable instant visibility, a Send Email node is used to notify when a video goes viral. The email includes key fields such as username, views, viral score, and video link, allowing quick action without checking the sheet manually.

Configuration:

  • Credential: Gmail SMTP
  • Operation: Send
  • From Email: your-email@gmail.com
  • To Email: your-email@gmail.com
  • Subject: Viral TikTok Alert – {{$json[“username”]}}
  • Format: HTML
  • Body: Includes username, views, viral score, and video URL

Instagram Reels Workflow: User-Based Viral Detection

For Instagram, the goal was to detect viral reels from specific user accounts. Since Instagram doesn’t offer a public API for viral content, we used the Apify actor called instagram-reel-scraper, which extracts reel data from a target user’s profile. The actor returns fields like caption, likes, hashtags, video URL, and username.

The workflow is designed to fetch reels, log them, score performance based on likes, and notify when a reel significantly outperforms the user’s average.

1. HTTP Request Node – Fetching Instagram Reels via Apify

The workflow begins with an HTTP Request node that calls the Apify actor instagram-reel-scraper. This actor returns recent reels posted by a specified user, including caption, likes, video URL, hashtags, and upload time. The request is unauthenticated and runs directly through Apify’s run-sync endpoint.

Configuration:

  • Method: GET
  • Authentication: None
  • Headers: None
  • Body: None
  • Response Format: JSON

2. Set Node : Structuring Instagram Reels Data

The Set node is used to select and rename only the relevant fields from the raw Instagram JSON response. This includes mapping the caption, likes, hashtags, video URL, and username into clearly labeled fields that can be logged or processed further.

Configuration:

  • Mode: Manual Mapping
  • Fields to Set:
    • Username: {{$json[“inputUrl”].split(“/”)[3]}}
    • Bio: {{$json[“caption”]}}
    • Likes: {{$json[“likesCount”]}}
    • Hashtags: {{$json[“hashtags”].join(“, “)}}
    • Video URL: {{$json[“url”]}}

3. Google Sheets Node : Storing Instagram Reels Data

This Google Sheets node logs each fetched Instagram reel in its raw form. Saving the full dataset before scoring ensures a complete history of content for future analysis or comparison, even if the post doesn’t go viral.

Configuration:

  • Credential: Google Sheets account
  • Resource: Sheet Within Document
  • Operation: Append Row
  • Document: From list → Workflow Sheet
  • Sheet: From list → Sheet2
  • Mapping Column Mode: Map Automatically

4. Google Sheets Node : Lookup Average Likes by Username

To calculate whether a reel is viral, the workflow first needs to know how that user’s past content typically performs. This node searches the raw sheet for all previous posts by the same username and fetches their like counts. These values will be used to compute an average in the next step.

Configuration:

  • Credential: Google Sheets account
  • Resource: Sheet Within Document
  • Operation: Get Row(s)
  • Document: From list → Instagram_Raw_Reels
  • Sheet: From list → Sheet1
  • Filters:
    • Column: Username
    • Value: {{$json[“Username”]}}
  • Combine Filters: AND

5. Code Node : Calculating Viral Score for Instagram Reels

This Code node compares the likes of the current reel to the user’s average likes from previous posts. If no history is found, a fallback estimation is used based on follower tier. The result is a viral score that indicates how much better the reel is performing compared to the user’s norm. A score of 6 or higher marks it as viral.

Configuration:

  • Mode: Run Once for All Items
  • Language: JavaScript
  • Output Fields: followers, avgLikes, viralScore, viral

Code:

const likes = parseInt(String($json.Likes).replace(/[^\d]/g, '') || '0');
const followers = parseInt(String($json.followersCount).replace(/[^\d]/g, '') || '0');
let avgLikes = parseInt($node["Lookup avgLikes"].json.avgLikes || '0');
if (avgLikes === 0) {
  // fallback estimation
  if (followers >= 1000000) avgLikes = 80000;
  else if (followers >= 500000) avgLikes = 40000;
  else if (followers >= 100000) avgLikes = 20000;
  else if (followers >= 10000) avgLikes = 5000;
  else avgLikes = 1000;
}
const ratio = avgLikes > 0 ? likes / avgLikes : 0;
return [{
  json: {
    ...$json,
    followers,
    avgLikes,
    viralScore: ratio.toFixed(2),
    viral: ratio >= 6 ? "Yes" : "No"
  }
}];

6. IF Node : Filtering Viral Reels

This IF node filters out all non-viral reels by checking the viral flag set in the previous step. Only reels with a viral score of 6 or more are marked as viral and passed forward for logging and notification.

Configuration:

  • Value 1: {{$json[“viral”]}}
  • Operator: is equal to
  • Value 2: Yes
  • Mode: All Match
  • Convert types where required: Enabled

7. Google Sheets Node : Appending Viral Instagram Reels

This node saves only the reels that passed the viral check into a separate sheet. Keeping viral content isolated makes it easier to track standout posts without sifting through the full dataset.

Configuration:

  • Credential: Google Sheets account
  • Resource: Sheet Within Document
  • Operation: Append Row
  • Document: From list → Instagram_Viral_Reels
  • Sheet: From list → Sheet1
  • Mapping Column Mode: Map Automatically

8. Email Node : Viral Email Alert

This Send Email node triggers an alert whenever a reel is marked as viral. It sends the username, number of likes, viral score, and reel URL, allowing the team to act quickly without checking the sheet manually.

Configuration:

  • Credential: Gmail SMTP
  • Operation: Send
  • From Email: your-email@gmail.com
  • To Email: your-email@gmail.com
  • Subject: Viral Instagram Reel – {{$json[“Username”]}}
  • Format: HTML
  • Body: Includes Username, Likes, Viral Score, Video URL, and Bio

To track high-performing YouTube content, we used the Apify actor called youtube-trend-usa. This actor scrapes trending videos from the YouTube Trending page in the United States and returns data including the video title, channel name, and a combined details field that shows both views and publish time.

The workflow fetches this data, extracts view counts, calculates a viral score, and identifies which videos are significantly outperforming the expected average. Identified videos are then logged into Google Sheets and optionally sent via email alert for quick access.

This node connects to the Apify actor youtube-trend-usa to retrieve a list of trending YouTube videos in the United States. The data includes fields like channel, title, and a details string that combines view count and time since upload.

Configuration:

  • Method: GET
  • Authentication: None
  • Headers: None
  • Body: None
  • Response Format: JSON

2. Set Node : Extracting Views and Upload Time

This Set node restructures the raw JSON by separating the combined details field into two separate values: views and upload time. It also keeps the video title and channel name, making the data easier to process in later steps.

Configuration:

  • Mode: Manual Mapping
  • Fields to Set:
    • Title: {{$json[“title”]}}
    • Channel: {{$json[“channel”]}}
    • Views: {{$json[“details”].split(“\n”)[0]}}
    • Upload Time: {{$json[“details”].split(“\n”)[1]}}

This node logs all fetched YouTube trending videos into a Google Sheet. Storing the full dataset allows historical tracking, benchmarking, and performance comparison over time.

Configuration:

  • Credential: Google Sheets account
  • Resource: Sheet Within Document
  • Operation: Append Row
  • Document: From list → Workflow Sheet
  • Sheet: From list → Sheet3
  • Mapping Column Mode: Map Automatically

4: Code Node : Extracting Views & Calculating Viral Score

This Code node converts the view count string into a numeric value and compares it to a fixed benchmark. The result is a viral score used to identify standout videos. A score of 6 or higher flags the video as viral.

Configuration:

  • Mode: Run Once for Each Item
  • Language: JavaScript
  • Output Fields: Views, avgViews, viralScore, viral

Code:

function parseViews(details) {
  const matchM = details.match(/([\d.,]+)\s*M/);
  if (matchM) return parseFloat(matchM[1].replace(/,/g, '')) * 1_000_000;

  const matchK = details.match(/([\d.,]+)\s*K/);
  if (matchK) return parseFloat(matchK[1].replace(/,/g, '')) * 1_000;

  const matchNum = details.match(/([\d.,]+)\s*views/);
  if (matchNum) return parseFloat(matchNum[1].replace(/,/g, ''));

  return 0;
}

return items.map(item => {
  const views = parseViews(item.json.Details);

  // Since we don’t have follower count, assume a default average benchmark
  const avgViews = 500000;  // adjust this value based on real observation

  const score = avgViews > 0 ? views / avgViews : 0;

  item.json.Views = views;
  item.json.avgViews = avgViews;
  item.json.viralScore = score.toFixed(2);
  item.json.viral = score >= 6 ? "Yes" : "No";

  return item;
});

5. IF Node : Filtering Viral YouTube Videos

This IF node checks whether a video has been marked as viral based on the calculated score. Only those with a viral flag set to Yes proceed to the next steps for logging and notification.

Configuration:

  • Value 1: {{$json[“viral”]}}
  • Operator: is equal to
  • Value 2: Yes
  • Mode: All Match
  • Convert types where required: Enabled

6. Google Sheets Node : Storing Viral YouTube Videos

This Google Sheets node stores only the videos that passed the viral check. It helps maintain a clean record of high-performing YouTube content for quick review or trend analysis.

Configuration:

  • Credential: Google Sheets account
  • Resource: Sheet Within Document
  • Operation: Append Row
  • Document: From list → YouTube_Viral_Videos
  • Sheet: From list → Sheet1
  • Mapping Column Mode: Map Automatically

7: Send Email Node : Viral YouTube Video Alert

This Send Email node notifies when a video is flagged as viral. The message includes details like the video title, channel name, view count, and viral score, enabling quick action without checking the sheet manually.

Configuration:

  • Credential: Gmail SMTP
  • Operation: Send
  • From Email: your-email@gmail.com
  • To Email: your-email@gmail.com
  • Subject: Viral YouTube Alert – {{$json[“Title”]}}
  • Format: HTML
  • Body: Includes Title, Channel, Views, Viral Score, and Upload Time

To stay ahead of trending conversations, we used the Apify actor twitter-trends-scraper-united-states. It collects the top real-time trends on Twitter (X) specific to the U.S. region, returning fields such as trend name, tweet volume, and timestamp.

The workflow fetches this data, parses the tweet volume, scores each trend, and identifies which ones are gaining unusually high attention. Only viral trends are saved to a separate Google Sheet and optionally emailed for real-time awareness.

1. HTTP Request Node : Fetching Live Twitter Trends (US)

This node calls the Apify actor twitter-trends-scraper-united-states to retrieve real-time Twitter trends for the United States. Each result includes the trend name, tweet volume (if available), and the timestamp.

Configuration:

  • Method: GET
  • Authentication: None
  • Headers: None
  • Body: None
  • Response Format: JSON

2. Set Node : Structure Twitter Trend Data

This Set node extracts the relevant fields from the Twitter trends API response and renames them for clarity. It keeps only the trend name, tweet volume, and timestamp, which are needed for scoring and logging.

Configuration:

  • Mode: Manual Mapping
  • Fields to Set:
    • Trend: {{$json[“trend”]}}
    • Volume: {{$json[“volume”]}}
    • Time: {{$json[“time”]}}

This node logs all the fetched Twitter trends into a Google Sheet. It serves as a raw data archive for monitoring what’s trending in real time, regardless of whether the trend is flagged as viral.

Configuration:

  • Credential: Google Sheets account
  • Resource: Sheet Within Document
  • Operation: Append Row
  • Document: From list → Workflow Sheet
  • Sheet: From list → Sheet4
  • Mapping Column Mode: Map Automatically

This Code node cleans the tweet volume by removing text and commas, converting it into a numeric value. It then calculates a viral score by comparing the cleaned volume to a fixed benchmark. A score of 6 or more marks the trend as viral.

Configuration:

  • Mode: Run Once for Each Item
  • Language: JavaScript
  • Output Fields: volumeCount, avgVolume, viralScore, viral

Code:

function parseVolume(vol) {
  if (!vol) return 0;
  vol = vol.toUpperCase().replace("TWEETS", "").trim();

  if (vol.includes("K")) return parseFloat(vol) * 1_000;
  if (vol.includes("M")) return parseFloat(vol) * 1_000_000;
  return parseInt(vol.replace(/[^\d]/g, "")) || 0;
}

// Step 1: Parse all volumes
const volumes = items.map(item => parseVolume(item.json.volume));

// Step 2: Compute average (exclude 0s)
const validVolumes = volumes.filter(v => v > 0);
const avgVolume = validVolumes.length > 0
  ? validVolumes.reduce((sum, v) => sum + v, 0) / validVolumes.length
  : 20000; // fallback

// Step 3: Add fields
return items.map((item, index) => {
  const volume = volumes[index];
  const viralScore = avgVolume > 0 ? volume / avgVolume : 0;

  item.json.volumeParsed = volume;
  item.json.avgVolume = Math.round(avgVolume);
  item.json.viralScore = viralScore.toFixed(2);
  item.json.viral = viralScore >= 6 ? "Yes" : "No";

  return item;
});

This IF node checks whether the viral flag is set to Yes. Only trends that meet or exceed the viral threshold move forward in the workflow for logging and notifications.

Configuration:

  • Value 1: {{$json[“viral”]}}
  • Operator: is equal to
  • Value 2: Yes
  • Mode: All Match
  • Convert types where required: Enabled

This node records only the filtered viral trends into a separate Google Sheet. It helps maintain a clean log of high-impact Twitter conversations without mixing them with general trends.

Configuration:

  • Credential: Google Sheets account
  • Resource: Sheet Within Document
  • Operation: Append Row
  • Document: From list → Twitter_Viral_Trends
  • Sheet: From list → Sheet1
  • Mapping Column Mode: Map Automatically

This node records only the filtered viral trends into a separate Google Sheet. It helps maintain a clean log of high-impact Twitter conversations without mixing them with general trends.

Configuration:

  • Credential: Google Sheets account
  • Resource: Sheet Within Document
  • Operation: Append Row
  • Document: From list → Twitter_Viral_Posts
  • Sheet: From list → Sheet1
  • Mapping Column Mode: Map Automatically

7. Send Email Node : Viral Twitter Trend Notification

This Send Email node sends an alert when a trend is flagged as viral. The email includes key details like the trend name, tweet volume, viral score, and timestamp for quick review and timely response.

Configuration:

  • Credential: Gmail SMTP
  • Operation: Send
  • From Email: your-email@gmail.com
  • To Email: your-email@gmail.com
  • Subject: Viral Twitter Trend Alert – {{$json[“Trend”]}}
  • Format: HTML
  • Body: Includes Trend, Volume, Viral Score, and Time

Wrap-Up Highlights:

  • Detects viral content across TikTok, Instagram, YouTube, and Twitter automatically
  • Uses Apify actors and n8n’s no-code workflows to fetch and process platform data
  • Applies simple scoring logic to flag high-performing content in real time
  • Logs data in Google Sheets for easy tracking, analysis, and reporting
  • Sends instant email alerts for content that meets viral thresholds
  • Scalable, code-free, and fully customizable for different platforms or audiences

What’s Next?

Now that the core viral content detection workflows are in place, it’s time to explore how to take them even further:

  • Experiment with scoring strategies: Adjust thresholds, test alternate engagement metrics, or bring in external benchmarks to improve how viral content is identified.
  • Swap or mix platforms: Try integrating Reddit, LinkedIn, or Pinterest using similar logic. The same scoring structure can be extended to new sources with minimal changes.
  • Test different APIs and tools: Combine n8n with tools like LangChain, Apify custom actors, or OpenAI functions to build smarter filtering, classification, or summarization steps.
  • Fine-tune alerts: Add logic to trigger different types of notifications based on content category, region, or urgency — not every alert needs to be treated the same.
  • Explore community workflows: Check out how others are using n8n for social listening, AI summarization, or creative automation. Many ideas can be adapted into your workflow.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button