Not able to connect to Slack with N8n using Socket mode as Webhook flow is not allowed in my company

Describe the problem/error/question

I am trying to connect Slack with n8n using Socket Mode since Webhook flow is not allowed in my company. However, I am facing difficulties in setting it up correctly.

What is the error message (if any)?

There is no specific error message, but Slack events are not being received in n8n.

  • n8n version: 1.80.4
  • Database: Not using SQLite
  • n8n EXECUTIONS_PROCESS setting: own
  • Running n8n via: Rancher Desktop
  • Operating system: Mac Pro

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:
  • n8n version: 1.80.4
  • Database: Not using SQLite
  • n8n EXECUTIONS_PROCESS setting: own
  • Running n8n via: Rancher Desktop
  • Operating system: Mac Pro

Configure Slack Socket Mode by setting up a Slack app with necessary scopes, generate App-Level and Bot tokens, and use them in n8n’s Slack Trigger node. Ensure your app is configured to receive events in Slack.

Do you need a proper step by step solution for this?

To connect n8n to Slack using Socket Mode, follow these steps:

  1. Slack App Configuration:
  • Create a Slack app in your workspace if you haven’t already.
  • Enable Socket Mode in your app settings.
  • Generate a Bot Token (starts with xoxb-) and an App-Level Token (starts with xapp-).
  • Subscribe to necessary bot events (e.g., message.channels, message.im).
  1. n8n Slack Trigger Node Setup:
  • Add a “Slack Trigger” node to your workflow.
  • In the node settings, select “Socket” as the Authentication method.
  • Enter your Bot Token and App-Level Token.
  • Choose the events you want to listen for.
  1. Environment Variables:
  • Set these environment variables in your n8n configuration:
N8N_ENCRYPTION_KEY=your_encryption_key
SLACK_SOCKET_TOKEN=your_app_level_token
  1. Custom Function Node (Optional):
  • If the Slack Trigger node doesn’t support Socket Mode directly, you may need to implement a custom solution:
const { WebClient } = require('@slack/web-api');
const { SocketModeClient } = require('@slack/socket-mode');

const appToken = process.env.SLACK_SOCKET_TOKEN;
const socketModeClient = new SocketModeClient({ appToken });

socketModeClient.on('message', async ({ event, body, ack }) => {
  await ack();
  // Process the message event
  // You can emit this data to other nodes in your workflow
});

socketModeClient.start().catch(console.error);
  1. Testing:
  • Activate your workflow.
  • Send a message in a Slack channel where your bot is present.
  • Check n8n execution logs to verify if events are being received.
  1. Troubleshooting:
  • Ensure your Slack app has the necessary scopes (e.g., chat:write, channels:history).
  • Verify that the bot is invited to the channels you’re testing with.
  • Check n8n logs for any connection errors or warnings.
  1. Security Considerations:
  • Store sensitive tokens securely using n8n’s credentials manager.
  • Implement proper error handling and logging in your workflow.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.