Build a Slack Bot with Claude Code
Create an intelligent Slack bot that responds to commands, processes messages, and integrates with your team's workflow.
Slack bot architecture and setup
A Slack bot receives events from Slack (messages, commands, reactions), processes them, and sends responses. The modern approach uses the Bolt framework from Slack, which handles authentication, event routing, and message formatting. Create a Slack app at api.slack.com/apps. You will need a Bot Token (for sending messages) and a Signing Secret (for verifying requests). Ask Claude Code: "Create a Slack bot using the Bolt framework for Node.js. Set it up with Socket Mode for development so I do not need a public URL yet. The bot should respond to a /summarise slash command and should also reply when mentioned in a channel."
Adding intelligence with the Anthropic API
A bot that echoes text is boring. Let us make it smart. Ask Claude Code: "Integrate the Anthropic API into the Slack bot. When the bot receives a /summarise command with a URL, it should fetch the page content, summarise it using Claude, and post the summary as a threaded reply. When the bot is mentioned in a channel, it should read the last 20 messages in the thread and provide a helpful response." Claude Code will add the AI integration, handle Slack's message formatting, and manage the API calls with proper error handling.
Slash commands, modals, and interactive messages
Go beyond basic replies. Ask Claude Code: "Add a /standup slash command that opens a Slack modal with three text inputs: what I did yesterday, what I am doing today, and any blockers. When submitted, post a formatted standup summary to the #standups channel." Claude Code will create the modal, handle the submission, format the message with Slack's Block Kit, and post to the channel. This pattern — command, modal, formatted output — is the foundation for sophisticated Slack integrations.
Deploying the bot to production
Socket Mode works for development but not production. Switch to HTTP mode. Ask Claude Code: "Convert this Slack bot from Socket Mode to HTTP mode for deployment on Railway. Add a health check endpoint. Use environment variables for all secrets. Add a Dockerfile." Deploy to Railway (or any Node.js host). Update your Slack app's Event Subscriptions URL to point to your deployed bot. The bot is now always-on and responding to your team's messages.
AI Integrations
This guide is hands-on and practical. The full curriculum covers the conceptual foundations in depth with structured lessons and quizzes.
Go to lesson