#Not getting banned (or at least trying not to)

1 messages · Page 1 of 1 (latest)

open lily
#

Sorry for my english, I'm using a translator

open wadi
#

nothing, it just works

#

dont abuse the API

civic blaze
#

WWebJS run a real instance of Whatsapp Web to avoid getting blocked. Just try not to send too many messages at once max 1 per second. Otherwise, everything is quite flexible, but you shouldn't exaggerate it

severe kelp
#

before doing anything ask yourself "would a regular whatsapp user do this?" if not you're likely to get identified as a bot and banned

charred epoch
#

I got a 3 seconds delay after each text. So far i have sent 20k plus texts

#

Treat it like a real Whatsapp instance

#

If you got a bot to reply to someone’s text, don’t immediately reply. Wait for a second or two before responding

#

Just like a real human

#

And if it’s making you money look into getting api

#

I am working on getting one soon

jagged eagle
# charred epoch I got a 3 seconds delay after each text. So far i have sent 20k plus texts

I do something like you, but never the same delay beteween messages... I add some extra stuffs:

  1. Random "Sleep" time between 1 to 4 seconds, but in milisecs... so i get a random value between 1.000 and 4.000 to wait.

  2. Our product is prior to ANSWER previous contacts, so 99% of the time, the our app receive the first message from the users; and only then we reply.

  3. We use the rule 1-1-1... 1 Whatsapp number - 1 Client per instance - 1 One IP unique address. So if some numer got a ban, it will not affect others

  4. As our bot is a "gateway" to messages, it works as a intermediate server. So when it receive a message, it will send it to the definitive server, and the server will show to the support staff, and this will take some seconds. Some msgs got answered in a few seconds, others can take a long time; so our app works as close to a real whatsapp web, but with a lot of attendants at the same time

charred epoch
#

I am using amocrm for customer communication and bots

#

Then i did a lot of automation using this library

#

That includes order processing

#

And payment links

#

Really like this stuff

#

Don’t wanna move to official api

#

Cos of 24 hr pricing limit for business initiated services

#

But we have to at one point

jagged eagle
#

My app send messages in a queue, and the queued task to send message is configured to have no parallel tasks just one. So, first i send the message, then add a random "Sleep" time, and after the sleep runs; i end the task to another get to the queue

charred epoch
#

What you are using for random?

#

Ps: not a js guy, i learnt js just for this library

#

And any suggestions on running chatbots using this code?

#

With like redis stream

#

To treat customer ls in conversations instead of new message

jagged eagle
#

Something like this

charred epoch
#

I created a function for sleep and using it in all

#

Will send the snippet when i am home

jagged eagle
#

as i am using miliseconds, there are 3.000 possible interval options. So it will make it close to a human behavior

jagged eagle
charred epoch
jagged eagle
#

i don't understand what do you mean here

charred epoch
#

Suppose someone sends a message

#

And bot replies with welcome

#

And convo proceeds

#

Instead of triggering the first message again

#

Basically a session servixe

jagged eagle
#

give me some minutes

charred epoch
#

Anytime

#

Thanks

#

I got a express api setup to send messages

jagged eagle
#
client.on('message', async (msg) => {
   if(msg.body === "Hey, can you help me!"){
      await sleepRandom();
      msg.reply('Of course i can help you');

      // Do not use then.
      sleepRandom()..then(async () => {
        msg.reply('Of course i can help you');
      })
   }

   if(msg.body === "Another option"){
     // sleep, then send, etc
   }
})

async sleepRandom() {
   const min = 1000;
   const max = 4000;
   const ms = Math.floor(Math.random()*(min-max))+max;
   await new Promise((resolve) => setTimeout(resolve, ms))
}
#

Something like this code

charred epoch
#

Something like this

jagged eagle
#

Of course, you can send the answer option to a queued task using redis, RabbitMQ, etc...

charred epoch
#

Welcome to company, ple enter your name

charred epoch
jagged eagle
#

the msg.body is just a single example on how to get it to answer and explain the use of sleep

charred epoch
#

I see

jagged eagle
#

yeah, just like i told hyou

#
  1. get the content of the msg you receive. It is on the body
  2. inspect the values with options you need to reply
  3. Give some random delay before answer
#

my code shows this to you

charred epoch
#

Will try that

#

Thanks

#

A lot

jagged eagle
#

In this case, i suggest you to store the flow in some database. So you can check the last received message content and the answer you send.

charred epoch
#

I am currently using dynamodb

#

For storing some data

jagged eagle
#

And you can add a TTL, Time To Live... a time to the option expires

#

So you can restart the flow

jagged eagle
#

there are infinite options. You need to enumerate what you need first, then create your rules

#

The example i give you is just a single exercise explaining how to use

#

Look at the part i comment, DO NOT USE .then... use await

#

this is an asynchronous 101 lesson

charred epoch
#

Here is what my crm does with whatsapp web

#

I wanna do similar using code

#

For some internal staff

jagged eagle
#

when you do something like this:

// Some code before

someAsyncFunctionCall().then(etc)

// Some code after the call

You WILL NOT LOCK THE EXECUTION FLOW and your code will continue to execute... and when its done, will execute the .then

charred epoch
#

Will try this

#

Thanks

#

🙏🏻

jagged eagle
#

But if you do something like this

// Some code before

await someAsyncFunctionCall()

// now execute the etc portion after the async done

// Some code after the call

Here YOU WILL LOCK THE EXECUTION FLOW and your code ONLY will continue to execute after the async call ends

#

So, if you use the async call to the sleep func with then, and have a lot of messages... the sleep will work, but a lot of these messages will be sent with a short sleep in parallel. But with await you will be guaranteed to only continue after finishing the current sleep, JUST ONE, not 50 with short delay

charred epoch
#

1-5 seconds is wait is all good

jagged eagle
#

Of course, inside the client messagelistener is not the right place to this. Here first i store the msg in a database, then run a queued job to proccess it. And is one bu one

jagged eagle
charred epoch
#

Lemme dig in on this weekend

#

I am a system admin guy

#

Starting programming earlier this year lol

rocky current
#

I'm only use dynamic random sleep duration based on text length.

open lily
#
        if (typeof content === 'string') {
            const chat = await <Client>.getChatById(chatId);
            await chat.sendStateTyping()

            const wpm = (content.split(' ').length / 90) * 60000;
            if (wpm < 25000) await chat.clearState()

            await new Promise((r) => setTimeout(r, wpm))
        }

        return this.client.sendMessage(chatId, content, options); ``` I made a way to simulate human typing, 90 words per minute (you can decrease it)
raw needle
#

Do whatsapp check ip location and mark as bot if their client is running on aws instance far away from their phone login ?

From my location and aws region its almost 900kms. So will it make any issue. There are no nearby regions awailable for me on aws.

And i cannot create different region instances manually for all client.

If this location creates any issue, is there any fix to spoof or proxy ip for each clients to show as different location on aws instance...

Please help...

jagged eagle
#

i am from Brazil and use AWS on Virginia, about 7.000Km, and of course another tel area codes

#

and in 27 months, so far so good

#

40 numbers and never got banned

jagged eagle
raw needle
rocky current
jagged eagle
#

Contabo sucka

jagged eagle
#

so in AWS was about $20 USD per number/server

#

but we are using Hetzner now aid ia about $7 each

rocky current
#

I'm using 1 docker container for 1 number. You also using hetzner, I also using it for my primary endpoint.

Anyway thanks for sharing

deep haven
#

@jagged eagle and what about buttons and list messages do you use it?

jagged eagle
#

just send & receive messages

hasty bone
civic blaze
#

You need to restart your instance

spring thistle
jagged eagle
#

we have customers with one number, others with 7 numbers

#

Some numbers have 5 new contacta asking for support per day

#

Others have 1.000 per day

spring thistle
# jagged eagle Others have 1.000 per day

Thanks! I am dimension a bot that will potentialy serve up to 5000 contacts, always replying their messages and with a random 2 to 4 seconds message delay. Needed to know if someone did it.

jagged eagle
#

And i ran a lot of chat.fetchMessages to get the last messages on each recent chat (last 3 days)... It helps capture non-sync msgs. Example: a simple disconnect and reconnect some minutes later will have messages not captured by the lib message and message_create events... And sometimes some messages até not sync right on wwweb

spring thistle
#

Becouse they will be notify 2 seconds or 500 seconds later depending on the demand of that time

jagged eagle
#

understand.

#

I run in queue using redis and bull dashboard. and limit it by one task per message and ONLY one message at time because in a normal "desktop" use of whatsapp web, users do not send messages on different chats simultaneously. So i add this filter to send one message then another and another.

#

And I add a custom delay of 2 to 10 seconds (and simulate typing/recording) before send

spring thistle
#

wil definitly try redis and bull dashboard complementing with agenda and mongo db. If users askk for same time appointments will escalate to a new number

glad sundial
#

Any one suggest ,what is an ideal time between two sending message so that is not included in bulk messaging?

jagged eagle
spring thistle
# jagged eagle I run in queue using redis and bull dashboard. and limit it by one task per mess...

Hi I am thinking my case where my users ask for a message at a given time example: 10:00 am. If i can send 1 at a time every 3 seconds i can only serve 20 users at 10:00 am the rest will recive message at 10:01:03 and so on.. Did you implemented a queque that schedules the message considerating the amount in line? Example: Schedule for 9:55am because y will have 5 min of messages to process?

jagged eagle
#

Jusr schedule the start, but do bot send bulk

#

Jusr one ar time

open lily
#

@jagged eagle

#

speak Portuguese?

jagged eagle
open lily
#

Pra mim o método mais eficiente é armazenar os eventos emitidos em uma array

#

e "re-emitir" cada um deles, com um tempo aleatoriamente definido