Category: Automations › Social Media & Content · Best for: Creators reading audience feedback · Platform: n8n · Steps: 14
What it does
The AI reads your YouTube comments and tells you if people are happy or not.
YouTube Comment Sentiment Analyzer with Google Sheets & OpenAI
Works with: OpenAI, Google Sheets, Sentiment Analysis
What you get
- The n8n workflow file (
workflow.json), ready to import - This setup guide
- The list of fields to change for your own accounts (see Install below)
- Email support if you get stuck
Before you start
-
An n8n account. Easiest: n8n Cloud (free trial). Self-host for free with Docker:
docker run -it --rm -p 5678:5678 -v n8n_data:/home/node/.n8n docker.n8n.io/n8nio/n8n, then open http://localhost:5678. -
Accounts and API keys for these services:
- OpenAI API key: how to connect (used by OpenAI Chat Model)
- Google (Sheets, Gmail, Drive, Calendar, Docs): how to connect (used by Get Video Urls from Google Sheet, Insert and update comment in google sheet, Update last fetched time and next_fetch_time)
- API key sent as a query parameter (see the node for which service): how to connect (used by Get Comments for video urls)
Install
- In n8n, click Create workflow (top right).
- Click the ⋯ menu → Import from file and choose
workflow.json. Or open the file, copy everything and paste it onto the empty canvas with Ctrl/Cmd + V. - Open each node with a red warning triangle and pick or create the matching credential from the list above.
- Point these fields at your own sheets, chats and accounts:
- Get Video Urls from Google Sheet →
sheetName: choose your own - Get Video Urls from Google Sheet →
documentId: choose your own - Insert and update comment in google sheet →
sheetName: choose your own - Insert and update comment in google sheet →
documentId: choose your own - Update last fetched time and next_fetch_time →
sheetName: choose your own - Update last fetched time and next_fetch_time →
documentId: choose your own
- Get Video Urls from Google Sheet →
- Click Save.
Test it
- Click Test workflow (or Execute workflow). When clicking ‘Test workflow’ starts it. Trigger it once with real sample data.
- Click each node to check its output. A green tick means the step worked.
- Fix any red node: it's almost always a credential or a field that still points at a sheet or chat that isn't yours.
Go live
Toggle Active (top right). From now on it runs on its own. Check Executions in the left sidebar to see every run.
How it works, step by step
- When clicking ‘Test workflow’ starts the workflow (Manual).
- OpenAI Chat Model uses AI (OpenAI).
- Get Video Urls from Google Sheet uses Google Sheets.
- Analyze sentiment of every comment uses AI (Sentiment Analysis).
- check next fetch time is available or not checks a condition and routes items accordingly.
- Format fields as required to save in google sheet reshapes the data for the next step.
- Get Comments for video urls calls an external API (https://www.googleapis.com/youtube/v3/commentThreads).
- check next fetch time is before the current time checks a condition and routes items accordingly.
- Insert and update comment in google sheet uses Google Sheets to appendOrUpdate.
- Check Success Response checks a condition and routes items accordingly.
- No Operation, do nothing uses No Op.
- Update last fetched time and next_fetch_time uses Google Sheets to appendOrUpdate.
- Split Out uses Split Out.
- No Operation, do nothing1 uses No Op.
Extra setup notes
These notes are also on the canvas as yellow sticky notes:
YouTube Comment Sentiment Analyzer with Google Sheets & OpenAI
How to Use This Workflow:
YouTube Comment Sentiment Analyzer
-
Trigger: Click "Execute Workflow" to run it manually.
-
Your Google Sheet should have 2 sheets:
-
Sheet1 (Results with Sentiment):
-
Column A:
commentId(YouTube comment id) -
Column B:
video_url(url of video) -
Column C:
comment(YouTube comment) -
Column E:
likes(Number of likes on that particular comment) -
Column f:
reply(Number of replies on that particular comment) -
Column g:
sentiment(Analyzed sentiment of the comment) -
Column h:
published_at(timestamp of comment published)
-
-
Sheet2 (Video URLs):
- Column A:
video_urls(list of YouTube video URLs) - Column B:
last_fetched_time(timestamp of the last fetch) - Column C:
next_fetch_time(time for the next fetch)
- Column A:
- Make sure these credentials are set up:
- Google Sheets (Service Account)
- YouTube Data API v3
- OpenAI API Key (for sentiment analysis)
- What this workflow does:
- Reads video URLs from Sheet2.
- Checks last fetched time (if applicable).
- Fetches new comments from YouTube.
- Analyzes sentiment using OpenAI.
- Appends comment, sentiment, video ID, and timestamp to Sheet1.
- Updates last_fetched timestamp in Sheet2.
- Tip:
- You can replace the Manual Trigger with a Cron node for automatic execution at specified intervals.
Troubleshooting
- "Credentials not found": open the node and select your credential again.
- Google "access blocked": in Google Cloud, add your email as a test user on the OAuth consent screen.
- Webhook not firing: copy the node's Production URL (not Test URL) into the other app, and make sure the workflow is Active.
- AI node errors: check your API key has billing enabled and the model name exists on your plan.
- Nothing happens on schedule: the workflow must be Active, and self-hosted n8n must stay running.
Need help?
Reply to your Morning Method order email and we'll help you get it running.
© Morning Method