Slack Conversational AI Agent with Google Gemini & Memory
Integrates with:
Overview
Unlock Intelligent Slack Assistance with this AI Agent
This n8n workflow transforms your Slack workspace into an interactive command center for AI-driven support and task automation. It listens for messages or commands sent via a configured Slack webhook, processes them using a sophisticated Langchain Agent powered by Google Gemini, and delivers intelligent, context-aware responses directly back to your Slack channels.
A key feature is its built-in conversational memory (Langchain Window Buffer Memory), allowing the AI Agent to recall previous parts of the dialogue within a session for more natural and human-like interactions. This makes it perfect for extended Q&A, brainstorming, or iterative task refinement.
Key Features & Benefits
- Direct Slack Integration: Seamlessly deploy an AI assistant within your existing Slack channels. No need for users to switch contexts.
- Google Gemini Power: Leverages Google's advanced Gemini models (e.g.,
gemini-1.5-flash-latest
) for superior natural language understanding, reasoning, and response generation. - Conversational Memory: Maintains context within a conversation (session-based, typically using Slack user or channel ID) for coherent, multi-turn dialogues.
- Customizable AI Persona: Easily tailor the AI's system prompt in the Agent node to define its role (e.g., 'YourCompany AI Expert,' 'Automation Advisor,' or 'Support Specialist') to match your brand and specific use case.
- AI-Driven Automation: Automates responses to common queries, provides information, or assists with tasks, freeing up valuable human time.
- Extensible & Adaptable: Built on n8n and Langchain, this agent can be further extended with tools, custom data sources, and more complex logic to handle a wide array of business processes.
Use Cases
- B2C E-commerce: Deploy an AI assistant in Slack to answer customer queries about products, orders, or provide support, fetched from connected systems.
- B2B SaaS: Create an internal AI helpdesk within Slack for employees to ask questions about company processes, software tools, or HR policies.
- Solopreneurs/Founders: Use as a personal AI assistant in Slack for brainstorming, drafting content, summarizing information, or getting quick answers.
- Heads of Automation: Provide an AI-powered 'Automation Copilot' in Slack to help team members with n8n workflow design, troubleshooting, or API lookups.
Prerequisites
- An n8n instance (Cloud or self-hosted).
- Google Cloud Project with the Vertex AI API enabled and billing configured.
- Credentials for Google Cloud (e.g., Service Account JSON key with appropriate IAM roles for Vertex AI usage).
- Slack App with a Bot User configured.
- Slack Bot User OAuth Token (starts with
xoxb-
) withchat:write
scope. Additional scopes likecommands
(for slash commands) or specific event scopes (e.g.,app_mention
,message.channels
for Event API) may be required depending on your Slack integration method. - A publicly accessible HTTPS URL for your n8n webhook. For local n8n instances, use a tunneling service like ngrok.io during testing.
Setup Instructions
- Download the n8n workflow JSON file.
- Import the workflow into your n8n instance.
- Configure the 'Webhook to receive message' node: a. Note the 'Test URL' (if testing locally) or 'Production URL'. This will be your 'Request URL' in your Slack App settings. b. This webhook is configured for POST requests from Slack.
- Set up your Slack App:
a. Navigate to your Slack App's configuration page (api.slack.com/apps).
b. Choose your integration method: 'Slash Commands' or 'Event Subscriptions'.
c. For Slash Commands: Create a new command, and set its 'Request URL' to your n8n webhook URL.
d. For Event Subscriptions: Enable events, provide your n8n webhook URL as the 'Request URL' (Slack will attempt to verify it). Subscribe to relevant bot events like
app_mention
ormessage.channels
under 'Subscribe to bot events'. e. Ensure your Slack App has the necessary permissions (e.g.,chat:write
). Install/reinstall the app to your workspace to apply changes and obtain the Bot User OAuth Token. - Configure the 'Google Gemini Chat Model' node:
a. In n8n, create or select your Google Cloud credentials that have access to Vertex AI.
b. Ensure the associated Google Cloud Project has the Vertex AI API enabled.
c. Select your preferred Gemini model (default is
models/gemini-1.5-flash-latest
). - Configure the 'Window Buffer Memory' node:
a. The
sessionKey
parameter is crucial for conversational context. It's pre-set to={{ $('Webhook to receive message').item.json.body.token }}
. For more reliable session tracking, modify this expression to use a unique identifier from the Slack payload, such as{{ $('Webhook to receive message').item.json.body.user_id }}
for user-specific memory or{{ $('Webhook to receive message').item.json.body.channel_id }}
for channel-specific memory. Verify the exact path from your Slack event payload. - Configure the 'Agent' node:
a. The
text
input={{ $json.body.text }}
is designed to capture the user's message from Slack. Confirm this path matches your Slack payload structure (e.g., for event subscriptions, it might be{{ $('Webhook to receive message').item.json.event.text }}
). b. Customize thesystemMessage
to define the AI's persona, role, and any specific instructions (e.g., "You are Effibotics AI, an expert in business process automation."). - Configure the 'Send response back to slack channel' node:
a. Add your Slack API credentials (select or create one using the Bot User OAuth Token from step 4e).
b. The
channelId
expression={{ $('Webhook to receive message').item.json.body.channel_id }}
should correctly extract the originating channel ID. Verify this against your Slack payload. c. Customize thetext
field for the bot's response format. You can also adjustsendAsUser
to control the bot's display name in Slack. - Activate the workflow in your n8n instance.
- Test the integration by triggering the AI Agent from Slack according to your setup (e.g., using the slash command, mentioning the bot, or sending a message in a subscribed channel).
Want your own unique AI agent?
Talk to us - we know how to build custom AI agents for your specific needs.
Schedule a Consultation