npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

node-red-contrib-slack-socketmode

v1.0.1

Published

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

Readme

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…