#How to get the number of sender in web whatsapp JS

11 messages · Page 1 of 1 (latest)

frank lantern
#

I want to get the number of new sender and save it in a text file. Is this possible to achieve? any help would be appreciated. Thanks

if (!(sender in userInfo)) {
    console.log("This is a new user.");

    // Create a text file and write the sender number to it
    fs.writeFile('new_users.txt', sender, (err) => {
        if (err) throw err;
        console.log('Sender number added to new_users.txt');
    });

    client.sendMessage(sender, greetings, { mentions: [contact] });
    
    userInfo[sender] = {
        "mode": "mode 1",
        "currentStage": "begin",
        "voice_id": "base",
        "elevenLabsLatency": 3,
    };
    
    return;
}```
oblique lance
#
console.log(msg.getContact());

You can see all properties for the contact.

frank lantern
#

can we use this to get the number and save it in txt?

oblique lance
#

You can do whatever you want if the information.

frank lantern
#

Thanks I will look into it

#
        console.log("This is new user.");
        message.getContact().then(contact => {
            console.log("The contact is -> " + contact.number);
            contact.number = contact.number.split('@')[0];
            //save the contact number in the in txt file
            fs.appendFile('contacts.txt', contact.number + '\n', function (err) {
                if (err) throw err;
                console.log('Saved!');
            });

        });
turbid raft
oblique lance
turbid raft
frank lantern
#

Do we have any idea how long would it actually take?