How to Build a Slack Slash Command AI Bot with an n8n Webhook
Wire a Slack slash command to an n8n webhook, run the text through a model, and post the answer back in channel.
A Slack slash command sends a webhook to any URL you choose. Point it at n8n, run the typed text through a model, and your team gets an AI assistant inside Slack with no extra app to install. This guide builds a /ask command end to end.
What you need
- A Slack workspace where you can create an app
- An n8n instance reachable over HTTPS
- A chat model credential in n8n
Step 1: Create the n8n webhook
Add a Webhook node with POST and path slack-ask. Slack sends slash command data as form-encoded fields, so the typed text lands in body.text and the response URL in body.response_url.
Step 2: Acknowledge within 3 seconds
Slack requires a reply within three seconds or it shows a timeout error. Add a Respond to Webhook node right away that returns a short acknowledgement, then do the AI work afterward and post the real answer to response_url.
{
"response_type": "ephemeral",
"text": "Thinking..."
}Step 3: Run the model and post back
Connect the webhook to an AI Agent node fed by body.text. Then add an HTTP Request node that POSTs the result to the captured response_url.
{
"response_type": "in_channel",
"text": "{{ $json.output }}"
}Step 4: Register the slash command in Slack
In your Slack app at api.slack.com, open Slash Commands, add /ask, and set the Request URL to your production webhook https://your-n8n.example.com/webhook/slack-ask. Install the app to the workspace.
Result: anyone in the workspace can type /ask followed by a question and get an AI answer posted right in the channel.
Watch related tutorials
32:08
21:45
34:10
26:40
32:15
40:20