'whatsapp-web.js, how do I send someone a contact card of someone else?
How do I send someone a contact card of someone else in whatsapp-web.js? Can I send a contact card when The person I send the contact card is saved on my phone but the contact I want to send is not on the contact list on my phone
Solution 1:[1]
client.on('ready', async () => { try {
console.log('Client is ready!');
const saved = [];
var array = fs.readFileSync('numb.txt').toString().split("\n"); //reading file
for (i in array) {
//console.log(array[i]);
saved.push(array[i].substring(1)); //array with number
}
const contacts = [];
for (var i = 0; i < saved.length; i++) {
contacts.push(await client.getContactById(saved[i] + '@c.us')); }
client.sendMessage(to, contacts); //sending contact cards
} });
Solution 2:[2]
you can send it by sending vcard as text message.
Example:
client.on('ready', async () => {
client.sendMessage(
'[email protected]',
'BEGIN:VCARD
....(vcarddata)....
END:VCARD',
{'parseVCards':true}) // by default its true
.then(...).catch(...);
});
VCard will be parsed and made contact by parseVCard option.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | tdy |
Solution 2 | Dhiren Jaypal |