🌐How to Create Webhook Server

If you want to receive incoming and outgoing messages, you need to install Webhook Listener. We have listed the steps for this respectively:

  • You need to obtain a tunnel address via NGROK. How do I do it?

  • You need to call and configure the webhookServer class in the WhatsappJS class.

An example is given below.


import { WhatsappJS } from '@efesoroglu/whatsappjs'

const client = new WhatsappJS("<your-api-key>", "<channel-phone-number>");

client.webhookServer({
	port: 8080,
	events: ["whatsapp.message.new"],
	host_name: "https://<your_sub>.ngrok-free.app",
});

client.once('ready', (client) => {
	console.log(`The bot started with the name ${client.client_name} (${client.phone_number})!`);
});

client.start();

Last updated