Automate Twitter Sentiment Analysis with n8n ETL Pipeline

Discover how this n8n ETL pipeline automates extracting tweets with #OnThisDay, analyzes their sentiment using Google Cloud Natural Language, stores results in MongoDB and Postgres, and posts positive tweets to Slack — saving hours of manual monitoring and enabling timely insights.
twitter
googleCloudNaturalLanguage
postgres
+6
Workflow Identifier: 1609
NODES in Use: Twitter, MongoDB, Google Cloud Natural Language, Set, Postgres, IF, Slack, NoOp, Cron

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What This Automation Does

This workflow fetches tweets tagged #OnThisDay each morning at 6 AM.
It saves raw tweets to MongoDB, then analyzes tweet emotions with Google Cloud NLP.
It stores sentiment scores and tweet text in Postgres.
When tweets have a positive feeling, it sends messages to a Slack channel.
Negative or neutral tweets do not generate alerts.
This saves time and helps teams see moods quickly.


Tools and Services Used

  • Twitter API (OAuth1): Gets tweets with #OnThisDay.
  • MongoDB: Stores raw tweet texts.
  • Google Cloud Natural Language API (OAuth2): Performs sentiment analysis.
  • Postgres Database: Saves analyzed tweet data with sentiment.
  • Slack API: Sends positive sentiment alerts to a channel.
  • n8n automation platform: Runs and connects all nodes.

Inputs, Processing Steps, and Outputs

Inputs

  • Search term ‘#OnThisDay’ from Twitter API every day at 6 AM.
  • MongoDB database connection for storing raw tweets.
  • Google Cloud NLP API credentials for sentiment evaluation.
  • Postgres database for saving final sentiment records.
  • Slack channel destination for positive sentiment alerts.

Processing Steps

  1. Extract tweets by searching latest 3 tweets with #OnThisDay.
  2. Insert raw tweet text into MongoDB collection named ‘tweets’.
  3. Run sentiment analysis on tweet text using Google Cloud NLP.
  4. Structure sentiment score, magnitude, and original text via Set node.
  5. Insert sentiment data and tweet text into Postgres ‘tweets’ table.
  6. Use IF node to check if sentiment score is greater than 0.
  7. If sentiment is positive, send message to Slack channel.
  8. If sentiment is not positive, proceed silently with NoOp node.

Outputs

  • Raw tweets saved in MongoDB.
  • Sentiment scores and text saved in Postgres.
  • Slack notifications showing positive tweets with scores.
  • No Slack messages for neutral or negative tweets.

Who Should Use This Workflow

This workflow is for social media analysts who check tweet moods daily.
It fits teams wanting fast, error-free sentiment reports without manual work.
Users who want automatic alerts about positive tweets benefit a lot.


Beginner Step-by-Step: How to Use This Workflow in n8n

Download and Import Workflow

  1. Click the Download button on this page to get the workflow file.
  2. Open n8n editor and choose “Import from File”.
  3. Select the downloaded workflow file to add it to your workspace.

Configure Credentials and Settings

  1. Add credentials for Twitter API with OAuth1.
  2. Add credentials for Google Cloud NLP API with OAuth2.
  3. Connect MongoDB and Postgres database credentials.
  4. Set Slack API token and confirm Slack channel name.
  5. Update table names, channel names, or IDs if your setup differs.

Test and Activate Workflow

  1. Run the workflow manually once to check the data flow.
  2. Look at output logs to ensure no errors.
  3. Toggle the active switch in n8n to turn the workflow on.
  4. Monitor the workflow at 6 AM daily for data and alerts.

For users controlling their own servers, check self-host n8n for hosting options.


Customizations and Extensions

  • Change sentiment threshold by editing IF node (e.g., score > 0.2) to show only stronger positives.
  • Increase the tweet fetch limit in Twitter node (e.g., from 3 to 10) for more data.
  • Add tweet timestamp or user info fields into MongoDB insertion for richer raw data.
  • Add an IF branch to notify on negative sentiment (scores below -0.5) for alerting bad buzz.
  • Modify Cron node to run multiple times per day such as 6 AM, 12 PM, and 6 PM for frequent tracking.

Troubleshooting

Twitter Node Returns No Tweets or Authorization Error

Cause: Twitter OAuth1 token expired or invalid.
Solution: Re-authenticate Twitter OAuth1 API credentials inside n8n.

Google Cloud Natural Language Node Fails Authentication

Cause: Missing or wrong OAuth2 credentials.
Solution: Generate new OAuth2 credentials in Google Cloud Console and update in n8n.

Postgres Node Insert Errors due to Schema Mismatch

Cause: Table columns do not match Insert fields.
Solution: Verify Postgres table has exactly columns named “text”, “score”, “magnitude”.


Pre-Production Checklist

  • Ensure Twitter API keys have read permissions.
  • Check database connections and schema match for MongoDB and Postgres.
  • Test Google Cloud NLP API separately to confirm expected responses.
  • Confirm Slack channel exists and API token can post messages.
  • Perform a manual test run of the workflow before scheduling.
  • Backup database data before running workflow in production.

Deployment Guide

Activate workflow by toggling “active” in n8n after setup finishes.
Watch execution logs regularly to catch errors or slow runs.
Update Cron timing if different schedule is wanted.


Summary and Results

✓ Automates daily tweet fetching, analyzing, and saving with #OnThisDay.
✓ Gives instant alert for positive tweets via Slack.
✓ Removes manual work and errors from social sentiment reporting.
→ Enables teams to quickly see and act on tweet moods every morning.
→ Saves multiple hours weekly in tweet analysis tasks.


Frequently Asked Questions

Edit the search text field in the Twitter node to the new hashtag or keyword.
Yes, sentiment analysis uses billable credits based on API request volume, so monitor the API quota.
Re-authenticate Twitter OAuth1 API credentials in n8n to refresh expired or invalid tokens.
Yes, change the Cron node to run multiple times daily like 6 AM, 12 PM, and 6 PM.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free