n8n Workflow
Intermediate

Twitter Mentions to Rocket.Chat Notifier

Automate real-time Twitter mention tracking. This workflow fetches new mentions of a specific handle, filters them to avoid duplicates, and sends instant notifications to a Rocket.Chat channel.

Overview

Automatically sends new Twitter mentions of your brand to a Rocket.Chat channel for real-time social media monitoring and team collaboration.

🧠 Description & Use Case

This workflow automates the process of monitoring Twitter for brand mentions and instantly notifying a team via Rocket.Chat. It ensures that every new mention of a specific Twitter handle is captured and delivered as a real-time alert, preventing duplicate notifications for the same tweet.

🔄 How It Works:

  1. Scheduled Trigger:

    • The Cron node initiates the workflow automatically every minute, ensuring continuous monitoring without manual intervention.
  2. Fetch Twitter Mentions:

    • The n8n.io mentions (Twitter) node searches Twitter for recent tweets that mention the handle @n8n_io.
  3. Extract Key Information:

    • The Filter Tweet Data (Set) node receives the raw tweet data and simplifies it. It extracts only the essential information: the tweet's text, its unique ID, and a direct URL to the tweet.
  4. Filter for New Tweets:

    • The Only get new tweets (Function) node is a crucial deduplication step. It maintains a memory of tweet IDs that have already been processed. It compares incoming tweets against this list and only allows new, unseen tweets to pass through, preventing the same mention from being sent multiple times.
  5. Send Rocket.Chat Alert:

    • For each new mention that passes the filter, the RocketChat node formats a message containing the tweet's content and a direct link. It then posts this alert to the 'general' channel in Rocket.Chat, notifying the team instantly.

✅ Real-World Use Cases:

  • Social Media Monitoring: Keep a finger on the pulse of your brand's presence on Twitter.
  • Customer Support: Quickly identify and respond to customer questions or issues raised on Twitter, improving response times.
  • Brand Management: Track brand sentiment and public perception by seeing what users are saying in real-time.
  • Internal Communication: Ensure your marketing or communications team is immediately aware of online conversations involving your brand.

Instructions

Basic steps

  1. Download workflow JSON
  2. Import into n8n
  3. Configure node parameters as needed
  4. Test and enable the workflow

💡 Tips

After importing, verify all connectors and credentials match your environment.

Preview

Workflow Visualization

6 nodes
100%
On clicking 'execute'manualTriggerFilter Tweet DatasetOnly get new tweetsfunctionn8n.io mentionstwitterRocketChatrocketchatCroncron

Nodes

1

On clicking 'execute'

禁用

manualTrigger

v1
2

Filter Tweet Data

set

v1
3

Only get new tweets

function

v1
4

n8n.io mentions

twitter

v1
5

RocketChat

rocketchat

v1
6

Cron

cron

v1

Statistics

Total nodes:6
Disabled nodes:1
Node types:6
Connections:5
View full JSON structure
{
  "nodes": [
    {
      "name": "On clicking 'execute'",
      "type": "n8n-nodes-base.manualTrigger",
      "disabled": true,
      "position": [
        400,
        850
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "name": "Filter Tweet Data",
      "type": "n8n-nodes-base.set",
      "position": [
        680,
        300
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "Tweet",
              "value": "={{$node[\"n8n.io mentions\"].json[\"text\"]}}"
            },
            {
              "name": "Tweet ID",
              "value": "={{$node[\"n8n.io mentions\"].json[\"id\"]}}"
            },
            {
              "name": "Tweet URL",
              "value": "=https://twitter.com/{{$node[\"n8n.io mentions\"].json[\"user\"][\"screen_name\"]}}/status/{{$node[\"n8n.io mentions\"].json[\"id_str\"]}}"
            }
          ]
        },
        "options": {},
        "keepOnlySet": true
      },
      "typeVersion": 1
    },
    {
      "name": "Only get new tweets",
      "type": "n8n-nodes-base.function",
      "position": [
        910,
        300
      ],
      "parameters": {
        "functionCode": "const staticData = getWorkflowStaticData('global');\nconst newTweetIds = items.map(item => item.json[\"Tweet ID\"]);\nconst oldTweetIds = staticData.oldTweetIds; \n\nif (!oldTweetIds) {\n  staticData.oldTweetIds = newTweetIds;\n  return items;\n}\n\n\nconst actualNewTweetIds = newTweetIds.filter((id) => !oldTweetIds.includes(id));\nconst actualNewTweets = items.filter((data) => actualNewTweetIds.includes(data.json['Tweet ID']));\nstaticData.oldTweetIds = [...actualNewTweetIds, ...oldTweetIds];\n\nreturn actualNewTweets;\n"
      },
      "typeVersion": 1
    },
    {
      "name": "n8n.io mentions",
      "type": "n8n-nodes-base.twitter",
      "position": [
        480,
        300
      ],
      "parameters": {
        "operation": "search",
        "searchText": "@n8n_io",
        "additionalFields": {}
      },
      "credentials": {
        "twitterOAuth1Api": "Twitter Credentials"
      },
      "typeVersion": 1
    },
    {
      "name": "RocketChat",
      "type": "n8n-nodes-base.rocketchat",
      "position": [
        1150,
        300
      ],
      "parameters": {
        "text": "=New Mention!: {{$node[\"Filter Tweet Data\"].json[\"Tweet\"]}}.\nSee it here: {{$node[\"Only get new tweets\"].json[\"Tweet URL\"]}}",
        "channel": "general",
        "options": {},
        "jsonParameters": true
      },
      "credentials": {
        "rocketchatApi": "Rocket Chat API"
      },
      "typeVersion": 1
    },
    {
      "name": "Cron",
      "type": "n8n-nodes-base.cron",
      "position": [
        270,
        300
      ],
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "mode": "everyX",
              "unit": "minutes",
              "value": 1
            }
          ]
        }
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Cron": {
      "main": [
        [
          {
            "node": "n8n.io mentions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "n8n.io mentions": {
      "main": [
        [
          {
            "node": "Filter Tweet Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Tweet Data": {
      "main": [
        [
          {
            "node": "Only get new tweets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Only get new tweets": {
      "main": [
        [
          {
            "node": "RocketChat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On clicking 'execute'": {
      "main": [
        []
      ]
    }
  }
}

Actions

Share
Categories:
Tags:
cronmanualtriggerfunctionsettwitterrocketchat

Technical Specs

Complexity:
Intermediate
Node Count:
6 nodes
Published:11 months ago
Updated:16 days ago

Compatibility

Platform:
N8N Cloud & Self-hosted
Min Version:
N8N v1.0.0+
Supports cloud and self-hosted deployment

License

This workflow template follows MIT license, you can freely use, modify and distribute.

Please comply with relevant third-party service terms when using.

Related Workflows