AutomationFlowsSlack & Telegram › Receive and Process Incoming Direct Messages in Rocket.chat

Receive and Process Incoming Direct Messages in Rocket.chat

ByWetomate AI @wetomate-ai on n8n.io

Use this workflow to automatically check Rocket.Chat for unread direct messages, process the latest user message in each thread, and send a response back to the conversation. It is useful for building automated support, AI chat, or message-handling workflows inside Rocket.Chat.

Cron / scheduled trigger★★★★☆ complexity18 nodesHTTP RequestRocketchat
Slack & Telegram Trigger: Cron / scheduled Nodes: 18 Complexity: ★★★★☆ Added:

This workflow corresponds to n8n.io template #15775 — we link there as the canonical source.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "38BA3QctV5R3jZHB",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "tags": [],
  "nodes": [
    {
      "id": "21267365-1706-4af2-a9c5-97bf9b6565e6",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -2416,
        376
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 1
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d2e1750f-e4b9-41a6-b8db-3f6b7730860d",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -1968,
        376
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "update"
      },
      "typeVersion": 1
    },
    {
      "id": "207bc116-8056-4c1c-8b7e-6e535d53fe08",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -1520,
        376
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "228ab24e-f5ed-4bd3-8317-2296ab308eb8",
      "name": "Subscription.get",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -2192,
        376
      ],
      "parameters": {
        "url": "<__PLACEHOLDER_VALUE__Your Rocket.Chat server URL + /api/v1/subscriptions.get (e.g., https://chat.wetomate.de/api/v1/subscriptions.get)__>",
        "options": {},
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "rocketchatApi"
      },
      "typeVersion": 4.2
    },
    {
      "id": "08469b9f-6cdf-4b65-b883-5f1066a7f6da",
      "name": "IM.Messages",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1296,
        304
      ],
      "parameters": {
        "url": "<__PLACEHOLDER_VALUE__Your Rocket.Chat server URL + /api/v1/im.messages?roomId={{ $json.rid }} (e.g., https://chat.wetomate.de/api/v1/im.messages?roomId={{ $json.rid }})__>",
        "options": {},
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "rocketchatApi"
      },
      "typeVersion": 4.2
    },
    {
      "id": "05077bc1-5b2a-4aad-a968-3d32a3891e86",
      "name": "Split Out1",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -1072,
        304
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "messages"
      },
      "typeVersion": 1
    },
    {
      "id": "a41f5bf6-c8a1-428d-ad65-ba89a640d25e",
      "name": "Get last",
      "type": "n8n-nodes-base.code",
      "position": [
        -400,
        400
      ],
      "parameters": {
        "jsCode": "return [items[0]];"
      },
      "typeVersion": 2
    },
    {
      "id": "fd9388a7-be8b-4851-956a-93a10e5e3160",
      "name": "Only Users Prompt",
      "type": "n8n-nodes-base.filter",
      "position": [
        -848,
        304
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e9beaaeb-eec7-41cd-a94f-a7179803d1cd",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json.u.username }}",
              "rightValue": "<__PLACEHOLDER_VALUE__Your bot username to exclude (e.g., mybot)__>"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "d4757187-a9aa-4019-b3f5-95ed6bc45d2d",
      "name": "Sort",
      "type": "n8n-nodes-base.sort",
      "position": [
        -624,
        304
      ],
      "parameters": {
        "options": {},
        "sortFieldsUi": {
          "sortField": [
            {
              "order": "descending",
              "fieldName": "ts"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ab6abfc0-9107-47a7-8c72-ae8402ec09e8",
      "name": "Unread and Direct Messages",
      "type": "n8n-nodes-base.filter",
      "position": [
        -1744,
        376
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "dc845068-2551-422e-a290-6b57e5e1ebee",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $json.unread }}",
              "rightValue": 0
            },
            {
              "id": "d617fca5-8199-4dc4-83a4-e21bf6bc9f60",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.t }}",
              "rightValue": "d"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "893af578-029a-41f6-be2a-f351245cd300",
      "name": "Mark as Read",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -400,
        208
      ],
      "parameters": {
        "url": "<__PLACEHOLDER_VALUE__Your Rocket.Chat server URL + /api/v1/subscriptions.read (e.g., https://chat.wetomate.de/api/v1/subscriptions.read)__>",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "rid",
              "value": "={{ $('Loop Over Items').item.json.rid }}"
            }
          ]
        },
        "nodeCredentialType": "rocketchatApi"
      },
      "typeVersion": 4.2
    },
    {
      "id": "53169d2f-c4dd-4c07-88bb-57799a580152",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -248,
        160
      ],
      "parameters": {
        "color": 3,
        "height": 400,
        "content": "## Process Message\nProcess the selected user message here before sending the final reply. For example: format the prompt, extract key details, call an AI model, apply business rules, build the final response text, or map fields required by `RocketChat` node.\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "ab96d75e-c5c7-4e13-b855-9bef9103472c",
      "name": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -176,
        400
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "2779d56d-51a5-48f8-9ce1-aa0811df31e8",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2472,
        280
      ],
      "parameters": {
        "color": 7,
        "width": 880,
        "height": 256,
        "content": "## Triggered subscription retrieval\n\nInitiates the workflow on a schedule and retrieves subscription data from RocketChat."
      },
      "typeVersion": 1
    },
    {
      "id": "6c28688e-627c-4f68-8bc7-5d7adea5ab6c",
      "name": "RocketChat",
      "type": "n8n-nodes-base.rocketchat",
      "position": [
        48,
        472
      ],
      "parameters": {
        "text": "<__PLACEHOLDER_VALUE__Your bot response message (e.g., Thanks for your message!)__>",
        "channel": "=@{{ $json.u.username }}",
        "options": {},
        "attachments": []
      },
      "credentials": {
        "rocketchatApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0ddfb653-a29a-484a-9e00-8ce11f820f60",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3008,
        128
      ],
      "parameters": {
        "width": 464,
        "height": 448,
        "content": "## RocketChat Template\n\n### How it works\n\n1. Triggers workflow based on a schedule.\n2. Retrieves subscription data from RocketChat.\n3. Filters and processes unread messages.\n4. Sorts and marks messages as read.\n5. Sends processed results back to RocketChat.\n\n### Setup steps\n\n- [ ] Configure credentials for RocketChat API.\n- [ ] Configure bot username in the `Only Users Prompt` node.\n- [ ] Set the schedule for the workflow trigger.\n- [ ] Add some nodes for processing the users message and generates the response.\n\n### Customization\n\nThe schedule and chat message filters can be customized to fit specific requirements.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "79c056af-eab9-4f64-8f5e-e1cc0de1155a",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1552,
        160
      ],
      "parameters": {
        "color": 7,
        "width": 1280,
        "height": 400,
        "content": "## Process Each Subscription\n1. Retrieves latest messages in a room\n1. Filter all users messages and remove bot messages\n1. Get last user message\n1. Mark message as read and start processing message"
      },
      "typeVersion": 1
    },
    {
      "id": "21d47321-c263-49a8-ba43-86574f4c3820",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16,
        392
      ],
      "parameters": {
        "color": 7,
        "width": 160,
        "height": 240,
        "content": "## Send Result\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "b0ba7c85-f93d-4c1b-9bca-752b2618c02d",
  "connections": {
    "Sort": {
      "main": [
        [
          {
            "node": "Get last",
            "type": "main",
            "index": 0
          },
          {
            "node": "Mark as Read",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get last": {
      "main": [
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Unread and Direct Messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "RocketChat": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out1": {
      "main": [
        [
          {
            "node": "Only Users Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IM.Messages": {
      "main": [
        [
          {
            "node": "Split Out1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "IM.Messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Subscription.get",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Subscription.get": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Only Users Prompt": {
      "main": [
        [
          {
            "node": "Sort",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "No Operation, do nothing": {
      "main": [
        [
          {
            "node": "RocketChat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Unread and Direct Messages": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Use this workflow to automatically check Rocket.Chat for unread direct messages, process the latest user message in each thread, and send a response back to the conversation. It is useful for building automated support, AI chat, or message-handling workflows inside Rocket.Chat.

Source: https://n8n.io/workflows/15775/ — original creator credit. Request a take-down →

More Slack & Telegram workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Slack & Telegram

This workflow is perfect for anyone who wants to automate lead generation using n8n without paying for expensive scraping tools. It uses simple Google Maps API requests and Google Sheets to pull busin

Google Sheets, Telegram, N8N Nodes Rapiwa +2
Slack & Telegram

Outreach - plantilla importable. Uses googleSheets, httpRequest. Scheduled trigger; 5 nodes.

Google Sheets, HTTP Request
Slack & Telegram

Outreach - plantilla básica. Uses googleSheets, httpRequest. Scheduled trigger; 5 nodes.

Google Sheets, HTTP Request
Slack & Telegram

PROSPECT DISCOVERY & DATA COLLECTION. Uses @apify/n8n-nodes-apify, airtable, slack. Scheduled trigger; 34 nodes.

@Apify/N8N Nodes Apify, Airtable, Slack
Slack & Telegram

Automatically detect when your champion contacts change companies and respond with intelligent, personalized AI outreach before your competitors do.

Google Sheets, @Exploriumai/N8N Nodes Explorium Ai, HTTP Request +1