Automated Twitter Sentiment Analysis and Data Pipeline
detail.loadingPreview
Streamline your social media monitoring with this n8n workflow. Automatically fetch tweets, analyze their sentiment, and store or alert based on the results.
About This Workflow
This n8n workflow is designed to automate the process of monitoring Twitter for specific hashtags, analyzing the sentiment of the tweets, and then acting upon that analysis. It begins by scheduling a daily fetch of tweets containing the hashtag #OnThisDay. These tweets are then stored in MongoDB for initial processing. Following this, the Google Cloud Natural Language API is leveraged to determine the sentiment score and magnitude of each tweet's text. The workflow then enriches the tweet data with these sentiment metrics before storing them in a PostgreSQL database. Finally, an IF node checks if the sentiment score is positive, triggering a Slack notification if it is. This powerful automation can be customized to suit various social media listening and data integration needs.
Key Features
- Scheduled Tweet Fetching: Automatically retrieve tweets based on a hashtag at a specified time.
- Sentiment Analysis: Utilize Google Cloud Natural Language API to gauge tweet sentiment (score and magnitude).
- Data Storage & Integration: Seamlessly store tweet data and sentiment scores in MongoDB and PostgreSQL.
- Conditional Notifications: Trigger alerts (e.g., to Slack) based on sentiment thresholds.
- Customizable Workflow: Easily adapt the hashtag, databases, and notification channels to your specific requirements.
How To Use
- Schedule Trigger: Configure the 'Cron' node to set the desired daily trigger time (e.g.,
hour: 6for 6 AM). - Fetch Tweets: In the 'Twitter' node, ensure your Twitter API credentials are set up and customize the
searchTextto the desired hashtag (e.g.,=#OnThisDay). Set thelimitfor the number of tweets to fetch. - Store Raw Tweets: Connect the 'Twitter' node to the 'MongoDB' node. Set up your MongoDB credentials and specify the
collectionname (e.g.,tweets). - Analyze Sentiment: Connect the 'MongoDB' node to the 'Google Cloud Natural Language' node. Configure your Google Cloud NLP credentials. The
contentparameter will automatically reference the tweet text from MongoDB. - Enrich Data: Connect the 'Google Cloud Natural Language' node to the 'Set' node. Map the
documentSentiment.scoreto a new field namedscore,documentSentiment.magnitudeto amagnitudefield, and ensure the original tweettextis also passed through. - Store Processed Data: Connect the 'Set' node to the 'Postgres' node. Configure your PostgreSQL credentials and specify the
tablename (e.g.,tweets). Ensure thecolumnsare correctly defined to receive thetext,score, andmagnitude. - Conditional Notification: Connect the 'Postgres' node to the 'IF' node. Set the
conditionsto check if thescoreis greater than a desired threshold (e.g.,operation: "larger",value1: "={{$json["score"]}}"). - Send Alerts: Connect the 'IF' node's 'larger' output to the 'Slack' node. Configure your Slack credentials, select the
channel(e.g.,tweets), and customize thetextto include the sentiment score, magnitude, and tweet text using the provided expressions.
Apps Used
Workflow JSON
{
"id": "55994bda-6d94-4005-b49b-174ccd2a13e1",
"name": "Automated Twitter Sentiment Analysis and Data Pipeline",
"nodes": 22,
"category": "Marketing",
"status": "active",
"version": "1.0.0"
}Note: This is a sample preview. The full workflow JSON contains node configurations, credentials placeholders, and execution logic.
Get This Workflow
ID: 55994bda-6d94...
About the Author
DevOps_Master_X
Infrastructure Expert
Specializing in CI/CD pipelines, Docker, and Kubernetes automations.
Statistics
Related Workflows
Discover more workflows you might like
Automated AI Motion Illustration Workflow with Midjourney and Kling
Unleash your creativity with this n8n workflow that automates the generation of stunning motion illustrations. It leverages the power of Midjourney for static image creation and Kling AI to transform them into dynamic videos, all managed through the PiAPI. Perfect for content creators, marketers, and social media professionals looking to produce engaging visuals at scale.
Automated Multi-Platform Social Media Publisher
Streamline your social media content creation and publishing with this n8n workflow. Simply fill out a web form with your caption, media (image or video), and target platforms, and let n8n automate the posting process across multiple social networks.
WhatsApp AI Assistant: LLaMA 4 & Google Search for Real-Time Insights
Instantly deploy a smart AI assistant on WhatsApp, powered by Groq's lightning-fast LLaMA 4 model. This workflow enables real-time conversations, remembers context, and provides up-to-date answers by integrating live Google Search results.