Automated Tweet Sentiment Analysis and Alerting Pipeline
detail.loadingPreview
This n8n workflow automatically fetches tweets related to a specific hashtag, analyzes their sentiment using Google Cloud Natural Language, stores the results in both MongoDB and Postgres, and alerts users on Slack for tweets with positive sentiment.
About This Workflow
This robust ETL pipeline is designed to streamline social media monitoring and sentiment analysis. It begins by regularly polling Twitter for tweets containing the '#OnThisDay' hashtag. Each fetched tweet is then stored in a MongoDB collection. Subsequently, the text of these tweets undergoes sophisticated sentiment analysis via Google Cloud Natural Language, yielding sentiment scores and magnitude. This analyzed data is then augmented with the original tweet text and stored in a PostgreSQL database. Finally, a conditional check filters for tweets with a positive sentiment score, triggering an immediate notification on Slack, complete with the tweet's content and its sentiment.
Key Features
- Automated Data Ingestion: Schedule regular fetching of relevant tweets from Twitter.
- Advanced Sentiment Analysis: Leverage Google Cloud Natural Language to gauge tweet sentiment and magnitude.
- Multi-Database Integration: Store processed data in both MongoDB for flexible NoSQL storage and PostgreSQL for structured relational data.
- Conditional Alerting: Receive instant Slack notifications for tweets exceeding a defined positive sentiment threshold.
- Customizable Triggers: Easily adjust the hashtag, polling frequency, and notification conditions.
How To Use
- Schedule Trigger: Configure the 'Cron' node to set the desired interval for fetching tweets (e.g., daily at 6 AM).
- Fetch Tweets: In the 'Twitter' node, ensure your Twitter API credentials are set and specify the 'searchText' (e.g., '#OnThisDay'). Adjust the 'limit' to control the number of tweets fetched per run.
- Store Raw Data: Connect the 'Twitter' node to the 'MongoDB' node to store the initial tweet data in your MongoDB instance.
- Analyze Sentiment: Link 'MongoDB' to 'Google Cloud Natural Language'. Ensure your Google Cloud NLP credentials are configured and set the 'content' parameter to retrieve the tweet text from the MongoDB output.
- Extract Sentiment & Text: Connect 'Google Cloud Natural Language' to the 'Set' node. Map the 'documentSentiment.score' and 'documentSentiment.magnitude' to new fields and also map the original tweet text from the 'Twitter' node.
- Store Structured Data: Connect the 'Set' node to the 'Postgres' node. Configure the table name ('tweets') and the columns you wish to store, ensuring they match the fields created in the 'Set' node.
- Conditional Alerting: Link 'Postgres' to the 'IF' node. Set the condition to check if the 'score' is 'larger' than a specified value (e.g., 0 for positive sentiment).
- Send Slack Alerts: Connect the positive outcome of the 'IF' node to the 'Slack' node. Configure your Slack credentials and customize the 'text' message to include the tweet content and sentiment scores. Ensure the target 'channel' is correctly set.
- Handle Non-Alerts: Connect the negative outcome of the 'IF' node to the 'NoOp' node to indicate that no alert was triggered for that specific tweet.
Apps Used
Workflow JSON
{
"id": "dbcd91d6-1da9-4e78-99a6-771ac03efe2a",
"name": "Automated Tweet Sentiment Analysis and Alerting Pipeline",
"nodes": 29,
"category": "Operations",
"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: dbcd91d6-1da9...
About the Author
Crypto_Watcher
Web3 Developer
Automated trading bots and blockchain monitoring workflows.
Statistics
Related Workflows
Discover more workflows you might like
Universal CSV to JSON API Converter
Effortlessly transform CSV data into structured JSON with this versatile n8n workflow. Integrate it into any application as a custom API endpoint, supporting various input methods including file uploads and raw text.
Instant WooCommerce Order Notifications via Telegram
When a new order is placed on your WooCommerce store, instantly receive detailed notifications directly to your Telegram chat. Stay on top of your e-commerce operations with real-time alerts, including order specifics and a direct link to view the order.
On-Demand Microsoft SQL Query Execution
This workflow allows you to manually trigger and execute any SQL query against your Microsoft SQL Server database. Perfect for ad-hoc data lookups, administrative tasks, or quick tests, giving you direct control over your database operations.