Is there an existing issue for this?
Is this a problem caused by your code, or is it specifically because of the library?
Describe the bug.
In WhatsApp Business accounts and in group chats, contact.number is almost always undefined, and names (pushname, name) are missing or incorrect.
Even after doing client.getContactById(), the sender/receiver number and proper name are not fetched reliably.
This is the #1 problem faced by 90% of developers using whatsapp-web.js with Business accounts.
Current unreliable behaviour
const contact = await client.getContactById(message.from);
console.log(contact.number); // → undefined (in Business accounts)
console.log(contact.pushname); // → undefined or wrong
### Expected Behavior
In WhatsApp Business accounts and in group chats, `contact.number` is almost always `undefined`, and names (`pushname`, `name`) are missing or incorrect.
Even after doing `client.getContactById()`, the sender/receiver number and proper name are not fetched reliably.
This is the #1 problem faced by 90% of developers using whatsapp-web.js with Business accounts.
### Current unreliable behaviour
```js
const contact = await client.getContactById(message.from);
console.log(contact.number); // → undefined (in Business accounts)
console.log(contact.pushname); // → undefined or wrong
### Steps to Reproduce the Bug or Issue
let senderName = 'N/A';
let receiverName = 'N/A';
try {
const senderContact = await client.getContactById(message.from);
senderName = senderContact.pushname || senderContact.name || 'N/A';
} catch (e) {}
try {
const receiverContact = await client.getContactById(message.to);
receiverName = receiverContact.pushname || receiverContact.name || 'N/A';
} catch (e) {}
// === 2. Apna real number (connected number) ===
const myNumber = client.info?.wid?._serialized?.split('@')[0] || 'unknown';
// === 3. Real sender & receiver numbers ===
let senderNumber = 'unknown';
let receiverNumber = 'unknown';
// Sender: agar hum khud bhej rahe hain to myNumber, warna contact.number
if (message.from.includes(myNumber) || message.from === client.info?.wid?._serialized) {
senderNumber = myNumber;
} else {
try {
const contact = await client.getContactById(message.from);
senderNumber = contact.number || (message.author || message.from).split('@')[0];
} catch (e) {
senderNumber = (message.author || message.from).split('@')[0];
}
}
// Receiver: agar hum receive kar rahe hain to myNumber, warna contact.number
if (message.to.includes(myNumber) || message.to === client.info?.wid?._serialized) {
receiverNumber = myNumber;
} else {
try {
const contact = await client.getContactById(message.to);
receiverNumber = contact.number || message.to.split('@')[0];
} catch (e) {
receiverNumber = message.to.split('@')[0];
}
}
### WhatsApp Account Type
Standard
### Browser Type
chromium
### Operation System Type
window|ubantu
### Phone OS Type
Android |IOS
### WhatsApp-Web.js Version
"whatsapp-web.js": "^1.34.2"
### WhatsApp Web Version
"whatsapp-web.js": "^1.34.2"
### Node.js Version
v20.13.0
### Authentication Strategy
LocalAuth
### Additional Context
_No response_
Is there an existing issue for this?
Is this a problem caused by your code, or is it specifically because of the library?
Describe the bug.
In WhatsApp Business accounts and in group chats,
contact.numberis almost alwaysundefined, and names (pushname,name) are missing or incorrect.Even after doing
client.getContactById(), the sender/receiver number and proper name are not fetched reliably.This is the #1 problem faced by 90% of developers using whatsapp-web.js with Business accounts.
Current unreliable behaviour