Back to all posts

How to Build Automated YouTube Comment Sentiment Analysis with n8n and SocialKit API

Jonathan Geiger
youtubesentiment-analysisn8nautomationapicommentsai

YouTube comment sentiment analysis is valuable for content creators, marketers, and researchers who need to understand audience reactions at scale. In this guide we'll show you how to build a complete automation that extracts comments, analyzes sentiment with AI, and delivers insights via email.

We'll use n8n for workflow automation, SocialKit's YouTube Comments API for reliable data extraction, and OpenAI for sentiment analysis. The result is a hands-off system that can run daily and provide consistent sentiment insights.

Video Tutorial

Watch the complete implementation in action:

Open in YouTube

What You'll Build

This automation workflow:

  1. Accepts YouTube URLs via chat or webhook trigger
  2. Extracts all comments using SocialKit YouTube Comments API
  3. Processes comments by combining them into a single text block
  4. Analyzes sentiment using AI (OpenAI/ChatGPT) with structured JSON output
  5. Generates HTML report with sentiment classification and summary
  6. Sends email notifications with the analysis results
  7. Supports scheduling for daily automated sentiment monitoring

Prerequisites

Before starting, ensure you have:

  • n8n instance (cloud or self-hosted)
  • SocialKit API key - Get free access here
  • OpenAI API key for sentiment analysis
  • Email service configured in n8n (Gmail, SMTP, etc.)
  • Basic understanding of n8n workflow concepts

Setting Up the Workflow

Step 1: Get the n8n Blueprint

Download the complete workflow blueprint:

n8n YouTube Sentiment Analysis Blueprint

Import this blueprint into your n8n instance to get the complete workflow structure.

Step 2: Configure the Trigger

The workflow starts with a chat trigger that accepts YouTube URLs:

{
  "trigger": "chat",
  "input": "youtube_url",
  "description": "Paste YouTube video URL to analyze comments"
}

You can also use:

  • Webhook trigger for API-based automation
  • Schedule trigger for daily analysis of predefined URLs
  • Manual trigger for on-demand analysis

Step 3: Extract Comments with SocialKit API

Configure the HTTP Request node to call SocialKit's YouTube Comments API:

Endpoint Configuration:

Method: GET
URL: https://api.socialkit.dev/youtube/comments

Parameters:

{
  "access_key": "{{ $env.SOCIALKIT_API_KEY }}",
  "url": "{{ $json.youtube_url }}",
  "limit": 100,
  "sortBy": "new"
}

Headers:

{
  "Content-Type": "application/json"
}

This extracts up to 100 recent comments with full metadata (author, likes, replies, timestamps).

Step 4: Process Comments Array

Comments come as an array that needs to be split and processed:

Split Out Node Configuration:

  • Field to Split Out: data.comments
  • Include Binary Data: False
  • Destination Field Name: comment

Aggregate Node Configuration:

  • Operation: Combine all items
  • Combine Field: comment.text
  • Separator: \n\n---\n\n

This creates a single text block with all comments separated for AI analysis.

Step 5: AI Sentiment Analysis

Configure the OpenAI node for structured sentiment analysis:

System Prompt:

You are an expert in sentiment analysis specializing in analyzing YouTube comments. You will be given comments in string format, all combined together. Analyze the overall sentiment and provide output in JSON format only.

Required JSON structure:
{
  "sentiment": "positive" | "negative" | "neutral",
  "summary": "Brief summary of the overall sentiment and key themes"
}

Model Settings:

  • Model: gpt-3.5-turbo or gpt-4
  • Max Tokens: 500
  • Temperature: 0.3 (for consistent results)
  • Response Format: JSON

Step 6: Generate HTML Email Report

Create an HTML template for the email report:

<div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto;">
  <h2 style="color: #333;">YouTube Comment Sentiment Analysis</h2>
  
  <div style="background: #f5f5f5; padding: 15px; border-radius: 5px; margin: 20px 0;">
    <h3>Video URL:</h3>
    <a href="{{ $node["Chat Trigger"].json["youtube_url"] }}">{{ $node["Chat Trigger"].json["youtube_url"] }}</a>
  </div>
  
  <div style="background: {% if $json.sentiment == 'positive' %}#d4edda{% elif $json.sentiment == 'negative' %}#f8d7da{% else %}#fff3cd{% endif %}; padding: 15px; border-radius: 5px; margin: 20px 0;">
    <h3>Overall Sentiment: {{ $json.sentiment | upper }}</h3>
    <p><strong>Analysis Summary:</strong></p>
    <p>{{ $json.summary }}</p>
  </div>
  
  <div style="background: #e9ecef; padding: 15px; border-radius: 5px; margin: 20px 0;">
    <p><strong>Analysis Date:</strong> {{ $now.format('YYYY-MM-DD HH:mm') }}</p>
    <p><strong>Comments Analyzed:</strong> {{ $node["HTTP Request"].json["data"]["comments"].length }}</p>
  </div>
</div>

Step 7: Send Email Notification

Configure the Email node:

Email Settings:

{
  "to": "your-email@example.com",
  "subject": "YouTube Sentiment Analysis: {{ $json.sentiment | title }}",
  "html": "{{ $node["HTML Template"].json["html"] }}",
  "from": "noreply@yourdomain.com"
}

Real-World Use Cases

Content Creator Monitoring

  • Daily sentiment tracking for new video uploads
  • Competitor analysis by monitoring their comment sentiment
  • Content strategy insights based on audience reaction patterns

Brand Monitoring

  • Product launch feedback analysis from YouTube reviews
  • Brand mention sentiment tracking across YouTube content
  • Campaign performance measurement through comment analysis

Market Research

  • Industry sentiment trends by analyzing multiple channels
  • Product feedback collection from review videos
  • Audience sentiment mapping for market insights

Conclusion

This automation provides a complete solution for YouTube comment sentiment analysis without manual intervention. The combination of n8n's workflow automation, SocialKit's reliable YouTube Comments API, and AI-powered sentiment analysis creates a robust system for understanding audience reactions.

Start with the basic workflow and gradually add features like scheduling, database storage, and multiple video analysis as your needs grow. The modular design makes it easy to customize for specific use cases.

Ready to build your sentiment analysis automation?

For more YouTube automation ideas, check out our other tutorials: