Blog · · 4 min read
How to build a Slack AI assistant with n8n (mentions, threads and memory)
A step-by-step guide to a Slack bot that replies with AI in n8n: Trigger, anti-loop filter, AI Agent with memory and threaded replies. No coding needed.

Your team already lives in Slack. Customer questions, internal “where’s the link for…?”, and someone has to answer them by hand. An AI assistant in the same channel can handle the routine ones and leave you only what matters.
In this guide you’ll build an n8n workflow that listens for mentions or direct messages, ignores the bot’s own messages (so it doesn’t loop), thinks with an AI Agent and replies in the thread. Same idea as Telegram or WhatsApp, adapted to Slack.
What you’ll build
A five-part workflow:
- Slack Trigger: receives bot mentions or direct messages (DMs).
- IF: drops messages written by the bot itself.
- Edit Fields (Set): puts the text, channel and user into clear fields.
- AI Agent + Memory: reads the message, keeps context and prepares the reply.
- Slack (Send Message): answers in the channel or in the thread.
If you’ve already built a Telegram AI bot or a WhatsApp AI agent, you’ll recognise the pattern: trigger → agent → reply. Only the Slack nodes change.
Step 1: Slack app and bot token (high level)
You need a Slack app in your workspace with a bot token (the one that starts with xoxb-) and the minimum permissions to read messages and post replies. In Slack’s app console you create the app, enable the bot, choose the events you want (for example mentions and direct messages) and copy the token.
In n8n, create a Slack credential with that token. You don’t need to invent OAuth screenshots: what matters is that the bot can receive what people write to it and send messages back to the same channel. Once that’s done, n8n’s Slack Trigger uses that credential.
Tip: start in a private test channel. That way the rest of the team doesn’t see your experiments while you tune the agent’s instructions.
Step 2: Slack Trigger (mentions or DMs)
Add a Slack Trigger node. Configure it to fire when someone mentions the bot (@your-assistant) or sends it a direct message. Those two paths are usually the safest: you don’t react to every channel message, only when you’re called.
Test the trigger once: mention the bot with a short phrase and check that n8n receives the text, channel ID, user ID and, if relevant, the thread ID.
Step 3: ignore the bot’s own messages
If the bot replies in the same channel and the trigger also listens to those messages, you can create a loop: the bot keeps answering itself.
After the trigger, add an IF node. A typical condition is checking whether the message came from the bot (for example, whether the message user matches the bot’s ID, or whether the message is marked as from a bot).
- True branch (it’s the bot): do nothing — or stop the workflow there.
- False branch (it’s a person): continue to the agent.
This filter is mandatory. Without it, a small glitch can flood the channel with automatic replies.
Step 4: prepare the data and the AI Agent
On the people branch, add Edit Fields (Set) and create clear fields, for example:
text: the message contentchannel: the channel IDuser: the ID of who wrotethread: the thread ID if the message was already in a thread (or the message ID if you want to open a thread)
Connect an AI Agent node. Attach your language model, clear instructions and a Memory keyed by channel + user (for example channel_user). That way the bot remembers that person’s conversation in that channel, without mixing chats from different people.
For the instructions, a good starting point is the customer service AI agent prompt. Adapt it for Slack: short tone, reply in the language of the message, and a rule like “If you’re not sure, say so and offer to hand off to a person.”
Step 5: reply in Slack (preferably in a thread)
Finish with a Slack node using Send Message (or the equivalent send-message operation in your node version). Use the channel from the previous step and, when it makes sense, the thread:
- If you were mentioned inside a thread, reply in that same thread.
- If you were mentioned in the main channel, it’s usually cleaner to open a thread under that message instead of filling the channel.
That way the rest of the team only follows the thread if they care. If the question is sensitive or the agent can’t resolve it, hand off to a person: see how to hand an AI agent off to a human.
Cost, privacy and errors
- Cost: every message goes through the AI model (and through n8n if you’re on a paid plan). Spend depends on volume and model; check current pricing on your AI provider’s site and on n8n’s. There’s no single number that fits everyone.
- Privacy: Slack can hold customer or internal data. Say in your privacy policy that you use an external service to process messages, limit who can mention the bot, and don’t keep conversations longer than needed.
- Errors: turn on Retry On Fail on the model or agent node, and set up an alert if something breaks, as in n8n error handling: alerts and retries. A short silence is better than a loop of broken messages.
Ideas to take it further
- Same logic on other channels: Telegram and WhatsApp with the Telegram AI bot and WhatsApp AI agent guides.
- Knowledge base: connect your business documents to the agent (RAG) when you have FAQs or internal PDFs.
- A daily summary of what the bot answered with the daily AI summary report.
Start with ready-made templates
If you’d rather skip the base setup, download the free WhatsApp agent or check out the AgentKiosk pack with 8 agents ready to import into n8n — the trigger → agent → reply pattern is the same as on Slack.


