- The commands Slash and bots allow you to run actions and automate flows without leaving Slack.
- Respond to slash in less than 3 seconds or use response_url; choose in_channel or ephemeral as appropriate.
- Bolt, Socket Mode, and good security practices help build reliable and scalable bots.
- ChatOps centralizes conversation and operations, accelerating deployments, support, and incidents.
If you work at Slack, you've probably noticed that the platform isn't just chat: it's a foundation for automate tasks, centralize alerts and execute actions without leaving the conversation. That's where slash commands and smart bots come in: two pillars that, when well combined, turn Slack into a true operational console.
In the following lines you will find a complete —and very practical— guide to master Custom slash commands, incoming webhooks, and bots, connect them with your tools (CI/CD, CRM, calendars, WordPress, etc.) and take your ChatOps to the next level with ideas, code and best practices.
Slash Commands and Bots in Slack: What They Are and Why They Matter
A slash command is a user-initiated instruction (e.g., /deploy staging) that triggers an HTTP call to your server with context data (team, channel, user, text) and waits for a response. Bots, on the other hand, are applications that listen events such as messages, mentions or interactions to respond and execute workflows programmatically.
What do we gain from this? Less context switching, more traceability, and seamless collaboration: you can create tasks, launch a deployment, view a report or open a modal without leaving the channel. If this sounds like ChatOps to you, you're on the right track.
How a slash command works inside
When someone types a command (for example, /test hello!), Slack sends an HTTP request to the URL you've configured in your app. This request arrives with key context parameters. A typical example of the fields you'll receive:
token=gIkuvaNzQIHg97ATvDxqgjtO
team_id=T0001
team_domain=acme
channel_id=C2147483705
channel_name=general
user_id=U2147483697
user_name=admin
command=/test
text=hola!
response_url=https://hooks.slack.com/commands/1234/5678
With that information you can validate the call (with the token or signature), decide what to do depending on the channel or user and, above all, respond. There are two options: respond to the request itself in less than 3 seconds or return an empty 200 and then reply to the response_url (asynchronous mode) if the process takes a while.
The response is JSON and can be public to everyone in the channel or visible only to the person who issued the command. Key fields are text, response_type (in_channel or ephemeral) and the attachments/blocks If you want to enrich the message. A simple example:
{
"text": "¡Hola Mundo!",
"response_type": "in_channel",
"attachments": [
{ "text": "Adjunto de prueba" }
]
}
If your logic goes over 3 seconds, nothing happens: return a 200 without a body and use the response_url when you have the result. This prevents Slack from showing an error to the user who ran the command, keeping a fluid experience.
Incoming Webhooks: Send messages to Slack whenever you want
Incoming webhooks are a unique URL that you can POST JSON to post messages to a channel, even if no one has executed a command. You can define the default channel, bot name, and avatar, and override them on a per-message basis if needed.
For example, to notify that someone has rung the office bell, a simple curl pointing to the webhook with the appropriate payload. Easy to automate alerts, summaries or event notifications from your server or scripts:
curl -X POST --data-urlencode 'payload={
"channel": "#general",
"username": "ElFantasmaDeLaPuerta",
"text": "Llamaron al timbre",
"icon_emoji": ":ghost:"
}' https://hooks.slack.com/services/XXXXX/XXXXX/XXXXX
Message format? You can add titles, links, colors, images, thumbs, line breaks with \n and emojis. Slack's Message Builder helps you test designs and see how attachments will look before putting them into production.
Message design: in-channel vs. ephemeral and attachments
Field response_type decide the visibility: in_channel for everyone or ephemeral for the user who launched the command. Attachments provide color, image, and links, and you can include anything from a title_link until a image_url to enrich the experience.
Inspiring example of attachment with image and color: title, link to resource, image_url and the sidebar color. Add \\n to force line breaks and combine blocks if you want something more modern than attachments, while maintaining a consistent look with your brand.
Apps, bots, and Slackbot: differences and when to use each one
A Slack app is a container for functionality: slash commands, webhooks, events, and botsA bot is a programmatic user that posts messages and reacts to events. Your app can include one or more bots, or even none at all if you only use webhooks and slash commands.
Extra benefit: Packaging everything into one app helps you save on the integration limit of the free plan (each app consumes a single “slot” even though it includes slash, webhooks and bot), and makes it easy for other teams to install the solution in their workspaces.
Installing and Discovering Bots: Where to Find Them and How to Add Them
To install bots you can go to Application Directory from Slack, search for the tool (Asana, Zoom, Trello, Salesforce, Google Drive…) and click “Add to Slack.” The browser will ask for permissions, and once authorized, the bot will be ready to use in your workspace.
From Slack, in the sidebar, scroll down to “Apps” and tap “Add Apps” to find the one you need. Once installed, configure permissions, channels, and notification options so the bot can start working with you in seconds.
ChatOps in Slack: Chat-Based Operations with AI and Automation
ChatOps is about carrying commands, flows and alerts to the chat where the conversation is already taking place. It was born in the DevOps community (Hubot popularized the concept) and today the Generative AI allows for more natural interactions: asking for diagnoses in natural language or generating commands from a simple sentence.
Clear benefits: less fragmentation between tools, better traceability and faster response in the event of incidents. There are teams that report an average reduction of 21% in There resolution thanks to coordinated actions from the channel itself.
Use cases and real-life examples
With bots and slash commands, you can automate everything from reminders to deployments. Some useful ideas that many people in Slack are already using to improve the productivity and collaboration:
- Knowledge management with Guru: search your internal database and direct integration into Slack to reply without leaving the chat.
- Zoom video calls: Create meetings with /zoom and share whiteboards with previews in the channel.
- Projects with Trello or Asana: Paste a link and you'll see members, comments, and status; create tasks with a slash command.
- Onboarding with Aloha: automatic introductions and contextual guidance for new hires.
- Automations with Zapier: Bring calendar events, leads, or posts into a channel and trigger flows in minutes.
In addition, you can set up flows of quick approvals, daily check-ins with Geekbot-like bots, link collection with Paperbot, or repo notifications with GitHub to keep technical activity on your engineering channel.
Building Your Bot with Node.js and Bolt: From Zero to Responding in Slack
Creating an app with a bot is much easier with Bolt for JavaScript, the official Slack framework. Typical steps: go to api.slack.com, create an app from scratch, name and choose your workspace, select which will have a bot, and review the OAuth permissions (e.g., chat:write to publish).
Install the app in the workspace, copy the Bot Token (xoxb-…) and the Signing Secret from “Basic Information.” In your Node.js project, save credentials in .env and start a minimalist Bolt server that can now receive events and publish messages.
const { App } = require("@slack/bolt");
require("dotenv").config();
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
signingSecret: process.env.SLACK_SIGNING_SECRET
});
(async () => {
await app.start(process.env.PORT || 3000);
console.log("⚡️ Bot en marcha");
})();
Quick tip: use process.env.PORT for the port in deployments; don't set it manually. From here, you can add listeners for commands (app.command), messages (app.message), or UI interactions (buttons, forms).
Socket Mode: events without exposing a public endpoint
If you do not want to open an HTTP endpoint, enable Socket Mode. Generate an App-Level Token (xapp-…), add the connections:write and authorizations:read scopes, enable the mode in your app, and configure Bolt to use WebSockets.
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
signingSecret: process.env.SLACK_SIGNING_SECRET,
socketMode: true,
appToken: process.env.APP_TOKEN
});
With this, Slack will connect to your app via WebSockets and you will receive real-time events No tunnels or proxies. Ideal for local development and for apps that rely heavily on rapid interactions.
Slash commands done right: validation, ACK, and rich responses
Define your commands in the Slack console (Slash Commands), assign a URL or use Socket Mode, and listen with app.command(«/your_command», …). Acknowledge receipt with ack() in less than 3 seconds and then respond with say() or via the response_url if the job takes time.
Think about UX: mix messages ephemeral to request parameters or confirm actions and in-channel messages to announce results to the team. Add blocks/attachments with buttons to rollback, assign, approve or open manners.
Advanced example with external API: Kinsta + Slack
A very useful use case is to connect Slack with the Kinsta API to manage WordPress sites from the chat: check the status of an operation, clear the cache or restart the PHP engineThe Bolt app receives the command and makes REST calls authenticated with a token.
Start by saving the API base and headers with your KINSTA_API_KEY in variables:
const KinstaAPIUrl = "https://api.kinsta.com/v2";
const getHeaders = { Authorization: `Bearer ${process.env.KINSTA_API_KEY}` };
const postHeaders = {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.KINSTA_API_KEY}`
};
To get the environment ID from the site name (command /environment_id [SiteName]), first list the company's sites, locate the one that matches, and then request its environments:
async function getAllSites() {
const q = new URLSearchParams({ company: process.env.KINSTA_COMPANY_ID });
const r = await fetch(`${KinstaAPIUrl}/sites?${q}`, { headers: getHeaders });
return r.json();
}
async function getEnvironmentId(siteId) {
const r = await fetch(`${KinstaAPIUrl}/sites/${siteId}/environments`, { headers: getHeaders });
return r.json();
}
Then you implement operational commands: /clear_site_cache [environment_id] y /restart_php_engine [environment_id], which are simple POSTs:
async function clearSiteCache(environmentId) {
const r = await fetch(`${KinstaAPIUrl}/sites/tools/clear-cache`, {
method: "POST",
headers: postHeaders,
body: JSON.stringify({ environment_id: environmentId })
});
return r.json();
}
async function restartPHPEngine(environmentId) {
const r = await fetch(`${KinstaAPIUrl}/sites/tools/restart-php`, {
method: "POST",
headers: postHeaders,
body: JSON.stringify({ environment_id: environmentId })
});
return r.json();
}
And finally, the status of an operation with /operation_status [operation_id], which queries the operations endpoint to report progress back to the channel in real time.
Events and Conversational UX: Beyond Commands
Bots don't live on slash alone. Subscribe to them. message events to respond to keywords, listen for @mentions, and turn an emoji reaction into a trigger (e.g., adding :eyes: to claim a task).
A powerful pattern is to couple it with RAG (Retrieval Augmented Search): your bot queries the knowledge base and answer with the most relevant snippet and link, cutting down on the “where’s the link to…?” chatter.
Good practices: safety, performance and care
Request only the minimum scopes (e.g., chat:write, reactions:read) and avoid granting excessive access. Protect OAuth tokens and signing secrets, use periodic rotation, and store everything in environment variables (.env), never in the repository.
Logs input, output, and errors for debugging, but avoids saving complete medical records from Slack unnecessarily. If you need memory, use storage short-term session. Be careful with sensitive data and retention policies.
Design fallback messages: if something fails, return a “I didn't understand that, try 'help'” instead of silence. And don't forget to ack() quickly; if the operation is cumbersome, respond later with the response_url webhook.
Take care of the design: use attachments or blocks, \\n for line breaks, icon_emoji or icon_url for the avatar, and choose either in_channel or ephemeral depending on the moment. Pin a message with available commands or create a Canvas with quick help.
ChatOps in action: deployments, issues, and support
Imagine /deploy staging and the bot showing progress and logs in real time, with buttons to abort or promote to production. Everything remains in the thread, ready for auditing and cross-learning.
In incidents, the bot publishes alerts with key data and shortcuts to escalate, diagnose, or rollbackConversation provides shared context and speeds up responses without searching for "where is what happening."
In support, automate frequent responses, route requests to the right team, and connect your CRM to view customer data. The result: less downtime and more focus on solving what is important.
How to get started with your own slash/bot step by step
1) Create the app at api.slack.com, 2) add a bot and basic scopes (chat:write, commands), 3) install the app and copy xoxb and Signing Secret, 4) set Socket Mode if you want to avoid public endpoints, 5) define one or two commands with useful cases (e.g., /meme, /deploy), 6) publish test messages with an incoming webhook.
When it's working, document commands and examples in a pinned message or in the App Home (enable them to be able to write by DM). Train your team, gather feedback, and prioritize what to automate next.
The combination of slash commands, webhooks, and bots turns Slack into an operational platform where conversation and execution They go hand in hand: you can trigger tasks, consult external services, coordinate responses, and document everything in one place. With a well-designed app, careful security, and a touch of ChatOps, your team will gain agility, visibility, and less chaos without leaving the channel.
Passionate writer about the world of bytes and technology in general. I love sharing my knowledge through writing, and that's what I'll do on this blog, show you all the most interesting things about gadgets, software, hardware, tech trends, and more. My goal is to help you navigate the digital world in a simple and entertaining way.