Slack Socket Mode Trigger icon

Slack Socket Mode Trigger

Triggers workflow when a Slack message matches a regex pattern via Socket Mode

Overview

This node triggers workflows in n8n when specific Slack events occur and optionally when incoming Slack messages match a user-defined regular expression pattern. It uses Slack's Socket Mode to listen for real-time events without requiring a public HTTP endpoint.

Common scenarios where this node is beneficial include:

  • Automating responses or actions when certain Slack events happen, such as messages posted, app mentions, channel changes, or user activities.
  • Filtering Slack messages by regex patterns to trigger workflows only on messages matching specific criteria.
  • Monitoring activity in specific Slack channels by filtering events to a selected channel.

Practical examples:

  • Trigger a workflow whenever someone mentions your Slack app with a keyword matching a regex pattern.
  • Start a workflow when a new file is shared in a particular Slack channel.
  • React to button interactions (block actions) in Slack messages to automate feedback collection.

Properties

Name Meaning
Trigger On Select one or more Slack event types that will trigger the workflow. Examples include "App Installed", "Message", "Channel Created", "Reaction Added", etc. A comprehensive list of Slack event types is provided.
Regex Pattern A regular expression pattern to match against incoming Slack messages. Capture groups can be used to extract data from the message text. If specified, only messages matching this pattern will trigger the workflow.
Regex Flags Flags for the regular expression, such as g for global matching or i for case-insensitive matching.
Channel to Watch Optionally select a specific Slack channel to filter events. If set, only events originating from this channel will trigger the workflow. Can be selected from a list or specified by channel ID.

Output

The node outputs JSON data representing the Slack event payload received via Socket Mode. The output includes:

  • body: The full raw body of the Slack event request.
  • payload: The payload object associated with the event (if applicable).
  • context: Contextual information about the event.
  • event: The actual Slack event object containing details such as type, user, channel, message content, etc.

This output allows downstream nodes to access all relevant event data for further processing.

The node does not output binary data.

Dependencies

  • Requires a Slack app configured with Socket Mode enabled.
  • Requires credentials including an API authentication token (bot token), app token, and signing secret for Slack Socket Mode.
  • Uses the official Slack Bolt SDK (@slack/bolt) to connect and listen to Slack events.
  • Supports proxy configuration via environment variables HTTP_PROXY or HTTPS_PROXY.
  • Requires appropriate OAuth scopes granted to the Slack app to receive the selected event types.

Troubleshooting

  • Missing Credentials: The node requires bot token, app token, and signing secret. Ensure these are correctly configured in the node credentials.
  • Invalid Channel ID: When specifying a channel by ID, ensure it matches Slack's channel ID format (starts with C, G, or D followed by 8+ alphanumeric characters).
  • Regex Errors: Invalid regex patterns or flags may cause errors or no matches. Validate regex syntax before use.
  • Event Subscription Issues: The Slack app must have subscribed to the selected event types in its configuration; otherwise, events won't be received.
  • Proxy Configuration: If behind a proxy, ensure environment variables are set correctly; otherwise, connection to Slack may fail.
  • Error Starting Socket Mode App: Check logs for errors related to starting or stopping the Slack Socket app. Common causes include invalid tokens or network issues.

Links and References

Discussion