Overview
This node triggers workflows in n8n when specific Slack events occur via Slack's Socket Mode. It listens for a wide range of Slack event types (such as messages, app installs, channel changes, reactions, and many others) and can filter these events based on a user-defined regular expression pattern applied to incoming Slack messages. Additionally, it supports filtering events by a specific Slack channel.
Common scenarios where this node is beneficial include:
- Automating responses or actions when certain keywords or patterns appear in Slack messages.
- Triggering workflows on specific Slack events like app installations, channel creations, or user joins.
- Monitoring interactions with Slack buttons or other UI elements.
- Filtering events to only those occurring in a particular Slack channel.
Practical examples:
- Automatically creating a task in a project management tool when a message matching a regex pattern is posted in a designated Slack channel.
- Sending notifications or logging when a new channel is created or deleted.
- Responding to button clicks within Slack messages to trigger custom workflows.
Properties
| Name | Meaning |
|---|---|
| Trigger On | Select one or more Slack event types that will trigger the workflow. Options include a comprehensive list such as "App Installed", "Message", "Channel Created", "Reaction Added", "Workflow Published", and many more. |
| Regex Pattern | A regular expression pattern to match against incoming Slack messages. Capture groups can be used to extract data from the message content. |
| Regex Flags | Flags for the regular expression, e.g., g for global matching, i for case-insensitive matching, m for multiline, etc. |
| Channel to Watch | Optionally select a specific Slack channel to filter events. If specified, 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 objects representing the Slack event data received. Each output item contains the following structure:
body: The raw body of the Slack event request.payload: The payload object associated with the event (if applicable).context: Contextual information provided by the Slack Bolt framework.event: The actual Slack event object containing details about the triggered event.
If a regex pattern is specified, the node applies it to incoming messages but does not modify the output structure; it simply filters which events trigger the workflow.
The node does not output binary data.
Dependencies
- Requires a Slack app configured for Socket Mode with appropriate permissions.
- Requires an API key credential providing:
- Bot token
- App token
- Signing secret
- Uses the official Slack Bolt SDK (
@slack/bolt) to connect and listen to Slack events via Socket Mode. - Supports proxy configuration via environment variables
HTTP_PROXYorHTTPS_PROXY. - Requires n8n credentials setup with the above Slack tokens.
Troubleshooting
- Missing Credentials: The node requires bot token, app token, and signing secret. If any are missing, the node will throw an error indicating missing required Slack Socket 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 at least 8 alphanumeric characters). Otherwise, validation errors will occur.
- Regex Errors: Invalid regex patterns or flags may cause runtime errors or prevent proper filtering. Validate regex syntax before use.
- Event Listener Setup Failures: Errors during setting up event listeners for selected triggers will be logged. Ensure the Slack app has subscribed to the requested event types.
- Connection Issues: Problems starting or stopping the Slack Socket app (e.g., network issues, invalid tokens) will be logged and may prevent triggering.
- Proxy Configuration: If behind a proxy, ensure environment variables
HTTP_PROXYorHTTPS_PROXYare correctly set; otherwise, connection attempts may fail.