Slack Socket Event Trigger
AI-generatedOverview
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 incoming Slack messages using a user-defined regular expression pattern. When an event matching the selected trigger(s) and regex pattern occurs, the node emits the event data to start or continue a workflow.
Common scenarios where this node is beneficial include:
- Automating responses or actions based on Slack messages that match certain patterns.
- Reacting to Slack workspace events like new channels, user joins, or app installations.
- Monitoring button interactions or other interactive components within Slack apps.
- Integrating Slack event-driven workflows without polling by leveraging Socket Mode.
Practical examples:
- Trigger a workflow when a message contains a specific keyword or format, extracting data from capture groups in the regex.
- Start a workflow when a new channel is created to automatically set up integrations or send welcome messages.
- Respond to button clicks in Slack messages to update external systems or databases.
Properties
| Name | Meaning |
|---|---|
| Trigger On | Select one or more Slack event types to listen for. Examples include "App Installed", "Message", "Channel Created", "Reaction Added", and many others. The node will trigger when any of the selected events occur. |
| Regex Pattern | A regular expression pattern to match against incoming Slack messages. Capture groups can be used to extract parts of the message for use in the workflow. This applies only if the "message" event type is selected. |
| Regex Flags | Flags for the regular expression, such as g for global matching or i for case-insensitive matching. These modify how the regex pattern is applied to incoming messages. |
Output
The node outputs JSON data representing the Slack event payload whenever a subscribed event occurs and matches the optional regex filter (for messages). The output JSON includes:
body: The full raw event body received from Slack.payload: The specific payload related to the event (e.g., message content, action details).context: Contextual information provided by the Slack Bolt framework.event: The Slack event object itself.
If the event involves binary data (not typical for most Slack events), it would be included accordingly, but this node primarily deals with JSON event data.
Dependencies
- Requires a Slack app configured with Socket Mode enabled.
- Needs credentials including a bot token, signing secret, and app-level token for authentication.
- Uses the official Slack Bolt SDK for Node.js to connect and listen to Slack events over WebSocket.
- Requires proper OAuth scopes and event subscriptions configured in the Slack app to receive the desired events.
Troubleshooting
Common issues:
- Incorrect or missing Slack credentials will prevent connection to Slack’s Socket Mode.
- Selecting event triggers not subscribed to in the Slack app configuration will result in no events being received.
- Invalid regex patterns or flags may cause runtime errors or no matches.
- Network connectivity issues can disrupt the WebSocket connection to Slack.
Error messages:
- Errors starting or stopping the Slack app instance are logged; ensure credentials and network access are correct.
- Regex compilation errors should be checked by validating the pattern and flags syntax.
- If no events are triggering, verify that the Slack app has the necessary event subscriptions and permissions.