Getting Started with Whatsapp Unofficial
Make sure you install the packages and get your env variables first
Package Setup
Install the packages
npm install node-fetch
Add env variables
WOTMASTER_SECRET=... # A secret key for your app (starts with wotmaster_)
⚠️
If you don't already have a wotmaster secret key, sign up (opens in a new tab) and create one from the dashboard! (opens in a new tab)
Set Up A Whatsapp Unofficial Service
Connecting your whatsapp account.
All the Unofficial whatsapp message are send through your whatsapp account.
- Login (opens in a new tab) to wotmaster Service.
- Click on [add accounts].(https://wotmaster.com/dashboard/accounts (opens in a new tab))
- Scan the qr code from Whatsapp App.
- Check the status of the connected account.
Send request to send message
src/utils/sendMessage.ts
import fetch from "node-fetch";
const url = "http://wotmaster.com/api/wu/text";
const response = await fetch(url, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringfy({
key: "wotmaster_••••••••••••••••••••••••",
countryCode: "91",
phone: "9999999999",
instanceId: "••••••••••••••••••••••••",
text: "Hey, This message is sent from an api",
}),
});
if (response.ok) {
const body = await response.json();
const { id, phone, text, message } = body;
console.log(id, phone, text, message);
}
Params
key = WOTMASTER_SECRET
countryCode = International country code without +
phone = Whatsapp number of receiver without countryCode
instanceId = Instance Id of whatsapp account connected and active
text = Mesasge string to be sent to receiver