Search code examples
node.jswhatsappngrok

Receive WhatsApp messages using Node.js


I'm trying to read messages from users via WhatsApp api with ultramsg

and use NGROK

const express = require('express')
const bodyParser = require('body-parser')
const app = express()
const PORT = 4000
app.use(bodyParser.json())
app.listen(PORT, () => console.log(`Server running ${PORT}`))

ngrok show display 404 error


Solution

  • You need Setup a webhook route

    app.use(bodyParser.json())
    app.post('/test_webhook', (req, res) => {
      console.log(req.body)
      res.status(200).end()
    })
    

    Now Webhook URL is : http://your_ngrok_url/test_webhook