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
/askor/anotherin 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
- Download the workflow file using the Download button on this page.
- Go to your n8n editor where you want to add the workflow.
- Click “Import from File” and upload the downloaded workflow.
Configure Credentials
- Add your Slack API credentials to the Slack node.
- Enter your OpenAI API Key with GPT-4o-mini access in the OpenAI Chat Model node credentials.
- Check that Slack slash commands in your Slack app point to the Webhook node URL.
- Update IDs or channel references if needed to match your Slack workspace.
Test the Workflow
- Trigger a command in Slack, for example:
/ask What is AI? - Make sure the AI response appears in the Slack channel quickly.
Activate Workflow
- Activate the workflow inside n8n to run continuously.
- 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.
