Ever wanted to build a Slack bot but got overwhelmed by the setup complexity? This minimal webhook template gets you a secure, production-ready Slack webhook handler with just a few commands.
The Template
Did you know there's a minimal Slack webhook template for Codehooks.io that makes it ridiculously easy to start building Slack integrations? Here's what makes it great:
- ~90 lines of code - No bloat, easy to understand
- Secure by default - HMAC SHA-256 signature verification built-in
- Production-ready - Handles URL verification, signature validation, and timing attacks
- Serverless - No servers to manage, auto-scales
Getting Started
coho create myapp --template webhook-slack-minimal
cd myapp
npm install
coho deploy
That's it. Three commands. Your webhook is live.
What You Get Out of the Box
The template handles all the boring security stuff for you:
// Automatic signature verification
function verifySlackSignature(body, signature, timestamp) {
// Rejects requests older than 5 minutes
// Uses timing-safe comparison
// Validates HMAC SHA-256 signature
}
// URL verification for Slack setup
if (body.type === 'url_verification') {
return res.json({ challenge: body.challenge });
}
// Your bot logic starts here
if (event.type === 'message' && !event.bot_id && event.text) {
console.log('Message:', event.text);
// Do something cool
}
Just add your SLACK_SIGNING_SECRET environment variable, point Slack at your webhook URL, and you're receiving events.
Cool Use Cases
Here are some practical ways teams are using Slack bots:
1. Incident Response Bot
Automatically create tickets and notify on-call engineers when someone types @bot incident in your #alerts channel. Parse the message, extract severity levels, and kick off your incident management workflow. Integrate with PagerDuty, Jira, or your internal tools.
if (event.text.includes('incident')) {
// Parse incident details
// Create ticket in your system
// Page on-call engineer
// Post confirmation back to channel
}
2. Code Review Reminder Bot
Monitor your #engineering channel and remind developers about pending code reviews. When someone mentions a PR link, the bot tracks it and sends daily reminders until it's merged. Integrates with GitHub/GitLab APIs to check PR status.
if (event.text.includes('github.com') && event.text.includes('/pull/')) {
// Extract PR URL
// Check PR status via GitHub API
// Schedule reminders for reviewers
// Update team when merged
}
3. Knowledge Base Assistant
Create a smart assistant that answers common questions by searching your internal docs. Team members can ask @bot how do I deploy? and get instant answers with links to relevant documentation. Saves your team from answering the same questions repeatedly.
if (event.text.includes('@bot')) {
const query = extractQuery(event.text);
// Search your knowledge base
// Format relevant results
// Post back with helpful links
}
Why This Matters
Most Slack bot tutorials leave you wading through authentication flows, webhook verification logic, and security best practices. This template gives you that foundation in ~90 lines, so you can focus on building the actual bot logic.
The Codehooks.io platform handles deployment, scaling, environment variables, and logging. You just write JavaScript and deploy.
Next Steps
The template is minimal on purpose - it's designed to be extended. Here's what you might add:
- Install
@slack/web-apito post messages back to Slack - Add slash commands for interactive workflows
- Connect to databases, APIs, or AI services
- Handle reactions, mentions, or other event types
Check out the template on GitHub and start building your Slack bot today!
Resources
What would you build with this template? Drop your ideas in the comments!
Top comments (0)