Connecting Hashnode to Slack: A Step-by-Step Webhook Integration Guide

I am an enthusiastic researcher and developer with a passion for using technology to innovate in business and education.
Search for a command to run...

I am an enthusiastic researcher and developer with a passion for using technology to innovate in business and education.
Super clean breakdown and love how you turned a messy webhook mismatch into a seamless, practical workflow
Ringkasan: Jika OpenClaw adalah AI Operating System yang menghubungkan berbagai layanan dan agent, maka Hermes adalah AI Worker yang fokus mengerjakan pekerjaan, belajar dari pengalaman, dan semakin p

Ketika membangun aplikasi modern seperti Next.js, Cloudflare Workers, platform AI, microservices, atau real-time dashboard, ada banyak istilah jaringan yang sering muncul: TCP, UDP, HTTP/2, QUIC, WebS

Setiap tahun, ribuan mahasiswa jurusan Teknologi Informasi, Sistem Informasi, dan Teknik Informatika diwisuda. Namun, tidak sedikit di antara mereka yang kemudian menghadapi kenyataan yang cukup berat

Jika Anda menggunakan Next.js, kemungkinan besar Anda pernah mendengar anggapan bahwa: "Next.js = Vercel" Padahal kenyataannya tidak harus demikian. Di sinilah OpenNext hadir. OpenNext adalah proyek

Saat pertama kali mencoba OpenCode Go, saya hampir langsung berlangganan tanpa membaca detail program yang mereka sediakan. Untungnya saya menemukan bahwa OpenCode memiliki program referral yang membe

Automating workflows is key to staying efficient. A great way to keep your team updated is to automatically announce new blog posts in a dedicated Slack channel. While both Hashnode and Slack support webhooks, they don't speak the same language out of the box.
This guide will walk you through the process of connecting Hashnode to Slack using a lightweight middleware API. We'll build this translator using the Hono framework and deploy it for free on Vercel.
The challenge is simple:
Hashnode's webhook sends a rich JSON object when a new post is published, containing details about the post, the blog, and the author.
Slack's Incoming Webhook expects a very specific, simple JSON format. At its most basic, it needs a text property, like this: {"text": "Hello, world"}.
Because Hashnode's payload doesn't have this top-level text property, a direct connection will fail. We need to create a small application to sit in the middle, catch the data from Hashnode, reformat it, and then forward it to Slack.
Before you start, make sure you have the following:
A Hashnode account and a blog.
A Slack workspace where you have permission to add applications.
A Vercel account for deployment (a free-tier account is sufficient).
Node.js and npm (or your preferred package manager) installed on your machine.
(Optional but Recommended) ngrok to inspect the initial webhook data.
First, we need to tell Slack to listen for incoming messages.
Go to the Slack App Directory and search for "Incoming Webhooks."
Click "Add to Slack" and choose the channel where you want the notifications to be posted.
Click "Add Incoming Webhooks Integration."
Slack will generate a unique Webhook URL. It will look something like this: https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX.
Copy this URL and keep it safe. Treat it like a password, as anyone with this URL can post messages to your channel.
ngrokTo understand what data we're working with, we can use ngrok to temporarily expose a local server to the internet and catch a sample webhook from Hashnode.
Create a simple local server. Create a file named inspector.js and add the following code:
import http from 'http';
const server = http.createServer((req, res) => {
let body = '';
req.on('data', chunk => {
body += chunk.toString();
});
req.on('end', () => {
console.log("--- Webhook Received ---");
console.log(JSON.parse(body));
console.log("------------------------");
res.end('OK');
});
});
server.listen(3000, () => console.log('Server listening on port 3000'));
Run the server:
node inspector.js
Expose it with ngrok. In a new terminal window, run:
ngrok http 3000
ngrok will give you a public "Forwarding" URL (e.g., https://random-string.ngrok.io). Copy the https version.
Configure Hashnode Webhook.
Go to your Hashnode blog's Dashboard -> Integrations.
In the "Webhooks" section, paste your ngrok URL.
Click "Add webhook."
Publish a new post (or update an existing one) on Hashnode to trigger the webhook.
Check your terminal. You will see the full JSON object sent by Hashnode. You'll notice it has a structure like {"post": {"title": "...", "url": "...", "author": {"name": "..."}}}. This confirms we need to extract data from this structure.
Now we'll build the actual middleware. Hono is an excellent choice because it's fast, lightweight, and easy to deploy on serverless platforms like Vercel.
Set up your project:
mkdir hashnode-to-slack
cd hashnode-to-slack
npm init -y
npm install hono
Create the API file. Create a new folder api and inside it, a file named index.js. Vercel automatically recognizes this structure.
hashnode-to-slack/
└── api/
└── index.js
Write the code. Open api/index.js and add the following:
import { Hono } from 'hono';
const app = new Hono();
app.post('/', async (c) => {
// Get the Slack Webhook URL from environment variables for security
const SLACK_WEBHOOK_URL = c.env.SLACK_WEBHOOK_URL;
if (!SLACK_WEBHOOK_URL) {
console.error("Slack Webhook URL is not configured.");
return c.json({ error: 'Server configuration error' }, 500);
}
try {
// 1. Receive and parse the webhook data from Hashnode
const hashnodeData = await c.req.json();
const post = hashnodeData.post;
// Ensure it's a new post publication event (optional but good practice)
if (hashnodeData.type !== 'post_published') {
return c.text('Event ignored. Not a new post.');
}
// 2. Extract the necessary information
const postTitle = post.title;
const postUrl = post.url;
const authorName = post.author.name;
// 3. Construct the Slack message payload
const slackMessage = {
text: `🎉 New post published by *${authorName}*!\n\n*<${postUrl}|${postTitle}>*`,
};
// 4. Send the formatted data to Slack
const response = await fetch(SLACK_WEBHOOK_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(slackMessage),
});
if (!response.ok) {
throw new Error(`Slack API responded with status: ${response.status}`);
}
// 5. Return a success response
return c.json({ success: true, message: 'Notification sent to Slack.' });
} catch (error) {
console.error('Error processing webhook:', error);
return c.json({ error: 'Failed to process request' }, 500);
}
});
export default app;
Deploying our Hono app to Vercel is straightforward.
Push to a Git provider. Push your hashnode-to-slack folder to a GitHub, GitLab, or Bitbucket repository.
Import to Vercel.
Log in to your Vercel dashboard and click "Add New... -> Project."
Import the Git repository you just created.
Vercel will automatically detect it as a Hono project. No special build commands are needed.
Add Environment Variable.
Before deploying, go to the project's Settings -> Environment Variables.
Add a new variable with the name SLACK_WEBHOOK_URL.
In the value field, paste the Slack Incoming Webhook URL you saved in Step 1.
Click "Save."
Deploy. Go back to the deployments tab and trigger a deployment. Vercel will build and deploy your application, giving you a production URL (e.g., https://your-project-name.vercel.app).
You're on the final step!
Copy your new Vercel production URL.
Go back to your Hashnode blog's Dashboard -> Integrations.
Delete the old ngrok webhook and add a new one, pasting in your Vercel URL.
Publish a new post on Hashnode to test the entire flow.
Within seconds, you should see a perfectly formatted notification appear in your designated Slack channel! 🚀
By creating a simple middleware service, you have successfully bridged the gap between Hashnode's webhook format and Slack's requirements. This pattern is incredibly powerful and can be adapted to connect many other services that have incompatible APIs. You can now easily customize the message format in your Hono app to include more details, like tags or a cover image, to create even richer notifications. Happy automating!