Starting Client

To start your client, you first need to call the WhatsappJS class using your 2Chat API Key and your Channel phone number.

Below is an example:


import { WhatsappJS } from '@efesoroglu/whatsappjs'

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

client.start();

Finally, you can now listen for the ready event and see that your bot has started.

Below is an example:


import { WhatsappJS } from '@efesoroglu/whatsappjs'

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

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

client.start();

Now you are ready! You have created your first bot.

Last updated