AIFlowPost

How to Build a Slack Bot With n8n (Tested)

Updated 2026-10-08 · 998 words

How to Build a Slack Bot With n8n (Tested) — AIFlowPost cover

This page may contain affiliate links. If you buy through them we may earn a commission at no extra cost to you.

Direct answer: building a Slack bot in n8n takes four pieces: a Slack app with Event Subscriptions and the right OAuth scopes, a bot token added as an n8n credential, a Slack Trigger node to receive events, and a Slack node to send replies. A basic bot that replies to direct messages is live in about twenty minutes; the setup time mostly goes into Slack's own app console, not n8n. The step that trips up almost everyone is Event Subscriptions verification, which fails silently if your webhook isn't reachable over HTTPS the moment Slack checks it.

Step 1: Create the Slack app and set OAuth scopes

Go to api.slack.com/apps and create a new app "from scratch," choosing the workspace you'll test in. Under OAuth & Permissions, add Bot Token Scopes for what the bot needs to do: chat:write to send messages, channels:history or im:history to read the messages it should respond to, and app_mentions:read if it should react to @mentions specifically. Install the app to your workspace from this page, which generates the bot token n8n will use.

Scope conservatively at first. A bot with every history-reading scope enabled in a busy workspace will see, and can be triggered by, far more traffic than you want while you're still debugging logic.

Scope What it lets the bot do
chat:write Send messages as the bot
channels:history Read messages in public channels
im:history Read direct messages
app_mentions:read React only when @mentioned

Step 2: Add the Slack credential in n8n

In n8n, create a new Slack credential using the Bot Token (starts with xoxb-) from Step 1. n8n validates the token immediately against Slack's API, confirming the connection before you build anything around it. This one credential covers both the trigger and the send nodes.

Step 3: Enable Event Subscriptions and add the Slack Trigger node

Back in the Slack app console, open Event Subscriptions and toggle it on. Slack asks for a Request URL here, this is where you paste your n8n Slack Trigger node's webhook URL, generated once you add that node to a workflow and copy its test or production URL. Slack sends a verification request to that URL immediately, and the workflow must be active (or at least listening in test mode) at that exact moment for verification to succeed.

Under "Subscribe to bot events," add message.channels for public channel messages, message.im for direct messages, or app_mention to only fire on @mentions. Save, and Slack starts delivering matching events to your n8n webhook.

If you're self-hosting n8n, this is where the HTTPS requirement becomes non-negotiable: Slack refuses to verify a Request URL without a valid TLS certificate. Our guide to using webhooks in n8n covers securing and testing a webhook endpoint in more depth, and our guide to self-hosting n8n covers the reverse-proxy and certificate setup if you haven't done that yet. n8n Cloud users skip this step entirely.

Step 4: Build the reply logic

Connect the Slack Trigger to a Slack node (Send a Message), set the channel to {{ $json.event.channel }} and the text to a fixed or templated reply. This echo-bot version is enough to confirm the full pipeline works before adding real logic, and it's worth testing in isolation before moving on.

For keyword-based routing, insert an IF or Switch node between the trigger and the reply. For an agent that actually reasons about open-ended messages instead of matching keywords, replace that step with an AI Agent node instead, the same pattern we cover in detail in our guide to building an AI agent in n8n: connect an LLM credential, write a specific system prompt, and pass {{ $json.event.text }} as the agent's input.

Step 5: Filter out the bot's own messages

This is the pitfall specific to Slack bots: by default, a bot subscribed to message.channels or message.im events will also receive the messages it sends itself, since those are message events in the same channel. Without a filter, this creates an infinite reply loop. Add an IF node right after the trigger that checks {{ $json.event.bot_id }} is empty, Slack sets this field on messages sent by any bot, including yours, and only continue to the reply logic when it's blank.

Step 6: Test in a private channel first

Create a private test channel or use direct messages rather than testing in a live team channel. Watch the n8n execution log as you send messages; a failed node or an unmet filter condition shows up immediately there, faster than guessing from Slack's side. Once the bot behaves correctly in isolation, invite it to the real channel.

Common pitfalls

The bot-loop issue from Step 5 is the one that actually embarrasses people in a shared channel, test the filter before going anywhere near a real team channel. Event Subscriptions verification failing silently is the second most common issue, re-check that your workflow was active and your URL was reachable at the moment you saved the Request URL in Slack's console; a workflow activated after a failed verification attempt needs the URL re-saved to trigger a fresh check. Third, a missing OAuth scope doesn't throw a clear n8n error, the bot token still authenticates fine, it just never receives the event type you forgot to add a scope for, so a "nothing is happening" bot is usually a scopes problem, not an n8n problem.

If you want the bot to initiate messages rather than only reply, use a Schedule Trigger feeding into the Slack node instead of the Slack Trigger; Slack's bot token lets an app post into a channel proactively without needing a user to message first. For the equivalent setup on other messaging platforms, our Telegram bot with n8n guide and our WhatsApp AI agent with n8n guide follow the same trigger-then-reply pattern with platform-specific setup steps. And if you're weighing a template over a from-scratch build, our best n8n workflow templates roundup covers where to find a Slack notification starting point instead of building one from zero.

Frequently asked questions

Do I need a paid Slack plan to build a bot with n8n?

No. Slack's free tier supports custom apps, Event Subscriptions, and bot tokens with no extra cost; the free plan's limits are on message history and app integrations count, not on building your own app. Your only real cost is n8n itself if you're not already running it, and any AI model you connect.

Can the bot respond in threads instead of the main channel?

Yes. The incoming event payload includes a thread_ts field when the message is part of a thread (or you can set it to the original message's timestamp to start a new thread). Pass that value into the Slack node's 'Thread' field and replies stay contained to the thread instead of posting to the main channel.

Why isn't my n8n Slack bot receiving any events?

The most common cause is an Event Subscriptions URL that failed verification, usually because the n8n webhook wasn't reachable over HTTPS when Slack tried to confirm it, or the workflow wasn't active yet at that moment. The second most common cause is missing OAuth scopes; a bot token without the right scope for the event type you subscribed to will authenticate fine but simply never receive that event.

Can I trigger the bot with a slash command instead of a message event?

Yes, but it's a separate setup from Event Subscriptions. Slash commands are configured under their own section in the Slack app console and point to a different n8n webhook URL; the payload format also differs slightly from a standard message event, so the two aren't interchangeable without adjusting how your workflow parses the incoming data.

↑ Back to top