Create a Slack AI Chatbot with n8n Slash Commands

Discover how to build an AI chatbot that responds to Slack slash commands using n8n automation. This workflow handles slash commands, routes queries, connects to an AI model, and sends replies seamlessly, saving you hours of manual handling and boosting Slack interaction efficiency.
webhook
switch
chainLlm
+3
Workflow Identifier: 1891
NODES in Use: Sticky Note, Webhook, Switch, Basic LLM Chain, OpenAI Chat Model, Slack
Automate Slack chatbot with n8n and OpenAI

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

What This Automation Does

This workflow in n8n catches Slack slash commands like /ask or /another.
It sends the typed question to the GPT-4o-mini AI model from OpenAI.
The AI creates a smart text reply and sends it back to the exact Slack channel.
All happens without a person needing to copy or paste answers.

This saves time, stops interruptions, and helps keep answers quick and clear in team chats.


Tools and Services Used

  • n8n: Manages workflow and nodes.
  • Slack Slash Commands: Triggers AI chat queries.
  • OpenAI GPT-4o-mini: Generates AI text replies.
  • Slack API: Sends messages back to Slack channels.

Inputs, Processing Steps, and Output

Inputs

Processing Steps

  • Webhook node receives command and payload.
  • Switch node checks which command is used.
  • Basic LLM Chain node sends text to OpenAI Chat Model node.
  • Chat Model node calls GPT-4o-mini model for response.
  • Slack node posts AI-generated reply back to original Slack channel.

Output

  • Slack channel sees instantly the AI’s answer to the user’s question.

Beginner Step-by-Step: How to Use This Workflow in n8n

Import and Setup

  1. Download the workflow file using the Download button on this page.
  2. Go to your n8n editor where you want to add the workflow.
  3. Click “Import from File” and upload the downloaded workflow.

Configure Credentials

  1. Add your Slack API credentials to the Slack node.
  2. Enter your OpenAI API Key with GPT-4o-mini access in the OpenAI Chat Model node credentials.
  3. Check that Slack slash commands in your Slack app point to the Webhook node URL.
  4. Update IDs or channel references if needed to match your Slack workspace.

Test the Workflow

  1. Trigger a command in Slack, for example: /ask What is AI?
  2. Make sure the AI response appears in the Slack channel quickly.

Activate Workflow

  1. Activate the workflow inside n8n to run continuously.
  2. Keep your n8n instance running (self-host n8n or cloud) so it can always receive Slack commands.

Common Issues and Their Fixes

Slack Command Triggers but No Response

Cause: Slack credentials missing or wrong channel ID in Slack node.

Fix: Add or fix Slack API credentials inside the Slack node. Map channel ID to $json.body.channel_id.

Basic LLM Chain Node Shows Empty Output

Cause: OpenAI model not connected or API key missing.

Fix: Confirm OpenAI API key in credentials. Link the OpenAI Chat Model node inside the Basic LLM Chain node.


Customization Ideas

  • Add more slash commands by updating the Switch node conditions.
  • Change AI model or prompt in the Basic LLM Chain node to change reply style.
  • Send AI answers to different Slack channels or users by adjusting channel properties in Slack node.
  • Use a Function node before AI processing to change questions or add info.

Summary and Outcome

→ Automates answering Slack slash commands with AI replies.
→ Reduces time spent on repeated questions.
→ Keeps Slack conversations fast and clear.
→ Allows easy updates and more commands later.
→ Runs fully inside n8n needing no manual effort after setup.

Automate Slack chatbot with n8n and OpenAI

Visit through Desktop to Interact with the Workflow.

Frequently Asked Questions

Yes. The Basic LLM Chain node can connect to different OpenAI models or custom LangChain models if set up.
Yes. Each AI response generated counts as an API call billed by OpenAI.
The Slack node posts AI-generated replies to the channel ID received from the Slack command payload.
Yes. Data passes through secure APIs and stays within the trusted n8n environment.

Promoted by BULDRR AI

Related Workflows

Automate Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.