Slack AI ChatBot : Context-Aware, Replies to Mentions AND also DMs

Go to Workflow
5 views
Built by Theo Marcadet Theo Marcadet
Created on June 13, 2026

Description

Click here to access this Workflow for free.

Get your own custom ChatGPT inside your Slack Workspace

Description
This n8n workflow enables a fully autonomous AI assistant within your Slack Workspace. It listens for both public mentions and direct messages (DMs), and replies in real-time using a large language model (OpenAI's GPT-4o by default). The assistant can dynamically fetch previous messages for better context, providing smart, coherent, and personalized responses.

🔧 Key Features

Dual Trigger**: Reacts to both public bot mentions and private DMs.
Context-Aware AI**: Dynamically fetches the last 20 messages from either public or private conversations.
Smart Routing**: Replies either in the original public channel or via DM, depending on where the message came from.
Custom Prompting**: Easily modify the system prompt to define the AI’s tone, behavior, and personality.
Fully Autonomous**: No manual intervention required — the bot always replies instantly.

✅ Requirements

An operational n8n instance.
A Slack workspace (you can create one for free here)
A Slack account with Admin or Owner privileges (required to install apps)

🧰 Setup Instructions

Slack Bot Setup
Create a Slack App with the necessary permissions and configurations
> You will find in the next step a complete tutorial to craft your own bot with the right confirguration and permissions for this workflow to work
Set your Slack bot token in n8n's credential manager.

🤖 How It Works

When a public mention is detected, the bot replies directly in the channel, referencing the original message.
When a DM is received, it responds privately.
The AI uses a tool to read the latest 20 public or private messages to build accurate context before replying.

🛠 Customization Options

Change LLM**: Swap out OpenAI with any LLM that has an API.
Edit Prompt Behavior**: Modify the system prompt to control tone and personality.

If you just need a tutorial on setting up your Slack bot, be my guest ➡️ Here

And if you need any help, or have any question, feel free to come discuss about it on Telegram

Nodes Used (7)

AI Agent
@n8n/n8n-nodes-langchain.agent
Embeddings OpenAI
@n8n/n8n-nodes-langchain.embeddingsOpenAi
OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi
Pinecone Vector Store
@n8n/n8n-nodes-langchain.vectorStorePinecone
Simple Memory
@n8n/n8n-nodes-langchain.memoryBufferWindow
Slack
n8n-nodes-base.slack
Think Tool
@n8n/n8n-nodes-langchain.toolThink