node-red-contrib-slack-socketmode 1.0.1

Real-time integration between Slack and Node-RED using Bolt with Socket Mode.

npm install node-red-contrib-slack-socketmode

node-red-contrib-slack-socketmode

A Node-RED node that enables real-time bi-directional communication with Slack using the Slack RTM API (Socket Mode).

This node allows you to:

  • Receive messages from any Slack channel, DM or app mention.
  • Send messages from Node-RED to Slack using the same authenticated connection.
  • Run a persistent background Slack RTM client that automatically reconnects.
  • Avoid the need for external tunnels (like ngrok), as Slack Socket Mode requires no public URL.

This package is useful when building:

  • ChatOps automations
  • Monitoring or alerting pipelines
  • IoT β†’ Slack integrations
  • Slack assistants connected to industrial SCADA/PLC systems
  • Internal automation bots without requiring slash commands or HTTP endpoints

πŸ”§ Installation

Using npm

cd ~/.node-red
npm install node-red-contrib-slack-socketmode

🧩 Node Description

This package provides two main components:

  1. Slack RTM Listener Node

Creates a persistent connection to Slack using your SLACK_APP_TOKEN and receives all Slack messages allowed by your app permissions.

Outputs a msg object like:

{ "type": "slack_event", "event": "message", "user": "U1234567", "text": "hello world", "channel": "C9876543", "ts": "1731530820.239629" }

  1. Slack RTM Sender Node

Allows you to send Slack messages using:

msg.payload = { channel: "CHANNEL_ID", text: "Your message text" };

βš™οΈ Slack Configuration (Required)

Follow these steps to configure Slack:

  1. Create a Slack App

https://api.slack.com/apps

  1. Enable Socket Mode

Slack App β†’ Settings β†’ Socket Mode β†’ Enable

  1. Add Required OAuth Scopes

Bot Token Scopes:

app_mentions:read

channels:history

chat:write

groups:history

im:history

mpim:history

  1. Install the App into Your Workspace

Slack App β†’ Install App β†’ Install

  1. Retrieve Tokens

You will need:

Token Type Purpose SLACK_APP_TOKEN (starts with xapp-) Required for RTM (Socket Mode) SLACK_BOT_TOKEN (starts with xoxb-) Required for sending messages

Insert these tokens in the node configuration inside Node-RED.

πŸš€ Usage Examples

  1. Receiving messages

Connect the Slack RTM Listener node to a debug node.

No payload is required; socket mode starts automatically.

Output example:

{ "type": "slack_event", "event": "message", "user": "U13579", "text": "Temperature is too high!", "channel": "C24680" }

  1. Sending messages from Node-RED

Inject:

{ "channel": "C24680", "text": "Hello from Node-RED!" }

Function node "Format message":

msg.payload = { channel: "C24680", text: "Hello from Node-RED!" }; return msg;

Connect it to Slack RTM Sender.

πŸ”„ Auto-Reconnect Feature

The Slack RTM connection automatically:

Reconnects on network failures

Resumes after computer sleep

Handles Slack server restarts

No user intervention is required.

πŸ›  Advanced Use Cases Trigger flows on keyword if (msg.text.includes("status")) { msg.payload = "System OK"; return msg; } return null;

Forward alerts to Slack

Use MQTT β†’ Function β†’ Slack RTM Sender.

Control Node-RED flows from Slack

Use the Listener node + Switch node.

πŸ§ͺ Testing

You can verify your Slack tokens by running:

node slack-socket.js

You should see:

Slack Bolt connected in Socket Mode…

Node Info

Version: 1.0.1
Updated 2 days ago
License: MIT
Rating: 5.0 1

Categories

Actions

Rate:

Downloads

0 in the last week

Nodes

  • slack-socket

Keywords

  • node-red
  • slack
  • slack-bot
  • slack-rtm
  • socket-mode
  • chatops

Maintainers