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

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

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

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

  • User types slash command /ask or /another in Slack channel.
  • Slack sends POST payload to n8n Webhook node.

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.

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 Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free