Stay Instantly Updated on Twitter Mentions with Automated Slack Alerts ⚙️
Meet Laura, the social media manager at a growing tech startup. She spends hours every day manually checking Twitter for any company mentions to respond quickly and manage reputation. With hundreds of mentions every week, the manual task wastes at least 3 hours daily and risks missing urgent tweets. Meanwhile, her team communications often lag behind, causing delayed responses and lost engagement opportunities.
This is where an automation like the one we’ll explore comes in handy. Using n8n’s powerful automation platform combined with Twitter and Slack, you can set up a workflow that checks for new mentions every 10 minutes and instantly notifies your team on Slack with direct links to the tweets.
What This Automation Does
- Runs every 10 minutes to keep your monitoring near real-time without manual effort.
- Searches Twitter for the last 50 mentions of your specified company Twitter handle (e.g.,
@n8n_io). - Filters the results to only notify of tweets created since the last workflow run, avoiding duplicate alerts.
- Formats important tweet info like tweet text and direct URL to the tweet for clear visibility.
- Posts these new mentions as messages directly to your specified Slack channel (e.g.,
#recent-tweets). - Saves hours of manual social media monitoring and centralizes alerts into your communication platform.
The benefits? You stay proactive on social media, catch issues or praise early, and streamline your team’s workflow without toggling between platforms.
Prerequisites ⚙️
- n8n account (self-hosting optional 💻 – consider Hostinger for hosting your n8n instance: https://buldrr.com/hostinger).
- Twitter API credentials with OAuth 1.0 access (for the Twitter node).
- Slack workspace and API Token with permission to post messages.
- Basic familiarity with n8n interface to create and manage workflows.
Step-by-Step Guide to Build This Workflow
Step 1: Create a Cron Node to Schedule
In your n8n editor, click + → Cron. Configure it to trigger every 10 minutes by setting:
- Mode: everyX
- Unit: minutes
- Value: 10
This node automatically starts the workflow on this schedule. You should see your node named Run Every 10 Minutes or rename it for clarity.
Common Mistake: Forgetting to save changes or set the correct time unit, causing no triggers.
Step 2: Define Setup Values with a Set Node
Click + → Set. Add string values:
twitterSearchValuewith your company Twitter handle (e.g.,@n8n_io).slackChannelwith your target Slack channel name (e.g.,#recent-tweets).
This node holds configuration data used downstream.
Visual: You should see these two fields under Values.
Step 3: Calculate Timestamp 10 Minutes Ago with DateTime Node
From the cron trigger, add a Date & Time node. Set:
- Action: calculate
- Value:
{{Date()}} - Operation: subtract
- Duration: 10 (or reference from Cron dynamically)
- Time Unit: minutes
This node produces a timestamp exactly 10 minutes before the current time, to filter tweets.
Step 4: Search Twitter for Mentions
Add the Twitter node. Select operation search.
- For Search Text, add an expression referencing the Set node’s
twitterSearchValue. - Use your Twitter OAuth credentials for authentication.
This node fetches the last 50 tweets mentioning your handle.
Step 5: Filter Tweets Created Since Last Run Using If Node
Insert an If node.
- Set condition type to Date & Time.
- Compare the tweet’s
created_atfield with the timestamp from the DateTime node.
This filters out tweets older than 10 minutes, ensuring you alert only on new mentions.
Step 6: Format Tweet Data for Slack
Use a Set node to prepare data:
- Create a field
Tweetwith the tweet’s text. - Create a
Tweet URLfield constructed by concatenating Twitter’s URL with the user’s screen name and tweet ID.
This makes the Slack message informative and actionable.
Step 7: Post New Mentions Directly to Slack Channel
Add the Slack node. Configure:
- Text: Use an expression combining static text and dynamic tweet data from the Set node.
- Channel: Reference your Slack channel string from the Setup node.
- Authenticate with your Slack API credentials.
Once this runs, new mentions appear as Slack messages with clickable tweet links.
Customizations ✏️
- Change Search Frequency: Update the Cron node’s schedule value to a preferred interval (e.g., every 5 minutes) for faster alerts.
- Expand Search Criteria: Modify the Twitter node’s search text to include alternate company handles or hashtags.
- Slack Message Styling: In the Slack node, add attachments or formatting for richer message presentation.
- Add More Filters: Insert additional nodes like Function or Filter between the Twitter and Slack step to filter by tweet language or sentiment.
- Notify Multiple Channels: Clone the Slack node and configure different channels to notify separate teams.
Troubleshooting 🔧
Problem: Workflow doesn’t trigger on schedule
Cause: Cron node misconfiguration or workflow not activated.
Solution: Revisit the Cron node, confirm every 10 minutes setup, activate workflow from top-right toggle.
Problem: Twitter node returns no data
Cause: Invalid Twitter credentials or incorrect search query.
Solution: Reauthorize Twitter credentials, verify search text references the correct handle with @.
Problem: Slack messages not posted
Cause: Slack API credentials missing or channel name error.
Solution: Check Slack node credentials, confirm channel name includes # if required.
Pre-Production Checklist ✅
- Verify Twitter API credentials have read access for search.
- Test Slack API token’s message posting using a test message.
- Run workflow manually first to confirm data flows correctly and nodes execute without errors.
- Test different Twitter search queries for expected mention results.
- Ensure workflow is activated for scheduled runs.
Deployment Guide
Activate the workflow by toggling it from draft to active within n8n. Confirm the cron scheduling is running.
Monitor initial runs using n8n’s execution logs to catch any failures early.
Consider setting up email alerts on workflow failures for production readiness.
Conclusion
By following this guide, you’ve created a tailored n8n workflow that automatically scrapes Twitter mentions for your company handle every 10 minutes and sends timely alerts to your Slack channel. This automation saves hours of manual monitoring daily and ensures your team never misses a critical mention.
Next steps? Extend this by incorporating sentiment analysis for prioritizing tweets or adding a database to archive mentions for reporting. You’re well on your way to mastering social media automation using n8n!