Automate Twitter Mentions to Mattermost with n8n

Save time monitoring Twitter mentions of n8n_io by automatically posting new tweets to your Mattermost channel. This n8n workflow filters duplicates and delivers real-time alerts to boost productivity.
twitter
cron
function
+2
Workflow Identifier: 1480
NODES in Use: Cron, Twitter, Set, Function, Mattermost

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

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

Opening Problem Statement

Meet Sarah, a community manager for a tech startup that heavily relies on the brand presence of n8n_io on Twitter. Sarah spends hours every day manually checking for new tweets mentioning n8n_io to stay updated and engage quickly. The constant search through endless tweets wastes valuable time and sometimes lets important mentions slip through unnoticed. Sarah also manages a busy Mattermost channel where the team collaborates and shares critical updates, but manual tweet posting delays vital communication and decreases team responsiveness.

Imagine losing hours daily, struggling with repetitive work, and risking missed opportunities to engage your community. This specific challenge of real-time Twitter monitoring and quick sharing to Mattermost can seriously stall a team’s productivity and impact brand visibility.

What This Automation Does

This unique n8n workflow solves Sarah’s problem with a smooth and effective automation. Here’s exactly what happens when it runs:

  • Every minute, a Cron node triggers the workflow to search Twitter for recent tweets mentioning “n8n_io”.
  • The Twitter node fetches tweets matching this search query, including user info and tweet content.
  • The Set node formats and extracts key tweet data such as tweet ID, URL, username, tweet text, user photo, display name, and profile link color.
  • A Function node filters out tweets that were already processed before, ensuring only new tweets proceed.
  • The filtered, fresh tweets are posted as detailed messages with author info and colors to a dedicated Mattermost channel automatically.
  • This continuous loop runs every minute, guaranteeing real-time updates and no duplicates in your team channel.

By automating this, Sarah instantly saves hours each week from manual searching, reduces errors and missed mentions, and keeps the team rapidly informed through Mattermost notifications.

Prerequisites ⚙️

  • n8n account (cloud or self-hosted)
  • Twitter developer account with OAuth1 credentials configured in n8n
  • Mattermost account with API token and target channel ID to post messages
  • Basic understanding of workflow setup in n8n

Step-by-Step Guide to Build This Workflow

1. Create a Cron Trigger to Run Every Minute

In n8n, click + Add Node, search and select Cron.

Set the Cron node’s parameters: Click Trigger TimesItem → choose Every Minute. This ensures the workflow runs once every 60 seconds, so you get near real-time tweets.

You should see a time schedule block showing a line for “Every Minute”. This guarantees the workflow’s trigger speed.

Common mistake: Forgetting to set the mode to “Every Minute” can cause longer delays.

2. Add a Twitter Node to Search Tweets

Click + Add Node > search for Twitter, and drag it after the Cron node.

Configure Twitter node:
– Operation: Search
– Search Text: n8n_io (this is the keyword to track)
– Additional fields → Result Type: Recent (to get the latest tweets)

Attach your Twitter OAuth1 credentials to allow access.

After this step, the data will include details of tweets mentioning “n8n_io” aggregated every minute.

Common mistake: Incorrect Twitter OAuth credentials or insufficient API access can prevent tweet fetching.

3. Use Set Node to Extract and Format Key Tweet Data

Add a Set node connected to Twitter node.

In Set node parameters, add fields matching your workflow’s required tweet data:
– id: {{$node["Twitter"].json["id"]}}
– url: https://twitter.com/{{$node["Twitter"].json["user"]["screen_name"]}}/status/{{$node["Twitter"].json["id_str"]}}
– tweet: {{$node["Twitter"].json["text"]}}
– username: {{$node["Twitter"].json["user"]["screen_name"]}}
– photo: {{$node["Twitter"].json["user"]["profile_image_url_https"]}}
– name: {{$node["Twitter"].json["user"]["name"]}}
– color: {{$node["Twitter"].json["user"]["profile_link_color"]}}

Check the option Keep Only Set to discard other unneeded data, reducing noise downstream.

Common mistake: Incorrect field paths might cause empty or failed fields.

4. Add a Function Node to Filter Duplicate Tweets

Add a Function node connected to the Set node.

Paste this JavaScript code inside Function Code:

const new_items = [];
const data = this.getWorkflowStaticData('node');

data.ids = data.ids || [];

for (var i=0; i item.json.id)
return new_items;

This code keeps track of tweet IDs that have already been sent out and only emits new ones to avoid duplicate notifications.

Common mistake: Resetting or clearing static data will cause repeated tweets to show again.

5. Post New Tweets to Mattermost Channel

Add a Mattermost node after the Function node.

Configure the node parameters:
– Channel ID: Use your target Mattermost channel’s ID (e.g., c81pcft85byeipbp3nptbmicah)
– Message: Set to tweet URL from Function node: {{$node["Function"].json["url"]}}
– Attachments:
– Text: Tweet text from function node
– Color: Use user profile link color with prefix #
– Author Icon: User’s profile photo URL
– Author Link: Link to user’s Twitter profile
– Author Name: Formatted as “full name (username)”

Connect your Mattermost credentials and test.

Common mistake: Wrong channel ID or insufficient permissions to post can cause failures.

Customizations ✏️

  • Change monitored keyword: In the Twitter node, edit “Search Text” to any keyword or hashtag you want to track.
  • Adjust frequency: In the Cron node, modify trigger times to every 5 or 10 minutes if minute-level updates are too frequent.
  • Extend tweet data: Add more user or tweet fields in the Set node to show additional info in Mattermost messages like retweet counts.
  • Message formatting: Customize Mattermost message attachment colors or text templates for your team branding.
  • Multi-channel posting: Duplicate Mattermost node with different channel IDs to broadcast alerts across teams.

Troubleshooting 🔧

Problem: “No tweets found despite recent mentions”

Cause: Twitter API quota limits, or incorrect search syntax.

Solution: Double-check Twitter credentials, verify API status, and ensure the search query is valid and has recent results.

Problem: “Mattermost node fails to send messages”

Cause: Wrong API token, channel ID, or permission issues.

Solution: Confirm your Mattermost API token and channel ID, give appropriate permissions, and retest.

Pre-Production Checklist ✅

  • Verify Twitter OAuth1 credentials authorize search operations successfully.
  • Test Cron trigger manually to check workflow execution frequency.
  • Run the workflow once and check that tweets appear correctly formatted in Mattermost.
  • Confirm Function node filters out duplicates by rerunning immediately—no repeated posts should appear.
  • Backup your workflow JSON prior to deployment for rollback safety.

Deployment Guide

Activate the workflow in n8n by toggling it to Active. Monitor the executions tab for errors, and adjust the Cron timing if needed. Since this workflow is simple and runs every minute, cloud or self-hosted n8n (including Hostinger options) will work well.

Set Mattermost alerts preferences to ensure notifications are visible to your team members promptly.

FAQs

  • Q: Can I track multiple keywords?
    A: Yes, you can create multiple Twitter nodes or modify the search query with OR logic but mind Twitter API rate limits.
  • Q: Does this consume many Twitter API requests?
    A: It uses one search request per minute, which is within standard Twitter API limits.
  • Q: Is my Twitter/Mattermost data secure?
    A: Yes, credentials are stored encrypted in n8n. Ensure to use secure environments.
  • Q: Can I post to Slack instead of Mattermost?
    A: Yes, just swap the Mattermost node with Slack node and adapt message formatting.

Conclusion

By following this guide, you automated your social media monitoring for the “n8n_io” Twitter mentions, pushing live updates into your Mattermost channel. This saves you at least a couple of hours weekly and helps your team stay alert and responsive to community conversations.

Next steps could include adding sentiment analysis, incorporating more social platforms like LinkedIn, or integrating response automation to tweets for faster engagement.

With this tailored automation, you turn tedious monitoring into timely, insightful communication without lifting a finger.

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 in n8n

A complete beginner guide to building an AI-powered 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