AI-Powered Tweet Sentiment Analyzer & Alerter
Integrates with:
Overview
Unlock Real-time Social Insights with this AI Agent
This AI Agent automates the process of monitoring Twitter for specific keywords or hashtags (initially set for '#OnThisDay'). It uses Google Cloud Natural Language for sentiment analysis, stores the tweet text and sentiment scores in MongoDB and PostgreSQL, and alerts you on Slack for tweets with positive sentiment. This empowers you to tap into social conversations, understand public perception, and react promptly.
Key Features & Benefits
- Scheduled Tweet Monitoring: Automatically fetches tweets using the Cron node at set intervals.
- Targeted Data Collection: Searches Twitter for specific hashtags or keywords (e.g.,
#OnThisDay
, brand mentions, industry terms). - AI-Driven Sentiment Analysis: Leverages Google Cloud Natural Language to accurately assess the emotional tone (score and magnitude) of each tweet.
- Dual Database Persistence: Stores raw tweet data and its sentiment analysis results in MongoDB for flexible querying and PostgreSQL for structured reporting.
- Conditional Slack Notifications: Instantly alerts a designated Slack channel when tweets meet a specific sentiment threshold (e.g., positive sentiment), enabling timely engagement or awareness.
- Data Enrichment: Combines original tweet data with its sentiment score and magnitude for comprehensive analysis.
- Customizable & Extensible: Easily modify search terms, sentiment criteria, database configurations, and alert messages to fit your unique business needs.
Use Cases
- B2C E-commerce: Monitor real-time Twitter sentiment for your brand or specific product launches (e.g., `#NewGadget`). Get Slack alerts for highly positive tweets to quickly engage with happy customers or identify user-generated content opportunities.
- B2B SaaS: Track industry conversations (e.g., `#AIinBusiness`) or competitor mentions. Analyze sentiment to understand market perception, identify pain points, and refine your marketing messaging. Store findings in PostgreSQL for trend analysis.
- Content Ideation: Discover trending topics with positive sentiment in your niche by monitoring relevant hashtags. Use insights to fuel your content calendar and blog posts.
- Brand Reputation Management: Set up alerts for your brand name to quickly identify and respond to tweets, especially those with strong sentiment (positive or negative, by adjusting the IF node).
- Market Research: Collect and analyze public opinion on specific themes or events relevant to your business by customizing the search query.
Prerequisites
- An n8n instance (Cloud or self-hosted).
- Twitter API V1.1 (OAuth 1.0a) credentials.
- Google Cloud Platform account with the Natural Language API enabled, and credentials for the 'Google Cloud Natural Language' node (typically OAuth2).
- MongoDB instance details (connection string, database name) and credentials.
- PostgreSQL instance details (host, database, user, password) and credentials.
- Slack workspace and API credentials (Bot Token recommended) for sending notifications.
Setup Instructions
- Download the n8n workflow JSON file.
- Import the workflow into your n8n instance.
- Cron Node: Adjust the 'Trigger Times' (e.g.,
Hour: 6
for 6 AM daily) to define how often the workflow runs. - Twitter Node: Enter your Twitter API V1.1 credentials. Modify the
Search Text
parameter from=#OnThisDay
to your desired search query (e.g., your brand name, a relevant hashtag, keywords). - MongoDB Node: Configure with your MongoDB connection string, database, and desired
Collection
(default is 'tweets'). Ensure the 'Fields' parameter is set totext
to store the tweet content. - Google Cloud Natural Language Node: Authenticate using your Google Cloud credentials. The
Content
field is set to={{$node["MongoDB"].json["text"]}}
, assuming the MongoDB node outputs the inserted document containing thetext
field. - Set Node: Review the expressions. It's configured to extract
score
andmagnitude
from the Google Cloud Natural Language node'sdocumentSentiment
, and the originaltext
from the 'Twitter' node. These values are then passed to PostgreSQL. - Postgres Node: Configure with your PostgreSQL connection details. Set the
Table
name (default 'tweets') and ensureColumns
match the data from the 'Set' node (text, score, magnitude
). - IF Node: The condition
={{$json["score"]}}
larger
0
filters for tweets with positive sentiment. Adjust the value0
or theoperation
if you want to filter for different sentiment scores (e.g.,smaller
for negative, or a higher/lower threshold). - Slack Node: Enter your Slack API credentials. Set the target
Channel
and customize the notificationText
using expressions like{{$json["text"]}}
,{{$json["score"]}}
, and{{$json["magnitude"]}}
. - Ensure you have created all necessary credentials (e.g., for Twitter, MongoDB, Google Cloud, PostgreSQL, Slack) within your n8n instance and link them to the respective nodes.
- Activate the workflow.
Want your own unique AI agent?
Talk to us - we know how to build custom AI agents for your specific needs.
Schedule a Consultation