open-wa / wa-automate-nodejs

💬 🤖 The most reliable tool for chatbots with advanced features. Be sure to 🌟 this repository for updates!
https://docs.openwa.dev/
Other
3.15k stars 601 forks source link

Trying to send msg to my contact #3105

Closed Kizuno18 closed 1 year ago

Kizuno18 commented 1 year ago

Are you using the latest version of the library?

What type of session are you experiencing this issue on?

Multi-device and I have set multiDevice to true in my config OR am using the --multi-device flag

What type of host account are you experiencing this issue on?

Business account

Mode

EASY API/CLI

Current Behavior

i wanna send message to my contact (who i deleted all chats)

but iam receiving ERROR: Not a contact.

Expected Behavior

this say in https://openwa.dev/docs/api/classes/api_Client.Client#sendtext

A license is NOT required to send messages with existing chats/contacts. A license is only required for starting conversations with new numbers.

but iam receiving ERROR: Not a contact.

Steps To Reproduce


 case '!test':
                    const contacts = await client.getAllContacts();
                    const minDelay = 1000; // minimum delay in milliseconds
                    const maxDelay = 5000; // maximum delay in milliseconds                    
                    await new Promise(resolve => setTimeout(resolve, 1000));
                    const messages = [
                        "iam here again, thanks for wait."                       
                        // Add more messages here               
                      ];

                      const groups = [
                        "Group News:\n https://chat.whatsapp.com/link_here",
                        // Add more group messages here 
                      ];

                    // Loop through the contacts and send a message to each one
                    for (const contact of contacts) {
                      const contactId = await contact.id;
                      const messageIndex = Math.floor(Math.random() * messages.length);
                      const groupIndex = Math.floor(Math.random() * groups.length);
                      const message = messages[messageIndex];
                      const group = groups[groupIndex];

                      // Send a message to the contact after a random delay between minDelay and maxDelay
                      setTimeout(async () => {
                        await client.sendText(contactId, message);
                        await client.sendText(contactId, group);
                      }, Math.floor(Math.random() * (maxDelay - minDelay)) + minDelay);
                    }
                  break;

create() code OR full CLI command + CONFIG

No response

DEBUG INFO

{
  "WA_VERSION": "2.2316.5",
  "WA_AUTOMATE_VERSION": "4.64.2",
  "BROWSER_VERSION": "HeadlessChrome/112.0.5615.29",
  "START_TS": 1681482458351,
  "RAM_INFO": "Total: 42.14 GB | Free: 23.69 GB",
  "PPTR_VERSION": "19.8.5",
  "LATEST_VERSION": true,
  "CLI": false
}

Environment

- OS: Windows 10
- Node: 18.15.0
- npm: 9.5.0

Screenshots/Logs

No response

Anything else?

No response

smashah commented 1 year ago

Is the contact in your phonebook? I suggest you don't delete all chats going forward.

Kizuno18 commented 1 year ago

yes, they are in my phonebook and google contacts, but i dont have oppened chat with them.

erm3nda commented 1 year ago

Same here, tried to send a message to a contact (which is another of my phones) and got the error "not a contact", which is false.