Build a powerful, context-aware Slack AI chatbot using this advanced n8n workflow. Integrate OpenRouter, persistent Postgres memory, and a 'thinking' UI for superior user experience. Get this complete n8n template now.
Download this n8n workflow template and start using it instantly.
Developers and Integrators: Seeking advanced n8n templates for custom Slack apps.
Team Managers: Who need a powerful, private AI assistant integrated directly into their collaboration platform.
Automation Specialists: Interested in utilizing LangChain n8n node functionality for complex AI agents.
Anyone: Looking for an example of a full conversational loop in an n8n workflow using external memory.
This robust n8n workflow template solves the challenge of creating a truly conversational AI assistant within Slack. Unlike simple notification bots, this architecture utilizes a dedicated Postgres database for persistent chat memory, ensuring the AI remembers previous statements within a specific Slack thread. The automation starts with an n8n trigger listening for messages. Before processing, it sends an immediate HTTP request to Slack to display a "thinking..." status, significantly enhancing the user experience. This advanced n8n workflow leverages the LangChain Agent n8n node, powered by OpenRouter, providing excellent flexibility in LLM choice and reliable performance. This is a crucial n8n workflow for teams needing reliable, stateful AI integration using OpenRouter and Postgres to manage context.
The entire process is initiated by the "On Message Received" n8n trigger, which listens for incoming Slack messages. The flow immediately moves to the "Check If User" n8n node, which filters out messages from bots, ensuring the text field exists, and confirming the event type is a message, effectively preventing feedback loops.
If the message is valid, the n8n workflow executes two paths concurrently:
thread_ts (thread timestamp) as the session key, guaranteeing that the AI only uses the context of the current thread for its response.Once the AI Agent calculates the optimal output, the n8n workflow concludes by running the "Send Reply" Slack n8n node, which posts the full, markdown-formatted AI response back into the original Slack thread.
chat_histories table if it doesn't exist.chat:write and chat:write.customize scopes, needed to interact with the special assistant.threads.setStatus API endpoint. On Message Received (Slack Trigger): This is the starting n8n trigger. It listens for message events in a specified channel ID. This crucial n8n trigger ensures the workflow only runs when relevant activity occurs.
Check If User (If): A core logic n8n node that filters the incoming data. It validates that the message did not come from a bot (botid is null) and is a standard message type, protecting the n8n workflow from recursive calls.
Set Thinking Status (HTTP Request): This n8n node makes a POST request to slack.com/api/assistant.threads.setStatus. It provides immediate visual feedback to the user by setting the thread status to 'is thinking...'.
AI Agent (LangChain Agent n8n node): The brain of the operation. It receives the input text and is configured with a system message emphasizing helpful, markdown-formatted responses. This n8n node orchestrates the LLM and memory components.
OpenRouter Chat Model (LangChain LM n8n node): Provides the language model capabilities to the Agent. Using OpenRouter allows access to various state-of-the-art models.
Postgres Chat Memory (LangChain Memory n8n node): Handles statefulness. It uses Postgres to store conversation history, keyed by the Slack message's threadts. This ensures context is retained between messages within the same thread, a key feature of this n8n template.
$json.output) back to the originating channel, specifying the thread timestamp to keep the conversation structured.Create a robust, time-to-live (TTL) aware data cache using n8n Data Tables. This reusable n8n workflow template handles reads, writes, and automated cleanup.

Deploy an advanced n8n workflow for a stateful Telegram chatbot using GPT-4o-mini and Google Sheets for persistent session management, summarization, and contextual Q&A.

Use this comprehensive n8n workflow to build a dynamic Retrieval-Augmented Generation (RAG) system. Sync Google Drive files to Supabase vectors using the Google Gemini n8n node.

Create a powerful, scalable Slack chatbot using this robust n8n workflow. Integrate GPT-4o for real-time customer support responses and automated AI interactions.

👋 Hi, I'm James. I run an AI automation agency focused on building small, focused workflows that have a direct and measurable impact on business growth or optimization.







































