Adela
Adela

Reputation: 23

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

Upvotes: 0

Views: 2972

Answers (2)

Dhiren Jaypal
Dhiren Jaypal

Reputation: 163

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.

Upvotes: 0

shubhamM
shubhamM

Reputation: 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   
} });

Upvotes: 0

Related Questions