
AI Automation
AI-Powered Slack Bot with Dynamic Knowledge & Actions
AI Automation
AI-Powered Slack Bot with Dynamic Knowledge & Actions
This project is a comprehensive AI-driven Slack bot built on n8n, designed to function as an intelligent and adaptable conversational agent within Slack workspaces. It integrates advanced AI models (OpenAI) with persistent memory (Postgres) and a vector-based knowledge retrieval system (Supabase Vector Store) to understand user inputs, manage information, and execute real-world actions across documents and databases. The system intelligently routes incoming Slack events (verification challenges, slash commands, and messages) through a sophisticated dual-agent architecture, where a main AI agent delegates specialized tasks to a tool agent capable of vector search, document retrieval, and SQL query execution.

- 1Receive Slack Events - The workflow is initiated when Slack sends HTTP POST requests to the Webhook, triggered by user interactions (messages, slash commands) or system events (verification challenges)
- 2Route by Request Type - The "Request Type" node (rules-based router) categorizes incoming Slack requests into three distinct paths: Verification (for Slack's URL verification), Command (for slash commands like /ask), or Message (for regular user messages)
- 3Handle Verification & Commands - Verification requests receive immediate responses to validate the webhook. Slash commands trigger dedicated response handlers that post replies and start new message threads in Slack
- 4Process User Messages - Message events are filtered through "User | Bot" to distinguish user messages from bot responses, then pre-processed by "Edit Fields" to prepare data for AI processing
- 5Engage Main AI Agent - The prepared message is fed to the central "AI Agent," which serves as the primary reasoning engine. It uses an "OpenAI Chat Model" for natural language understanding and "Postgres Chat Memory" to maintain persistent conversational context across interactions
- 6Delegate to AI Agent Tool - When complex actions are needed, the main AI Agent invokes the "AI Agent Tool," a specialized secondary agent with its own OpenAI model and Postgres memory, designed to execute specific operations
- 7Execute Specialized Actions - The AI Agent Tool can perform three types of operations: (a) Query Supabase Vector Store with OpenAI embeddings for semantic search and RAG, (b) List and retrieve file contents from documents, and (c) Execute SQL queries directly in Postgres for structured data access
- 8Synthesize Response - The main AI Agent combines its reasoning, conversation memory, and retrieved information from tools to formulate an intelligent, context-aware response
- 9Reply in Slack - The final response is sent back to Slack via the "Reply" block, appearing as a message in the appropriate channel or thread, completing the conversational loop





- Intelligent & Context-Aware Conversations - Leverages advanced AI models and persistent Postgres memory for natural, context-aware interactions that remember past conversations
- Dual-Agent Architecture - Main AI agent handles reasoning and conversation, while specialized tool agent executes complex operations (vector search, document retrieval, SQL queries)
- Dynamic Knowledge Retrieval - Integrates Supabase Vector Store with OpenAI embeddings for efficient semantic search and Retrieval Augmented Generation (RAG)
- Multi-Modal Data Access - Can directly query structured data in PostgreSQL, retrieve content from documents, and perform semantic search across vector embeddings
- Smart Request Routing - Intelligently handles Slack's verification challenges, slash commands, and regular messages through dedicated processing paths
- Seamless Slack Integration - Native Slack bot functionality with thread management, real-time responses, and natural conversation flow
- Scalable & Extensible - Built on n8n, allowing for easy expansion with new integrations, tools, and custom logic


🔗 Webhook Trigger
The entry point for Slack events, accepting incoming HTTP POST requests from Slack's Event API. This webhook receives all Slack interactions including messages, slash commands, and verification challenges, making it the crucial gateway for real-time integration with the AI conversational agent.


🔄 Request Type Router
A rules-based routing node that intelligently categorizes incoming Slack requests into three distinct paths: Verification (for Slack's webhook URL validation), Command (for slash commands that trigger immediate responses and thread creation), and Message (for regular user messages that require AI processing). This ensures each request type is handled by the appropriate processing logic.


💬 Slack Reply
Providing the AI agent with Slack's voice, enabling the agent to communicate directly within Slack channels and threads. It takes the AI's generated response and posts it as a message, facilitating real-time, interactive conversations and actions within the Slack environment. For slash commands, it also initiates new message threads to keep responses organized.


💾 Supabase Vector Store
the workflow's intelligent knowledge base, efficiently storing and retrieving vector embeddings, generated by OpenAI, to enable semantic search and context-aware information retrieval for advanced AI applications.


🧠 Main AI Agent with Persistent Memory
The central brain of the workflow, combining an OpenAI chat model for intelligent reasoning and natural language understanding, a Postgres database for persistent conversational memory, and a connection to specialized tools. This main agent understands complex requests, maintains context across conversations, and intelligently delegates tasks to the AI Agent Tool when specialized operations are needed.


🛠️ AI Agent Tool (Specialized Operations)
A specialized secondary AI agent that executes complex operations on behalf of the main agent. Equipped with its own OpenAI chat model and Postgres memory, it provides three powerful capabilities: (1) Semantic search via Supabase Vector Store with OpenAI embeddings for RAG, (2) Document listing and content retrieval from files, and (3) Direct SQL query execution in Postgres for structured data access. This dual-agent architecture allows the main agent to focus on conversation while delegating technical operations.
n8n Workflow Engine
The core automation platform orchestrating the entire conversational agent, providing visual workflow design and seamless integration between all components.
OpenAI (Chat Models + Embeddings)
Provides the foundational AI intelligence for natural language understanding, reasoning, response generation, and creating vector embeddings for semantic search.
PostgreSQL
Serves as the persistent memory store for maintaining conversational context and for structured data management, enabling the AI to remember past interactions and query databases.
Supabase Vector Store
A dedicated vector database for storing and retrieving semantic embeddings, crucial for Retrieval Augmented Generation (RAG) to enhance the AI's knowledge base.
Slack
The communication platform where the AI agent operates, receiving events via webhooks and responding to users through channels, DMs, and threads. Handles verification, slash commands, and message events.
Webhook
The primary entry point for the workflow, enabling real-time integration by accepting HTTP POST requests from Slack's Event API to trigger the AI agent.
n8n Workflow Engine
The core automation platform orchestrating the entire conversational agent, providing visual workflow design and seamless integration between all components.
OpenAI (Chat Models + Embeddings)
Provides the foundational AI intelligence for natural language understanding, reasoning, response generation, and creating vector embeddings for semantic search.
PostgreSQL
Serves as the persistent memory store for maintaining conversational context and for structured data management, enabling the AI to remember past interactions and query databases.
Supabase Vector Store
A dedicated vector database for storing and retrieving semantic embeddings, crucial for Retrieval Augmented Generation (RAG) to enhance the AI's knowledge base.
Slack
The communication platform where the AI agent operates, receiving events via webhooks and responding to users through channels, DMs, and threads. Handles verification, slash commands, and message events.
Webhook
The primary entry point for the workflow, enabling real-time integration by accepting HTTP POST requests from Slack's Event API to trigger the AI agent.









