Public Directory

You can listen to the public folder by specifying a public object in the webhookListener function. With this feature, you can make your transfers from your public folder without requiring an additional intermediate server when sending images, files, etc. over whatsapp.

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",
	public: {
		name: "/public" // this is public path on your hostname. For example: https://<your_sub>.ngrok-free.app/public
		path: "path/to/public/dir" // this is public files dir
	}
});

As you can see, the Events class is called and the Events in it are selected. You can take a look at 2Chat Documentation to learn which Event does what.

Last updated