Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

98
Views
I want to build my own webhook dispatch server using node js?

I am trying to build a webhook server using node js. If any user sets their server URL as a hook using API provided by me, then my webhook server should respond to that user server.

I got this idea from the Facebook Messenger Chatbot application which uses the same approach.

Server 1 - My Server

const express = require("express");
const axios = require("axios");

const app = express();
const PORT = 3000;

/* Set Middleware to Express App */
app.use(express.json());

// Routes
app.post("/handle-webhooks", (req, res) => {
    const body = {"id": "1", "message": "hello"};
    const headers = {
        'Content-Type': "application/json",
    }
    const clientWebhookUrl = "http://localhost:8093/webhook2" // This will be different for each client
    axios.post(clientWebhookUrl, body, {headers})
    return res.sendStatus(200);
})

app.post("/set-webhook", (req,res) => {
    const clientWebhookUrl = req.url;
    // This URL will be saved to database
    return res.sendStatus(200)
}

/* Listen Server */
app.listen(PORT, () => {
    console.log(`App is listening on port ${PORT}.`);
})

Server 2 - My Client 1 Server

Using postman, the Client will make a post request to http://localhost:3000/set-webhook and set the webhook2 endpoint of his web server as a webhook URL to receive a response from my server.

const express = require("express");
const axios = require("axios");

const app = express();
const PORT = 8093;

/* Set Middleware to Express App */
app.use(express.json());

// Routes
app.post("/webhook2", (req, res) => {
    const body = req.body; // receives {"id": "1", "message": "hello"}
    return res.status(200).send(body);
})

/* Listen Server */
app.listen(PORT, () => {
    console.log(`App is listening on port ${PORT}.`);
})

Is the above approach is correct for doing this task? or do I need to add more complex code for this?

Thanks.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!